Skip to content

Commit

Permalink
Merge pull request #195 from wordpress-mobile/try/WPiOS-integration
Browse files Browse the repository at this point in the history
Changes to integrate Gutenberg-Mobile into the WPiOS App
  • Loading branch information
etoledom authored Nov 8, 2018
2 parents 16c6a60 + 2372f40 commit 9464e8c
Show file tree
Hide file tree
Showing 15 changed files with 255 additions and 171 deletions.
5 changes: 4 additions & 1 deletion ios/gutenberg-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
//

#import <React/RCTBundleURLProvider.h>

#import <React/RCTEventEmitter.h>
#import <React/RCTUIManager.h>
#import <React/RCTViewManager.h>
#import "Gutenberg.h"
42 changes: 22 additions & 20 deletions ios/gutenberg.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
2DCD954D1E0B4F2C00145EB5 /* gutenbergTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* gutenbergTests.m */; };
2DF0FFEE2056DD460020B375 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
7E4C21212187419000EC7F49 /* libRNReactNativeGutenbergBridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E4C211D2187417100EC7F49 /* libRNReactNativeGutenbergBridge.a */; };
7E45CC5B218B42E000C0B2AB /* libRNReactNativeGutenbergBridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E45CC5A218B42C000C0B2AB /* libRNReactNativeGutenbergBridge.a */; };
7EC7328F21907E3F00FED2E6 /* GutenbergViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EC7328E21907E3F00FED2E6 /* GutenbergViewController.swift */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
8C666FF0C9224FB88C2C0447 /* libRNSVG-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9BFAFEB337654221B2F14D03 /* libRNSVG-tvOS.a */; };
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
CF45443564B845C8BDCFBAB6 /* libRNTAztecView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3ADEFEC092CF4D00BEF1019E /* libRNTAztecView.a */; };
DD2AE937473A49B2B5A0E7B6 /* libRNSVG.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EB766FE2F6D446A80AC6E6A /* libRNSVG.a */; };
F1289ECB2100E4320091E81D /* Aztec.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1289ECA2100E4320091E81D /* Aztec.framework */; };
F151983B2100DC3D000F6E97 /* BridgeDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15198382100DC3C000F6E97 /* BridgeDelegate.swift */; };
F151983C2100DC3D000F6E97 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F15198392100DC3D000F6E97 /* AppDelegate.swift */; };
F151983D2100DC3D000F6E97 /* MediaProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F151983A2100DC3D000F6E97 /* MediaProvider.swift */; };
F19CFDA821021EB100EAB240 /* Aztec.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = F1289ECA2100E4320091E81D /* Aztec.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -305,9 +305,9 @@
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTLinking;
};
7E4C211C2187417100EC7F49 /* PBXContainerItemProxy */ = {
7E45CC59218B42C000C0B2AB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 7E4C20F32187417100EC7F49 /* RNReactNativeGutenbergBridge.xcodeproj */;
containerPortal = 7E45CC55218B42C000C0B2AB /* RNReactNativeGutenbergBridge.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNReactNativeGutenbergBridge;
Expand Down Expand Up @@ -386,16 +386,16 @@
3ADEFEC092CF4D00BEF1019E /* libRNTAztecView.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNTAztecView.a; sourceTree = "<group>"; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
7E4C20F32187417100EC7F49 /* RNReactNativeGutenbergBridge.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNReactNativeGutenbergBridge.xcodeproj; path = "../react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.xcodeproj"; sourceTree = "<group>"; };
7E45CC55218B42C000C0B2AB /* RNReactNativeGutenbergBridge.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNReactNativeGutenbergBridge.xcodeproj; path = "../react-native-gutenberg-bridge/ios/RNReactNativeGutenbergBridge.xcodeproj"; sourceTree = "<group>"; };
7EC7328E21907E3F00FED2E6 /* GutenbergViewController.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; name = GutenbergViewController.swift; path = gutenberg/GutenbergViewController.swift; sourceTree = "<group>"; tabWidth = 1; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
9B18D59B9364468890D0E546 /* RNSVG.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNSVG.xcodeproj; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = "<group>"; };
9BFAFEB337654221B2F14D03 /* libRNSVG-tvOS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = "libRNSVG-tvOS.a"; sourceTree = "<group>"; };
ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
F1289ECA2100E4320091E81D /* Aztec.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Aztec.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F15198372100DC3C000F6E97 /* gutenberg-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "gutenberg-Bridging-Header.h"; sourceTree = "<group>"; };
F15198382100DC3C000F6E97 /* BridgeDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BridgeDelegate.swift; path = gutenberg/BridgeDelegate.swift; sourceTree = "<group>"; };
F15198392100DC3D000F6E97 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = gutenberg/AppDelegate.swift; sourceTree = "<group>"; };
F151983A2100DC3D000F6E97 /* MediaProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaProvider.swift; path = gutenberg/MediaProvider.swift; sourceTree = "<group>"; };
F15198372100DC3C000F6E97 /* gutenberg-Bridging-Header.h */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = "gutenberg-Bridging-Header.h"; sourceTree = "<group>"; tabWidth = 1; };
F15198392100DC3D000F6E97 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = gutenberg/AppDelegate.swift; sourceTree = "<group>"; tabWidth = 1; };
F151983A2100DC3D000F6E97 /* MediaProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.swift; name = MediaProvider.swift; path = gutenberg/MediaProvider.swift; sourceTree = "<group>"; tabWidth = 1; usesTabs = 0; };
F619623252704B46A619C33C /* RNTAztecView.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNTAztecView.xcodeproj; path = "../react-native-aztec/ios/RNTAztecView.xcodeproj"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -413,7 +413,7 @@
buildActionMask = 2147483647;
files = (
F1289ECB2100E4320091E81D /* Aztec.framework in Frameworks */,
7E4C21212187419000EC7F49 /* libRNReactNativeGutenbergBridge.a in Frameworks */,
7E45CC5B218B42E000C0B2AB /* libRNReactNativeGutenbergBridge.a in Frameworks */,
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */,
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */,
146834051AC3E58100842450 /* libReact.a in Frameworks */,
Expand Down Expand Up @@ -544,7 +544,7 @@
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
F15198372100DC3C000F6E97 /* gutenberg-Bridging-Header.h */,
F15198392100DC3D000F6E97 /* AppDelegate.swift */,
F15198382100DC3C000F6E97 /* BridgeDelegate.swift */,
7EC7328E21907E3F00FED2E6 /* GutenbergViewController.swift */,
F151983A2100DC3D000F6E97 /* MediaProvider.swift */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
13B07FB61A68108700A75B9A /* Info.plist */,
Expand Down Expand Up @@ -603,18 +603,18 @@
name = Products;
sourceTree = "<group>";
};
7E4C20F42187417100EC7F49 /* Products */ = {
7E45CC56218B42C000C0B2AB /* Products */ = {
isa = PBXGroup;
children = (
7E4C211D2187417100EC7F49 /* libRNReactNativeGutenbergBridge.a */,
7E45CC5A218B42C000C0B2AB /* libRNReactNativeGutenbergBridge.a */,
);
name = Products;
sourceTree = "<group>";
};
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
7E4C20F32187417100EC7F49 /* RNReactNativeGutenbergBridge.xcodeproj */,
7E45CC55218B42C000C0B2AB /* RNReactNativeGutenbergBridge.xcodeproj */,
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */,
146833FF1AC3E56700842450 /* React.xcodeproj */,
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
Expand Down Expand Up @@ -869,8 +869,8 @@
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
},
{
ProductGroup = 7E4C20F42187417100EC7F49 /* Products */;
ProjectRef = 7E4C20F32187417100EC7F49 /* RNReactNativeGutenbergBridge.xcodeproj */;
ProductGroup = 7E45CC56218B42C000C0B2AB /* Products */;
ProjectRef = 7E45CC55218B42C000C0B2AB /* RNReactNativeGutenbergBridge.xcodeproj */;
},
{
ProductGroup = FFEDF6EF21241BDF007FCC6D /* Products */;
Expand Down Expand Up @@ -1137,11 +1137,11 @@
remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
7E4C211D2187417100EC7F49 /* libRNReactNativeGutenbergBridge.a */ = {
7E45CC5A218B42C000C0B2AB /* libRNReactNativeGutenbergBridge.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNReactNativeGutenbergBridge.a;
remoteRef = 7E4C211C2187417100EC7F49 /* PBXContainerItemProxy */;
remoteRef = 7E45CC59218B42C000C0B2AB /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
832341B51AAA6A8300B99B32 /* libRCTText.a */ = {
Expand Down Expand Up @@ -1228,7 +1228,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
};
2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -1260,8 +1260,8 @@
buildActionMask = 2147483647;
files = (
F151983C2100DC3D000F6E97 /* AppDelegate.swift in Sources */,
F151983B2100DC3D000F6E97 /* BridgeDelegate.swift in Sources */,
F151983D2100DC3D000F6E97 /* MediaProvider.swift in Sources */,
7EC7328F21907E3F00FED2E6 /* GutenbergViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1382,6 +1382,7 @@
"$(SRCROOT)/../react-native-aztec/example/iOS/example",
/usr/include/libxml2,
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
"$(SRCROOT)/../react-native-gutenberg-bridge/ios/**",
);
INFOPLIST_FILE = gutenberg/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down Expand Up @@ -1410,6 +1411,7 @@
"$(SRCROOT)/../react-native-aztec/example/iOS/example",
/usr/include/libxml2,
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
"$(SRCROOT)/../react-native-gutenberg-bridge/ios/**",
);
INFOPLIST_FILE = gutenberg/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
52 changes: 8 additions & 44 deletions ios/gutenberg/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,18 @@ import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

let mediaProvider = MediaProvider()

lazy var bridgeDelegate: BridgeDelegate = {
let sourceURL = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource: nil)!

return BridgeDelegate(sourceURL: sourceURL, mediaProvider: self.mediaProvider)
}()


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

let bridge = RCTBridge(delegate: bridgeDelegate, launchOptions: launchOptions)
let rootView = RCTRootView(bridge: bridge, moduleName: "gutenberg", initialProperties: nil)

rootView?.backgroundColor = .white


window = UIWindow(frame: UIScreen.main.bounds)

let rootViewController = UIViewController()

rootViewController.view = rootView
window?.rootViewController = rootViewController

let rootViewController = GutenbergViewController()

window?.rootViewController = UINavigationController(rootViewController: rootViewController)
window?.makeKeyAndVisible()

return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
30 changes: 0 additions & 30 deletions ios/gutenberg/BridgeDelegate.swift

This file was deleted.

31 changes: 31 additions & 0 deletions ios/gutenberg/GutenbergViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

import UIKit

class GutenbergViewController: UIViewController {
lazy var gutenberg = Gutenberg()

override func loadView() {
view = gutenberg.rootView
}

override func viewDidLoad() {
super.viewDidLoad()
addSaveButton()
gutenberg.delegate = self
navigationController?.navigationBar.isTranslucent = false
}

func addSaveButton() {
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .save, target: self, action: #selector(saveButtonPressed(sender:)))
}

@objc func saveButtonPressed(sender: UIBarButtonItem) {
gutenberg.requestHTML()
}
}

extension GutenbergViewController: GutenbergBridgeDelegate {
func gutenbergDidProvideHTML(_ html: String) {
print("Did receive HTML: \(html)")
}
}
Loading

0 comments on commit 9464e8c

Please sign in to comment.