From 97e6ea13714c7741d0ba6105523cfebd6e11f963 Mon Sep 17 00:00:00 2001 From: ericlewis Date: Fri, 15 Mar 2019 23:56:17 -0700 Subject: [PATCH] Fabric: working podspecs & works in RNTester (#23803) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This is the couple of hacks I used after I finished #23802 in order to get fabric working on RNTester. This is inspired from prior work by kmagiera. The goal of this PR is to show others what I’m struggling with, and to eventually merge it sans hacks. - Yarn Install - Uncomment the commented out pods in RNTester's pod file - Open RNTesterPods workspace - Run App - this is only for pods, the non-pod RNTester will no longer work until updated with fabric too. - `SurfaceHostingView` & `SurfaceHostingProxyRootView` both try to start the surface immediately, this leads to a race condition due to the javascript not having loaded yet, the hack here is: 1. Swizzle the `start` method on `RCTFabricSurface` to no-op when called. 2. Add observer for `RCTJavaScriptDidLoadNotification` 3. Call private method `_startAllSurfaces` on `_surfacePresenter` in AppDelegate when we receive `RCTJavaScriptDidLoadNotification`. [General] [Added] - Use Fabric in RNTester Pull Request resolved: https://github.com/facebook/react-native/pull/23803 Reviewed By: shergin, mdvacca Differential Revision: D14450726 Pulled By: fkgozali fbshipit-source-id: 8ae2d48634fecb60db539aaf0a2c89ba1f572c27 --- RNTester/ComponentRegistry.cpp | 48 ++++ RNTester/Podfile | 7 + RNTester/Podfile.lock | 67 +++--- RNTester/RNTester/AppDelegate.m | 49 ++++- .../RNTesterPods.xcodeproj/project.pbxproj | 102 ++++++++- RNTester/Swizzle_RCTFabricSurface.m | 50 +++++ RNTester/js/RNTesterApp.ios.js | 1 + React/React-RCTFabric.podspec | 49 +++++ ReactCommon/React-Fabric.podspec | 206 ++++++++++++++++++ .../fabric/graphics/React-graphics.podspec | 41 ++++ .../fabric/uimanager/UIManagerBinding.cpp | 1 + ReactCommon/jsi/JSCRuntime.cpp | 32 ++- ReactCommon/jsi/React-jsi.podspec | 9 + ReactCommon/yoga/yoga.podspec | 2 +- package.json | 1 + scripts/generate-rncore.sh | 13 ++ third-party-podspecs/Folly.podspec | 26 ++- yarn.lock | 18 ++ 18 files changed, 671 insertions(+), 51 deletions(-) create mode 100644 RNTester/ComponentRegistry.cpp create mode 100644 RNTester/Swizzle_RCTFabricSurface.m create mode 100644 React/React-RCTFabric.podspec create mode 100644 ReactCommon/React-Fabric.podspec create mode 100644 ReactCommon/fabric/graphics/React-graphics.podspec create mode 100644 scripts/generate-rncore.sh diff --git a/RNTester/ComponentRegistry.cpp b/RNTester/ComponentRegistry.cpp new file mode 100644 index 000000000..624161149 --- /dev/null +++ b/RNTester/ComponentRegistry.cpp @@ -0,0 +1,48 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#ifdef RN_FABRIC_ENABLED +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + +/** + * This is a sample implementation. Each app should provide its own. + */ +ComponentRegistryFactory getDefaultComponentRegistryFactory() { + return [](const EventDispatcher::Shared &eventDispatcher, + const SharedContextContainer &contextContainer) { + auto registry = std::make_shared(); + registry->registerComponentDescriptor(std::make_shared(eventDispatcher)); + registry->registerComponentDescriptor(std::make_shared(eventDispatcher, contextContainer)); + registry->registerComponentDescriptor(std::make_shared(eventDispatcher)); + registry->registerComponentDescriptor(std::make_shared(eventDispatcher, contextContainer)); + registry->registerComponentDescriptor(std::make_shared(eventDispatcher)); + registry->registerComponentDescriptor(std::make_shared(eventDispatcher)); + registry->registerComponentDescriptor(std::make_shared(eventDispatcher)); + registry->registerComponentDescriptor(std::make_shared(eventDispatcher)); + registry->registerComponentDescriptor(std::make_shared(eventDispatcher, contextContainer)); + return registry; + }; +} + +} // namespace react +} // namespace facebook +#endif diff --git a/RNTester/Podfile b/RNTester/Podfile index ec5fe7841..229ecb58a 100644 --- a/RNTester/Podfile +++ b/RNTester/Podfile @@ -25,6 +25,13 @@ target 'RNTester' do pod 'React-RCTVibration', :path => '../Libraries/Vibration' pod 'React-RCTWebSocket', :path => '../Libraries/WebSocket' + # Fabric Pods, uncomment these to enable in RNTester + # pod 'React-Fabric', :path => '../ReactCommon' + # pod 'React-graphics', :path => '../ReactCommon/fabric/graphics' + # pod 'React-jsi/Fabric', :path => '../ReactCommon/jsi' + # pod 'React-RCTFabric', :path => '../React' + # pod 'Folly/Fabric', :podspec => '../third-party-podspecs/Folly.podspec' + pod 'React-cxxreact', :path => '../ReactCommon/cxxreact' pod 'React-jsi', :path => '../ReactCommon/jsi' pod 'React-jsiexecutor', :path => '../ReactCommon/jsiexecutor' diff --git a/RNTester/Podfile.lock b/RNTester/Podfile.lock index d94cc10b5..85558e368 100644 --- a/RNTester/Podfile.lock +++ b/RNTester/Podfile.lock @@ -2,6 +2,11 @@ PODS: - boost-for-react-native (1.63.0) - DoubleConversion (1.1.6) - Folly (2018.10.22.00): + - boost-for-react-native + - DoubleConversion + - Folly/Default (= 2018.10.22.00) + - glog + - Folly/Default (2018.10.22.00): - boost-for-react-native - DoubleConversion - glog @@ -42,6 +47,12 @@ PODS: - DoubleConversion - Folly (= 2018.10.22.00) - glog + - React-jsi/Default (= 1000.0.0) + - React-jsi/Default (1000.0.0): + - boost-for-react-native (= 1.63.0) + - DoubleConversion + - Folly (= 2018.10.22.00) + - glog - React-jsiexecutor (1000.0.0): - DoubleConversion - Folly (= 2018.10.22.00) @@ -170,33 +181,33 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c - DoubleConversion: 3eb87e5bfd9737e9a8cc698f74ee064d00c8dafc - Folly: de497beb10f102453a1afa9edbf8cf8a251890de - glog: aefd1eb5dda2ab95ba0938556f34b98e2da3a60d - React: 4d01f91757abcfd2adccf80248285957ac1a2de2 - React-ART: f03123e0f0b9850db4733ad94ded11d29c719dc6 - React-Core: fcb8a6f34de5a43426efcb9dfda6a434c1b1275d - React-cxxreact: 2a2acf4466abf5b794da53bf69e757a885259452 - React-DevSupport: 140c1ccfa9ccba495977225c117dc78c8858224f - React-fishhook: aefe3414f44d4deaa880f0e39dc76644f1072bf7 - React-jsi: 425cd468e0be54cdc9009a2b4d2c1a4eada83805 - React-jsiexecutor: 520560a0b08226e4e758645940253e270b4d7d76 - React-jsinspector: c9020e3a37b7b27125d824b1d02b9be0d1c737ac - React-RCTActionSheet: 78b940169b3c12d199dbbd382c5a3d22ec2197e2 - React-RCTAnimation: da0026d00ed99669b6175a941189539d8f9d52a4 - React-RCTBlob: c5a2104bd8b8e0462fc35eefa9133dc04ced56dd - React-RCTCameraRoll: effa220c8e244af93b44011ab85cab814c469e08 - React-RCTGeolocation: 3517483e877750bae5a03d9f52e7b0e48c49651e - React-RCTImage: ed045a58ebc9c97870a4fe5d066fdf04f247023b - React-RCTLinking: e5f174d3f9e6ffe30087b9edc8c9860d62c1413c - React-RCTNetwork: 9fbf72be6083a4b5fffe3dc1afad9fa2b70c4f19 - React-RCTPushNotification: 106e9846882a8dcce372fc90531be996ce0bb29b - React-RCTSettings: afd7ae33bacd09b12c8a0d3151069d465344ce24 - React-RCTText: 03945b44521b34f89f9a728e1c265fa096af9f94 - React-RCTVibration: ef9e4e077360a599a1b59cee7d18398871d37759 - React-RCTWebSocket: 510a4eef2c064ef30508aba41628e6d69f4df4c5 - yoga: c63f2cb4fd93594d29e792c198a8050d5daf9fdf + DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2 + Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51 + glog: 1f3da668190260b06b429bb211bfbee5cd790c28 + React: 113a88ebe41487ae78bde6494495d0e25f9fe2ff + React-ART: 28f8815acbbc4816cec14866b59911a83eb780ed + React-Core: 9da7fd6dc9e1e773f578cae2a00621a7c4422816 + React-cxxreact: 7e670bad16eb78fa889573d931c12bb1003a3598 + React-DevSupport: f34768e3aad3e59ee9800c752a78bc6cb24d0f75 + React-fishhook: d2a67f0eaeef9fe0dca0526812ca8fcff4b6f17b + React-jsi: 74e5e06d56f71aff1cd75c7ca56cf0f27940e792 + React-jsiexecutor: ee776181a1ba315dbae9500c4dba5cb94ea3c5d2 + React-jsinspector: ea0a218071a11c3687cef2480580180caa6a64c0 + React-RCTActionSheet: caf6532394bdbbe0fc0ec2363c84f26bcfcdd36a + React-RCTAnimation: b324c6eb699637c735650c6180e13d003eeb0e56 + React-RCTBlob: 069290c8db758bb1d77523a06d117dd668b6cef3 + React-RCTCameraRoll: 353af870a0acd5ebb0bcf6a8187ed78d94c4c65e + React-RCTGeolocation: 4bbdba9893dc3f22b22553904e54ae46dcedf48b + React-RCTImage: 012d845d919177e2726743ad06052dda66592760 + React-RCTLinking: c6fe7b82bed97ce72203b2ce2f4aac87b1e2647f + React-RCTNetwork: 2a2b22a17cd965de53ba21c5ca392d0da84ef322 + React-RCTPushNotification: 13729b4a2b63b191f42ba7230a69f462f3b5a7f9 + React-RCTSettings: e36d7f7d566b80d4363176c2f76cc5eccfdd0ae1 + React-RCTText: 469ec754592c92fc639825e558908c2f0e783e2c + React-RCTVibration: ade3c169b54f3bc16c9a9918e17e48ef66aee6ba + React-RCTWebSocket: 90b78ed51d53d17db417d3956decba3f7ace58e4 + yoga: 542cb34fe3bca476487e08eb516dd640ea996a65 -PODFILE CHECKSUM: c144025e9b0ade3d8b536a343fee89da69391cdc +PODFILE CHECKSUM: 74d947ec52f59c3db4f273853e36d504be6e9414 -COCOAPODS: 1.6.0 +COCOAPODS: 1.6.1 diff --git a/RNTester/RNTester/AppDelegate.m b/RNTester/RNTester/AppDelegate.m index 5986de77d..716d9d1cd 100644 --- a/RNTester/RNTester/AppDelegate.m +++ b/RNTester/RNTester/AppDelegate.m @@ -18,28 +18,54 @@ #import #endif -@interface AppDelegate() +#ifdef RN_FABRIC_ENABLED +#import +#import +@interface AppDelegate() { + RCTSurfacePresenter *_surfacePresenter; +} @end +// FIXME: remove when resolved https://github.com/facebook/react-native/issues/23910 +@interface RCTSurfacePresenter () +-(void)_startAllSurfaces; +@end + +#else +@interface AppDelegate() +@end +#endif + @implementation AppDelegate - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { _bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; - + // Appetizer.io params check - NSDictionary *initProps = nil; + NSDictionary *initProps = @{}; NSString *_routeUri = [[NSUserDefaults standardUserDefaults] stringForKey:@"route"]; if (_routeUri) { initProps = @{@"exampleFromAppetizeParams": [NSString stringWithFormat:@"rntester://example/%@Example", _routeUri]}; } + +#ifdef RN_FABRIC_ENABLED + // FIXME: remove when resolved https://github.com/facebook/react-native/issues/23910 + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(handleJavaScriptDidLoadNotification:) + name:RCTJavaScriptDidLoadNotification + object:_bridge]; + + _surfacePresenter = [[RCTSurfacePresenter alloc] initWithBridge:_bridge config:nil]; + _bridge.surfacePresenter = _surfacePresenter; - RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:_bridge - moduleName:@"RNTesterApp" - initialProperties:initProps]; - + UIView *rootView = [[RCTFabricSurfaceHostingProxyRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps]; +#else + UIView *rootView = [[RCTRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps]; +#endif + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; @@ -48,6 +74,15 @@ return YES; } +#ifdef RN_FABRIC_ENABLED +// FIXME: remove when resolved https://github.com/facebook/react-native/issues/23910 +- (void)handleJavaScriptDidLoadNotification:(__unused NSNotification*)notification { + dispatch_async(dispatch_get_main_queue(), ^{ + [self->_surfacePresenter _startAllSurfaces]; + }); +} +#endif + - (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge { return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"RNTester/js/RNTesterApp.ios" diff --git a/RNTester/RNTesterPods.xcodeproj/project.pbxproj b/RNTester/RNTesterPods.xcodeproj/project.pbxproj index 1802a7d7a..53484cc64 100644 --- a/RNTester/RNTesterPods.xcodeproj/project.pbxproj +++ b/RNTester/RNTesterPods.xcodeproj/project.pbxproj @@ -17,7 +17,9 @@ 3D13F84A1D6F6AFD00E69E0E /* OtherImages.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3D13F8451D6F6AF200E69E0E /* OtherImages.xcassets */; }; 3D2AFAF51D646CF80089D1A3 /* legacy_image@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3D2AFAF41D646CF80089D1A3 /* legacy_image@2x.png */; }; 3D56F9F11D6F6E9B00F53A06 /* RNTesterBundle.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 3D13F83E1D6F6AE000E69E0E /* RNTesterBundle.bundle */; }; - EC31D453B972BC46FE559C89 /* libPods-RNTester.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C062A1C08AD9375355BE47F /* libPods-RNTester.a */; }; + 68D134442238528800D0B233 /* Swizzle_RCTFabricSurface.m in Sources */ = {isa = PBXBuildFile; fileRef = 68D134432238528800D0B233 /* Swizzle_RCTFabricSurface.m */; }; + 68E1E4BC2230DF2F00570185 /* ComponentRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 68E1E4BB2230DF2F00570185 /* ComponentRegistry.cpp */; }; + B9C5BB1881F54450DBCA70F5 /* libPods-RNTester.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8508AD3C1DC3509924E63948 /* libPods-RNTester.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -33,7 +35,7 @@ /* Begin PBXFileReference section */ 13B07F961A680F5B00A75B9A /* RNTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RNTester.app; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = RNTester/AppDelegate.h; sourceTree = ""; }; - 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = RNTester/AppDelegate.m; sourceTree = ""; }; + 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = AppDelegate.m; path = RNTester/AppDelegate.m; sourceTree = ""; }; 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RNTester/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = RNTester/main.m; sourceTree = ""; }; @@ -48,7 +50,9 @@ 3D13F8451D6F6AF200E69E0E /* OtherImages.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = OtherImages.xcassets; sourceTree = ""; }; 3D2AFAF41D646CF80089D1A3 /* legacy_image@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "legacy_image@2x.png"; path = "RNTester/legacy_image@2x.png"; sourceTree = ""; }; 5BEC8567F3741044B6A5EFC5 /* Pods-RNTester.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTester.release.xcconfig"; path = "Pods/Target Support Files/Pods-RNTester/Pods-RNTester.release.xcconfig"; sourceTree = ""; }; - 6C062A1C08AD9375355BE47F /* libPods-RNTester.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTester.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 68D134432238528800D0B233 /* Swizzle_RCTFabricSurface.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Swizzle_RCTFabricSurface.m; sourceTree = ""; }; + 68E1E4BB2230DF2F00570185 /* ComponentRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ComponentRegistry.cpp; sourceTree = ""; }; + 8508AD3C1DC3509924E63948 /* libPods-RNTester.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTester.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 98233960D1D6A1977D1C7EAF /* Pods-RNTester.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTester.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RNTester/Pods-RNTester.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -57,7 +61,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - EC31D453B972BC46FE559C89 /* libPods-RNTester.a in Frameworks */, + B9C5BB1881F54450DBCA70F5 /* libPods-RNTester.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -83,12 +87,13 @@ 13B07FAE1A68108700A75B9A /* RNTester */ = { isa = PBXGroup; children = ( - 2DDEF00F1F84BF7B00DBDF73 /* Images.xcassets */, - 272E6B3A1BEA846C001FCF37 /* NativeExampleViews */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.m */, - 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, 13B07FB71A68108700A75B9A /* main.m */, + 2DDEF00F1F84BF7B00DBDF73 /* Images.xcassets */, + 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, + 680759612239798500290469 /* Fabric */, + 272E6B3A1BEA846C001FCF37 /* NativeExampleViews */, 1323F18D1C04ABAC0091BED0 /* Supporting Files */, ); name = RNTester; @@ -108,7 +113,7 @@ 2DE7E7D81FB2A4F3009E225D /* Frameworks */ = { isa = PBXGroup; children = ( - 6C062A1C08AD9375355BE47F /* libPods-RNTester.a */, + 8508AD3C1DC3509924E63948 /* libPods-RNTester.a */, ); name = Frameworks; sourceTree = ""; @@ -133,6 +138,15 @@ name = Pods; sourceTree = ""; }; + 680759612239798500290469 /* Fabric */ = { + isa = PBXGroup; + children = ( + 68E1E4BB2230DF2F00570185 /* ComponentRegistry.cpp */, + 68D134432238528800D0B233 /* Swizzle_RCTFabricSurface.m */, + ); + name = Fabric; + sourceTree = ""; + }; 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( @@ -269,7 +283,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi"; + shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n"; showEnvVarsInLog = 0; }; 68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */ = { @@ -311,8 +325,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 68E1E4BC2230DF2F00570185 /* ComponentRegistry.cpp in Sources */, 272E6B3F1BEA849E001FCF37 /* UpdatePropertiesExampleView.m in Sources */, 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, + 68D134442238528800D0B233 /* Swizzle_RCTFabricSurface.m in Sources */, 27F441EC1BEBE5030039B79C /* FlexibleSizeExampleView.m in Sources */, 13B07FC11A68108700A75B9A /* main.m in Sources */, ); @@ -353,10 +369,44 @@ baseConfigurationReference = 98233960D1D6A1977D1C7EAF /* Pods-RNTester.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; DEVELOPMENT_TEAM = V9WTTPBFK9; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "\"${PODS_ROOT}/Headers/Public\"", + "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"", + "\"${PODS_ROOT}/Headers/Public/React-ART\"", + "\"${PODS_ROOT}/Headers/Public/React-Core\"", + "\"${PODS_ROOT}/Headers/Public/React-DevSupport\"", + "\"${PODS_ROOT}/Headers/Public/React-Fabric\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTActionSheet\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTAnimation\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTBlob\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTCameraRoll\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTFabric\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTGeolocation\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTImage\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTLinking\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTNetwork\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTPushNotification\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTSettings\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTText\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTVibration\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTWebSocket\"", + "\"${PODS_ROOT}/Headers/Public/React-cxxreact\"", + "\"${PODS_ROOT}/Headers/Public/React-fishhook\"", + "\"${PODS_ROOT}/Headers/Public/React-jsi\"", + "\"${PODS_ROOT}/Headers/Public/React-jsiexecutor\"", + "\"${PODS_ROOT}/Headers/Public/React-jsinspector\"", + "\"${PODS_ROOT}/Headers/Public/glog\"", + "\"${PODS_ROOT}/Headers/Public/libevent\"", + "\"$(PODS_ROOT)/boost-for-react-native\"", + "\"$(PODS_ROOT)/Folly\"", + ); INFOPLIST_FILE = "$(SRCROOT)/RNTester/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_CFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = com.facebook.react.uiapp; PRODUCT_NAME = RNTester; TARGETED_DEVICE_FAMILY = "1,2"; @@ -368,10 +418,44 @@ baseConfigurationReference = 5BEC8567F3741044B6A5EFC5 /* Pods-RNTester.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "c++14"; DEVELOPMENT_TEAM = V9WTTPBFK9; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "\"${PODS_ROOT}/Headers/Public\"", + "\"${PODS_ROOT}/Headers/Public/DoubleConversion\"", + "\"${PODS_ROOT}/Headers/Public/React-ART\"", + "\"${PODS_ROOT}/Headers/Public/React-Core\"", + "\"${PODS_ROOT}/Headers/Public/React-DevSupport\"", + "\"${PODS_ROOT}/Headers/Public/React-Fabric\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTActionSheet\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTAnimation\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTBlob\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTCameraRoll\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTFabric\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTGeolocation\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTImage\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTLinking\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTNetwork\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTPushNotification\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTSettings\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTText\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTVibration\"", + "\"${PODS_ROOT}/Headers/Public/React-RCTWebSocket\"", + "\"${PODS_ROOT}/Headers/Public/React-cxxreact\"", + "\"${PODS_ROOT}/Headers/Public/React-fishhook\"", + "\"${PODS_ROOT}/Headers/Public/React-jsi\"", + "\"${PODS_ROOT}/Headers/Public/React-jsiexecutor\"", + "\"${PODS_ROOT}/Headers/Public/React-jsinspector\"", + "\"${PODS_ROOT}/Headers/Public/glog\"", + "\"${PODS_ROOT}/Headers/Public/libevent\"", + "\"$(PODS_ROOT)/boost-for-react-native\"", + "\"$(PODS_ROOT)/Folly\"", + ); INFOPLIST_FILE = "$(SRCROOT)/RNTester/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_CFLAGS = "$(inherited)"; PRODUCT_BUNDLE_IDENTIFIER = com.facebook.react.uiapp; PRODUCT_NAME = RNTester; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/RNTester/Swizzle_RCTFabricSurface.m b/RNTester/Swizzle_RCTFabricSurface.m new file mode 100644 index 000000000..60125ccef --- /dev/null +++ b/RNTester/Swizzle_RCTFabricSurface.m @@ -0,0 +1,50 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#ifdef RN_FABRIC_ENABLED +#import +#import + +// FIXME: remove when resolved https://github.com/facebook/react-native/issues/23910 +@implementation RCTFabricSurface (SwizzleMeTimbers) + ++ (void)load { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + Class class = [self class]; + + SEL originalSelector = @selector((start)); + SEL swizzledSelector = @selector(xxx_start); + + Method originalMethod = class_getInstanceMethod(class, originalSelector); + Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); + + BOOL didAddMethod = + class_addMethod(class, + originalSelector, + method_getImplementation(swizzledMethod), + method_getTypeEncoding(swizzledMethod)); + + if (didAddMethod) { + class_replaceMethod(class, + swizzledSelector, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)); + } else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } + }); +} + +#pragma mark - Method Swizzling + +- (void)xxx_start { + NSLog(@"RCTSurface start: %@", self); +} + +@end +#endif diff --git a/RNTester/js/RNTesterApp.ios.js b/RNTester/js/RNTesterApp.ios.js index c0c467261..bf4ea6c26 100644 --- a/RNTester/js/RNTesterApp.ios.js +++ b/RNTester/js/RNTesterApp.ios.js @@ -148,6 +148,7 @@ const styles = StyleSheet.create({ top: 7, left: 0, right: 0, + alignItems: 'center', }, title: { fontSize: 19, diff --git a/React/React-RCTFabric.podspec b/React/React-RCTFabric.podspec new file mode 100644 index 000000000..04d3ffc66 --- /dev/null +++ b/React/React-RCTFabric.podspec @@ -0,0 +1,49 @@ +# coding: utf-8 +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip +else + source[:tag] = "v#{version}" +end + +folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1' +folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32' +folly_version = '2018.10.22.00' +boost_compiler_flags = '-Wno-documentation' + +Pod::Spec.new do |s| + s.name = "React-RCTFabric" + s.version = version + s.summary = "RCTFabric for React Native." + s.homepage = "http://facebook.github.io/react-native/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "9.0", :tvos => "9.2" } + s.source = source + s.source_files = "Fabric/**/*.{c,h,m,mm,S,cpp}" + s.exclude_files = "**/tests/*", + "**/android/*", + s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags + s.header_dir = "React" + s.framework = "JavaScriptCore" + s.library = "stdc++" + s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Folly\"" } + s.xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/Folly\"", + "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" + " " + folly_flags } + + s.dependency "React-Core", version + s.dependency "React-Fabric", version + s.dependency "React-RCTImage", version + s.dependency "Folly/Fabric", folly_version +end diff --git a/ReactCommon/React-Fabric.podspec b/ReactCommon/React-Fabric.podspec new file mode 100644 index 000000000..9bc54dc9c --- /dev/null +++ b/ReactCommon/React-Fabric.podspec @@ -0,0 +1,206 @@ +# coding: utf-8 +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip +else + source[:tag] = "v#{version}" +end + +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' +folly_version = '2018.10.22.00' +folly_dep_name = 'Folly/Fabric' +boost_compiler_flags = '-Wno-documentation' + +Pod::Spec.new do |s| + s.name = "React-Fabric" + s.version = version + s.summary = "Fabric for React Native." + s.homepage = "http://facebook.github.io/react-native/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "9.0", :tvos => "9.2" } + s.source = source + s.prepare_command = File.read("../scripts/generate-rncore.sh") + s.source_files = "dummyFile.cpp" + s.library = "stdc++" + s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14" } + + s.dependency folly_dep_name, folly_version + s.dependency "React-graphics", version + s.dependency "React-jsiexecutor", version + + s.subspec "attributedstring" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "fabric/attributedstring/**/*.{m,mm,cpp,h}" + ss.exclude_files = "**/tests/*" + ss.header_dir = "react/attributedstring" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + s.subspec "better" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "better/**/*.{m,mm,cpp,h}" + ss.exclude_files = "**/tests/*" + ss.header_dir = "better" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + s.subspec "config" do |ss| + ss.source_files = "config/*.{m,mm,cpp,h}" + ss.header_dir = "react/config" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"" } + end + + s.subspec "core" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags + ss.source_files = "fabric/core/**/*.{m,mm,cpp,h}" + ss.exclude_files = "**/tests/*" + ss.header_dir = "react/core" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + s.subspec "components" do |ss| + ss.subspec "activityindicator" do |sss| + sss.dependency folly_dep_name, folly_version + sss.compiler_flags = folly_compiler_flags + sss.source_files = "fabric/components/activityindicator/**/*.{m,mm,cpp,h}" + sss.exclude_files = "**/tests/*" + sss.header_dir = "react/components/activityindicator" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + ss.subspec "image" do |sss| + sss.dependency folly_dep_name, folly_version + sss.compiler_flags = folly_compiler_flags + sss.source_files = "fabric/components/image/**/*.{m,mm,cpp,h}" + sss.exclude_files = "**/tests/*" + sss.header_dir = "react/components/image" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + ss.subspec "rncore" do |sss| + sss.dependency folly_dep_name, folly_version + sss.compiler_flags = folly_compiler_flags + sss.source_files = "fabric/components/rncore/*.{m,mm,cpp,h}" + sss.exclude_files = "**/tests/*" + sss.header_dir = "react/components/rncore" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + ss.subspec "root" do |sss| + sss.dependency folly_dep_name, folly_version + sss.compiler_flags = folly_compiler_flags + sss.source_files = "fabric/components/root/**/*.{m,mm,cpp,h}" + sss.exclude_files = "**/tests/*" + sss.header_dir = "react/components/root" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + ss.subspec "scrollview" do |sss| + sss.dependency folly_dep_name, folly_version + sss.compiler_flags = folly_compiler_flags + sss.source_files = "fabric/components/scrollview/**/*.{m,mm,cpp,h}" + sss.exclude_files = "**/tests/*" + sss.header_dir = "react/components/scrollview" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + ss.subspec "slider" do |sss| + sss.dependency folly_dep_name, folly_version + sss.compiler_flags = folly_compiler_flags + sss.source_files = "fabric/components/slider/**/*.{m,mm,cpp,h}" + sss.exclude_files = "**/tests/*", + "**/android/*" + sss.header_dir = "react/components/slider" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + ss.subspec "text" do |sss| + sss.dependency folly_dep_name, folly_version + sss.compiler_flags = folly_compiler_flags + sss.source_files = "fabric/components/text/**/*.{m,mm,cpp,h}" + sss.exclude_files = "**/tests/*" + sss.header_dir = "react/components/text" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + ss.subspec "view" do |sss| + sss.dependency folly_dep_name, folly_version + sss.dependency "yoga", "#{version}.React" + sss.compiler_flags = folly_compiler_flags + sss.source_files = "fabric/components/view/**/*.{m,mm,cpp,h}" + sss.exclude_files = "**/tests/*" + sss.header_dir = "react/components/view" + sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + end + + s.subspec "debug" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "fabric/debug/**/*.{m,mm,cpp,h}" + ss.exclude_files = "**/tests/*" + ss.header_dir = "react/debug" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + s.subspec "imagemanager" do |ss| + ss.dependency "React-RCTImage", version + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "fabric/imagemanager/**/*.{m,mm,cpp,h}" + ss.exclude_files = "**/tests/*", + "**/android/*" + ss.header_dir = "react/imagemanager" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + s.subspec "mounting" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "fabric/mounting/**/*.{m,mm,cpp,h}" + ss.exclude_files = "**/tests/*" + ss.header_dir = "react/mounting" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + s.subspec "textlayoutmanager" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "fabric/textlayoutmanager/**/*.{m,mm,cpp,h}" + ss.exclude_files = "**/tests/*", + "**/android/*" + ss.header_dir = "react/textlayoutmanager" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + s.subspec "uimanager" do |ss| + ss.dependency folly_dep_name, folly_version + ss.compiler_flags = folly_compiler_flags + ss.source_files = "fabric/uimanager/**/*.{m,mm,cpp,h}" + ss.exclude_files = "**/tests/*", + ss.header_dir = "react/uimanager" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end + + s.subspec "utils" do |ss| + ss.source_files = "utils/*.{m,mm,cpp,h}" + ss.header_dir = "react/utils" + ss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + end +end diff --git a/ReactCommon/fabric/graphics/React-graphics.podspec b/ReactCommon/fabric/graphics/React-graphics.podspec new file mode 100644 index 000000000..52c46a45e --- /dev/null +++ b/ReactCommon/fabric/graphics/React-graphics.podspec @@ -0,0 +1,41 @@ +# coding: utf-8 +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip +else + source[:tag] = "v#{version}" +end + +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' +folly_version = '2018.10.22.00' + +Pod::Spec.new do |s| + s.name = "React-graphics" + s.version = version + s.summary = "Fabric for React Native." + s.homepage = "http://facebook.github.io/react-native/" + s.license = package["license"] + s.author = "Facebook, Inc. and its affiliates" + s.platforms = { :ios => "9.0", :tvos => "9.2" } + s.source = source + s.library = "stdc++" + s.compiler_flags = folly_compiler_flags + s.source_files = "**/*.{m,mm,cpp,h}" + s.exclude_files = "**/tests/*", + "**/android/*" + s.header_dir = "react/graphics" + s.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/Folly\"" } + + s.dependency "Folly/Fabric", folly_version +end diff --git a/ReactCommon/fabric/uimanager/UIManagerBinding.cpp b/ReactCommon/fabric/uimanager/UIManagerBinding.cpp index 7fb8af5f6..29abd601b 100644 --- a/ReactCommon/fabric/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/fabric/uimanager/UIManagerBinding.cpp @@ -44,6 +44,7 @@ void UIManagerBinding::startSurface( folly::dynamic parameters = folly::dynamic::object(); parameters["rootTag"] = surfaceId; parameters["initialProps"] = initalProps; + parameters["fabric"] = true; auto module = getModule(runtime, "AppRegistry"); auto method = module.getPropertyAsFunction(runtime, "runApplication"); diff --git a/ReactCommon/jsi/JSCRuntime.cpp b/ReactCommon/jsi/JSCRuntime.cpp index 7a941d609..894ef87ec 100644 --- a/ReactCommon/jsi/JSCRuntime.cpp +++ b/ReactCommon/jsi/JSCRuntime.cpp @@ -150,6 +150,7 @@ class JSCRuntime : public jsi::Runtime { bool isHostFunction(const jsi::Function&) const override; jsi::Array getPropertyNames(const jsi::Object&) override; + // TODO: revisit this implementation jsi::WeakObject createWeakObject(const jsi::Object&) override; jsi::Value lockWeakObject(const jsi::WeakObject&) override; @@ -184,7 +185,11 @@ class JSCRuntime : public jsi::Runtime { static JSStringRef stringRef(const jsi::String& str); static JSStringRef stringRef(const jsi::PropNameID& sym); static JSObjectRef objectRef(const jsi::Object& obj); - + +#ifdef RN_FABRIC_ENABLED + static JSObjectRef objectRef(const jsi::WeakObject& obj); +#endif + // Factory methods for creating String/Object jsi::String createString(JSStringRef stringRef) const; jsi::PropNameID createPropNameID(JSStringRef stringRef); @@ -819,12 +824,24 @@ jsi::Array JSCRuntime::getPropertyNames(const jsi::Object& obj) { return result; } -jsi::WeakObject JSCRuntime::createWeakObject(const jsi::Object&) { +jsi::WeakObject JSCRuntime::createWeakObject(const jsi::Object& obj) { +#ifdef RN_FABRIC_ENABLED + // TODO: revisit this implementation + JSObjectRef objRef = objectRef(obj); + return make(makeObjectValue(objRef)); +#else throw std::logic_error("Not implemented"); +#endif } -jsi::Value JSCRuntime::lockWeakObject(const jsi::WeakObject&) { +jsi::Value JSCRuntime::lockWeakObject(const jsi::WeakObject& obj) { +#ifdef RN_FABRIC_ENABLED + // TODO: revisit this implementation + JSObjectRef objRef = objectRef(obj); + return jsi::Value(createObject(objRef)); +#else throw std::logic_error("Not implemented"); +#endif } jsi::Array JSCRuntime::createArray(size_t length) { @@ -1219,7 +1236,14 @@ JSStringRef JSCRuntime::stringRef(const jsi::PropNameID& sym) { JSObjectRef JSCRuntime::objectRef(const jsi::Object& obj) { return static_cast(getPointerValue(obj))->obj_; } - + +#ifdef RN_FABRIC_ENABLED +JSObjectRef JSCRuntime::objectRef(const jsi::WeakObject& obj) { + // TODO: revisit this implementation + return static_cast(getPointerValue(obj))->obj_; +} +#endif + void JSCRuntime::checkException(JSValueRef exc) { if (JSC_UNLIKELY(exc)) { throw jsi::JSError(*this, createValue(exc)); diff --git a/ReactCommon/jsi/React-jsi.podspec b/ReactCommon/jsi/React-jsi.podspec index 40632099d..c1509a22d 100644 --- a/ReactCommon/jsi/React-jsi.podspec +++ b/ReactCommon/jsi/React-jsi.podspec @@ -35,9 +35,18 @@ Pod::Spec.new do |s| s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/Folly\"" } s.header_dir = "jsi" + s.default_subspec = "Default" s.dependency "boost-for-react-native", "1.63.0" s.dependency "DoubleConversion" s.dependency "Folly", folly_version s.dependency "glog" + + s.subspec "Default" do + # no-op + end + + s.subspec "Fabric" do |ss| + ss.pod_target_xcconfig = { "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" } + end end diff --git a/ReactCommon/yoga/yoga.podspec b/ReactCommon/yoga/yoga.podspec index a1e6b9cf3..fd17f019c 100644 --- a/ReactCommon/yoga/yoga.podspec +++ b/ReactCommon/yoga/yoga.podspec @@ -47,7 +47,7 @@ Pod::Spec.new do |spec| source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION'] spec.source_files = source_files - header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h' + header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue,YGStyle,CompactValue,YGFloatOptional,Yoga-internal,YGNode,YGConfig,YGLayout,YGMarker}.h' header_files = File.join('ReactCommon/yoga', header_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION'] spec.public_header_files = header_files end diff --git a/package.json b/package.json index ecd0d1d1d..ddc862611 100644 --- a/package.json +++ b/package.json @@ -126,6 +126,7 @@ "eslint-plugin-react-hooks": "^1.0.1", "eslint-plugin-react-native": "3.5.0", "flow-bin": "^0.94.0", + "flow-remove-types": "1.2.3", "jest": "24.5.0", "jest-junit": "6.3.0", "jscodeshift": "^0.6.2", diff --git a/scripts/generate-rncore.sh b/scripts/generate-rncore.sh new file mode 100644 index 000000000..9392b3530 --- /dev/null +++ b/scripts/generate-rncore.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. +# +# This script collects the "core" component schemas used by fabric +# then uses react-native-codegen to generate the component headers +# to a location that the podspecs expect. + +# shellcheck disable=SC2038 +find "$PWD/../Libraries" -name "*Schema.js" -print | xargs yarn flow-node packages/react-native-codegen/buck_tests/combine-js-to-schema-cli.js schema-rncore.json +yarn flow-node packages/react-native-codegen/buck_tests/generate-tests.js schema-rncore.json rncore ReactCommon/fabric/components/rncore diff --git a/third-party-podspecs/Folly.podspec b/third-party-podspecs/Folly.podspec index 20aff7a7b..e601da88b 100644 --- a/third-party-podspecs/Folly.podspec +++ b/third-party-podspecs/Folly.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| spec.dependency 'boost-for-react-native' spec.dependency 'DoubleConversion' spec.dependency 'glog' - spec.compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation' + spec.compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_PTHREAD=1 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation' spec.source_files = 'folly/String.cpp', 'folly/Conv.cpp', 'folly/Demangle.cpp', @@ -32,6 +32,7 @@ Pod::Spec.new do |spec| 'folly/lang/Assume.cpp', 'folly/lang/ColdClass.cpp', 'folly/memory/detail/MallocImpl.cpp' + # workaround for https://github.com/facebook/react-native/issues/14326 spec.preserve_paths = 'folly/*.h', 'folly/container/*.h', @@ -48,6 +49,27 @@ Pod::Spec.new do |spec| "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\"" } + spec.default_subspec = 'Default' + + spec.subspec 'Default' do + # no-op + end + + spec.subspec 'Fabric' do |fabric| + fabric.source_files = 'folly/portability/SysUio.cpp', + 'folly/FileUtil.cpp', + 'folly/SharedMutex.cpp', + 'folly/concurrency/CacheLocality.cpp', + 'folly/detail/Futex.cpp', + 'folly/lang/SafeAssert.cpp', + 'folly/synchronization/ParkingLot.cpp', + 'folly/portability/Malloc.cpp' + fabric.preserve_paths = 'folly/concurrency/CacheLocality.h', + 'folly/synchronization/ParkingLot.h', + 'folly/synchronization/SanitizeThread.h', + 'folly/system/ThreadId.h' + end + # Pinning to the same version as React.podspec. spec.platforms = { :ios => "9.0", :tvos => "9.2" } -end +end \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index ce0c4d00f..29397fc29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1630,6 +1630,11 @@ babel-preset-jest@^24.3.0: "@babel/plugin-syntax-object-rest-spread" "^7.0.0" babel-plugin-jest-hoist "^24.3.0" +babylon@^6.15.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" + integrity sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ== + balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -3087,6 +3092,14 @@ flow-parser@0.*: resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.89.0.tgz#c87bf45831644733dd576983ab12e75a3546573b" integrity sha512-vC8YuwhAPE+tbkz49DA/TjtFyfhcqM48occMdRQiZ/HL+Wg97IcuebMZUGVB4oBq7aHw0iJJtnvmlnmOQF7Ydg== +flow-remove-types@1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-1.2.3.tgz#6131aefc7da43364bb8b479758c9dec7735d1a18" + integrity sha512-ypq/U3V+t9atYiOuSJd40tekCra03EHKoRsiK/wXGrsZimuum0kdwVY7Yv0HTaoXgHW1WiayomYd+Q3kkvPl9Q== + dependencies: + babylon "^6.15.0" + vlq "^0.2.1" + for-in@^1.0.1, for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" @@ -7210,6 +7223,11 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" +vlq@^0.2.1: + version "0.2.3" + resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.3.tgz#8f3e4328cf63b1540c0d67e1b2778386f8975b26" + integrity sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow== + w3c-hr-time@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045"