diff --git a/.circleci/config.yml b/.circleci/config.yml index 453586bbf6dd41..2e05bd0c47a5b2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,6 @@ defaults: &defaults - PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A: &github_token_a "78a72af35445ca3f8180" - PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B: &github_token_b "b1a98e0bbd56ff1ccba1" - # ------------------------- # EXECUTORS # ------------------------- @@ -152,13 +151,13 @@ commands: command: cp packages/rn-tester/Podfile.lock packages/rn-tester/Podfile.lock.bak - restore_cache: keys: - - v1-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }} - - v1-pods-{{ .Environment.CIRCLE_JOB }}- + - v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }} + - v3-pods-{{ .Environment.CIRCLE_JOB }}- - steps: << parameters.steps >> - save_cache: paths: - packages/rn-tester/Pods - key: v1-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }} + key: v3-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }} download_gradle_dependencies: steps: @@ -216,12 +215,12 @@ commands: jobs: setup: parameters: - executor: - type: executor - default: nodelts - checkout_type: - type: string - default: node + executor: + type: executor + default: nodelts + checkout_type: + type: string + default: node executor: << parameters.executor >> steps: - checkout @@ -261,7 +260,6 @@ jobs: DANGER_GITHUB_API_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" yarn danger ci --use-github-checks when: always - # ------------------------- # JOBS: Analyze Code # ------------------------- @@ -351,6 +349,9 @@ jobs: use_frameworks: type: boolean default: false + use_hermes: + type: boolean + default: false run_unit_tests: description: Specifies whether unit tests should run. type: boolean @@ -407,6 +408,13 @@ jobs: name: Set USE_FRAMEWORKS=1 command: echo "export USE_FRAMEWORKS=1" >> $BASH_ENV + - when: + condition: << parameters.use_hermes >> + steps: + - run: + name: Set USE_HERMES=1 + command: echo "export USE_HERMES=1" >> $BASH_ENV + - run: name: Setup the CocoaPods environment command: pod setup @@ -765,20 +773,31 @@ workflows: requires: - setup_android - test_ios: - name: test_ios_unit - run_disabled_tests: false + name: test_ios_unit_jsc + run_unit_tests: true + requires: + - setup_ios + - test_ios: + name: test_ios_unit_frameworks_jsc + use_frameworks: true + run_unit_tests: true + requires: + - setup_ios + - test_ios: + name: test_ios_unit_hermes + use_hermes: true run_unit_tests: true requires: - setup_ios - test_ios: - name: test_ios_unit_frameworks + name: test_ios_unit_frameworks_hermes + use_hermes: true use_frameworks: true run_unit_tests: true requires: - setup_ios # - test_ios: # name: test_ios_detox - # run_disabled_tests: false # run_detox_tests: true # requires: # - setup_ios diff --git a/IntegrationTests/GlobalEvalWithSourceUrlTest.js b/IntegrationTests/GlobalEvalWithSourceUrlTest.js index a30bfeec12df1a..fca7bfbc2170c7 100644 --- a/IntegrationTests/GlobalEvalWithSourceUrlTest.js +++ b/IntegrationTests/GlobalEvalWithSourceUrlTest.js @@ -10,6 +10,8 @@ 'use strict'; +import type {ExtendedError} from 'react-native/Libraries/Core/Devtools/parseErrorStack'; + const React = require('react'); const ReactNative = require('react-native'); const parseErrorStack = require('react-native/Libraries/Core/Devtools/parseErrorStack'); @@ -31,7 +33,7 @@ class GlobalEvalWithSourceUrlTest extends React.Component<{...}> { 'Expected globalEvalWithSourceUrl(expression) to return a value', ); } - let syntaxError; + let syntaxError: ?ExtendedError; try { global.globalEvalWithSourceUrl('{'); } catch (e) { @@ -42,7 +44,12 @@ class GlobalEvalWithSourceUrlTest extends React.Component<{...}> { 'Expected globalEvalWithSourceUrl to throw on a syntax error', ); } - if (!(syntaxError instanceof SyntaxError)) { + // Hermes throws an Error instead of a SyntaxError + // https://github.com/facebook/hermes/issues/400 + if ( + syntaxError.jsEngine !== 'hermes' && + !(syntaxError instanceof SyntaxError) + ) { throw new Error( 'Expected globalEvalWithSourceUrl to throw SyntaxError on a syntax error', ); diff --git a/React-Core.podspec b/React-Core.podspec index 5c69ed70f06778..9a2be90c4bc145 100644 --- a/React-Core.podspec +++ b/React-Core.podspec @@ -63,14 +63,14 @@ Pod::Spec.new do |s| end s.subspec "Hermes" do |ss| - ss.platforms = { :osx => "10.14" } + ss.platforms = { :osx => "10.14", :ios => "10.0" } ss.source_files = "ReactCommon/hermes/executor/*.{cpp,h}", "ReactCommon/hermes/inspector/*.{cpp,h}", "ReactCommon/hermes/inspector/chrome/*.{cpp,h}", "ReactCommon/hermes/inspector/detail/*.{cpp,h}" ss.pod_target_xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" } ss.dependency "RCT-Folly/Futures" - ss.dependency "hermes", "~> 0.6.0" + ss.dependency "hermes-engine" end s.subspec "DevSupport" do |ss| diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index c0caf5a8869b07..bf1647fc7acc02 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -37,7 +37,7 @@ #import #import -#if TARGET_OS_OSX && __has_include() +#if __has_include() #define RCT_USE_HERMES 1 #endif #if RCT_USE_HERMES diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile index a41e58ad5363b9..feb884bd0b84a8 100644 --- a/packages/rn-tester/Podfile +++ b/packages/rn-tester/Podfile @@ -8,12 +8,16 @@ if ENV['USE_FRAMEWORKS'] == '1' use_frameworks! end +if ENV['USE_HERMES'] == '1' + puts "Using Hermes engine" +end + def pods() project 'RNTesterPods.xcodeproj' # Enable TurboModule prefix_path = "../.." - use_react_native!(path:prefix_path) + use_react_native!(path: prefix_path, hermes_enabled: ENV['USE_HERMES'] == '1') pod 'ReactCommon/turbomodule/samples', :path => "#{prefix_path}/ReactCommon" # Additional Pods which aren't included in the default Podfile diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index c0f2c94818cdf1..7dfd23ee07ccb8 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -58,6 +58,8 @@ PODS: - FlipperKit/Core - FlipperKit/FlipperKitNetworkPlugin - glog (0.3.5) + - hermes-engine (0.7.1) + - libevent (2.1.11) - OpenSSL-Universal (1.0.2.19): - OpenSSL-Universal/Static (= 1.0.2.19) - OpenSSL-Universal/Static (1.0.2.19) @@ -70,6 +72,11 @@ PODS: - boost-for-react-native - DoubleConversion - glog + - RCT-Folly/Futures (2020.01.13.00): + - boost-for-react-native + - DoubleConversion + - glog + - libevent - RCTRequired (1000.0.0) - RCTTypeSafety (1000.0.0): - FBLazyVector (= 1000.0.0) @@ -127,6 +134,16 @@ PODS: - React-jsinspector (= 1000.0.0) - React-perflogger (= 1000.0.0) - Yoga + - React-Core/Hermes (1000.0.0): + - glog + - hermes-engine + - RCT-Folly (= 2020.01.13.00) + - RCT-Folly/Futures + - React-cxxreact (= 1000.0.0) + - React-jsi (= 1000.0.0) + - React-jsiexecutor (= 1000.0.0) + - React-perflogger (= 1000.0.0) + - Yoga - React-Core/RCTActionSheetHeaders (1000.0.0): - glog - RCT-Folly (= 2020.01.13.00) @@ -377,6 +394,8 @@ DEPENDENCIES: - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.54.0) - FlipperKit/SKIOSNetworkPlugin (~> 0.54.0) - glog (from `../../third-party-podspecs/glog.podspec`) + - hermes-engine + - libevent (from `../../third-party-podspecs/libevent.podspec`) - RCT-Folly (from `../../third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../../Libraries/RCTRequired`) - RCTTypeSafety (from `../../Libraries/TypeSafety`) @@ -384,6 +403,7 @@ DEPENDENCIES: - React-callinvoker (from `../../ReactCommon/callinvoker`) - React-Core (from `../../`) - React-Core/DevSupport (from `../../`) + - React-Core/Hermes (from `../../`) - React-Core/RCTWebSocket (from `../../`) - React-CoreModules (from `../../React/CoreModules`) - React-cxxreact (from `../../ReactCommon/cxxreact`) @@ -408,7 +428,7 @@ DEPENDENCIES: - Yoga (from `../../ReactCommon/yoga`) SPEC REPOS: - trunk: + https://cdn.cocoapods.org/: - boost-for-react-native - CocoaAsyncSocket - CocoaLibEvent @@ -419,6 +439,7 @@ SPEC REPOS: - Flipper-PeerTalk - Flipper-RSocket - FlipperKit + - hermes-engine - OpenSSL-Universal - YogaKit @@ -431,6 +452,8 @@ EXTERNAL SOURCES: :path: "../../Libraries/FBReactNativeSpec" glog: :podspec: "../../third-party-podspecs/glog.podspec" + libevent: + :podspec: "../../third-party-podspecs/libevent.podspec" RCT-Folly: :podspec: "../../third-party-podspecs/RCT-Folly.podspec" RCTRequired: @@ -488,9 +511,9 @@ SPEC CHECKSUMS: boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c CocoaAsyncSocket: 694058e7c0ed05a9e217d1b3c7ded962f4180845 CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f - DoubleConversion: cde416483dac037923206447da6e1454df403714 - FBLazyVector: fe973c09b2299b5e8154186ecf1f6554b4f70987 - FBReactNativeSpec: 20a9345af9157362b51ab0258d842cb7bb347d19 + DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de + FBLazyVector: 41b9b20a04ec7d992469c3c0100df42bd5bba9ba + FBReactNativeSpec: 1d4c3a5b3b08575ef17b566bfb41604adf854c7a Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365 Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 Flipper-Folly: c12092ea368353b58e992843a990a3225d4533c3 @@ -498,36 +521,38 @@ SPEC CHECKSUMS: Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 Flipper-RSocket: 64e7431a55835eb953b0bf984ef3b90ae9fdddd7 FlipperKit: ab353d41aea8aae2ea6daaf813e67496642f3d7d - glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3 + glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62 + hermes-engine: 2d25059126292d4375a46b65704767b3b0f529aa + libevent: 867cc03e654415675bcacf9726871a37c4b56b8a OpenSSL-Universal: 8b48cc0d10c1b2923617dfe5c178aa9ed2689355 - RCT-Folly: b39288cedafe50da43317ec7d91bcc8cc0abbf33 - RCTRequired: d3d4ce60e1e2282864d7560340690a3c8c646de1 - RCTTypeSafety: 4da4f9f218727257c50fd3bf2683a06cdb4fede3 - React: 87b3271d925336a94620915db5845c67c5dbbd77 - React-callinvoker: e9524d75cf0b7ae108868f8d34c0b8d7dc08ec03 - React-Core: f4eeb7ca3d6a7c2879d1d5b093800f23da9be617 - React-CoreModules: 87f011fa87190ffe979e443ce578ec93ec6ff4d4 - React-cxxreact: de6de17eac6bbaa4f9fad46b66e7f0c4aaaf863d - React-jsi: 790da16b69a61adc36829eed43c44187c1488d10 - React-jsiexecutor: 17a3e26806bc19d8be7b6c83792bffc46df796be - React-jsinspector: 01db8cd098c7ab72bd09abdda522a08c9acd3af9 - React-perflogger: 37913fce32026582ad0244b585d1e52652fd01c0 - React-RCTActionSheet: e6562ea4df7099af4023d1bd0e9716e43b45a5c9 - React-RCTAnimation: fc2f655a64f0791879ab03843cca90c53737d1cb - React-RCTBlob: 5f82467e5d3bef65d05cdd900df6e12b0849744a - React-RCTImage: f3a98834281555ce1bbbe1af0306aaf40ac70fc7 - React-RCTLinking: 801d05ad5e6d1636e977f4dfeab21f87358a02a5 - React-RCTNetwork: b5e2f27a098ca52d98426328640314a499da6d00 - React-RCTPushNotification: ce60993f816f917a6495227e16978b5fd550d73b - React-RCTSettings: 3cb638230af06ba769edc0bc4ed4123040b1b4e2 - React-RCTTest: 090e9816044220c39462be109dab6d473d94b1c9 - React-RCTText: 51a41bf9d18a91b2437b833ed4246754baf830d0 - React-RCTVibration: a1cce36dd452eb88296d99d80d66f2c5bd50aad4 - React-runtimeexecutor: 53867815d0a01e53a2c901cb7f01076216c5c799 - ReactCommon: d101410fc55088c91dc24595715c7b26ec760adf - Yoga: 69ef0b2bba5387523f793957a9f80dbd61e89631 + RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c + RCTRequired: 08a7ff32dfcf3d2a0d5975d8936aa461e751c94f + RCTTypeSafety: 6c06b6212c260279dceadfb492cc071b6ccaa94b + React: 11446588a4415be9685faa772f51617aedd42c53 + React-callinvoker: 91bb3d26e1bc03956a04f2fc4dfd18fa201c2116 + React-Core: 7cf15c7da07872c4eddda7e60fc782b5c90c3ec4 + React-CoreModules: fa38f1a0095cb23221f6e1ace508e002ab0859b5 + React-cxxreact: aaf9d64527d2ce9beb3c80167adde72c79fbd1d9 + React-jsi: e71179690ee4deb4bdb76f2e10023c22f0c0bafd + React-jsiexecutor: 260ee4bd8d0c5eab950d7222c88cdb71c4dd4a98 + React-jsinspector: 1a013b2751ebe53792abfaa9967058248c5586a8 + React-perflogger: 13cc0c550c30110ed2a661d081e649a9fb87cee8 + React-RCTActionSheet: 8d7c7f5f5df20a60f92ac04dd43c14a444fad7b1 + React-RCTAnimation: 153673bb315d67cbb5e107bc7fbdb07e67566690 + React-RCTBlob: 92e03c3a61cda7e3d745a04eb792d564bcdb9b52 + React-RCTImage: b7d345c55df0dd17b180e7f598a2db599d1a1dc7 + React-RCTLinking: 711815a70272557f3740621c00e69ffef1131f50 + React-RCTNetwork: 2fb0b1d61d12475b7decfbf728b8a4892f24efb6 + React-RCTPushNotification: 7f1fcd788b630b0ffee8ea2d3de4ad0260b6301d + React-RCTSettings: 41eee0ff18d317265f2f401da66c0e4cbe1a026d + React-RCTTest: de5b8af1586d82622e95a6ddf04ca2c78579c655 + React-RCTText: db9001d0d20425e5e50fe6d0a57ef4a8e8d1dc74 + React-RCTVibration: 2059c6d5fa254390e1f3874c55d026b282ebd579 + React-runtimeexecutor: 08bf2f4079793909fbece520244bc2b855607e36 + ReactCommon: fbf1cc0fe30d2442614975cb59515c12069c2054 + Yoga: 331a94ed76c4d00b4b5b0458296b8850c9b53ff2 YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 1d1cdc29892e8a27b768e0e7ce1ead435a53bf0c +PODFILE CHECKSUM: b7291ba95c2e06e414d49a93264f5ee198245f68 COCOAPODS: 1.10.0 diff --git a/packages/rn-tester/README.md b/packages/rn-tester/README.md index e1d52db22883a7..98027009b6fd47 100644 --- a/packages/rn-tester/README.md +++ b/packages/rn-tester/README.md @@ -15,7 +15,7 @@ Before running the app, make sure you ran: Both macOS and Xcode are required. - `cd packages/rn-tester` - Install [Bundler](https://bundler.io/): `gem install bundler`. We use bundler to install the right version of [CocoaPods](https://cocoapods.org/) locally. -- Install Bundler and CocoaPods dependencies: `bundle install && bundle exec pod install` +- Install Bundler and CocoaPods dependencies: `bundle install && bundle exec pod install`. In order to use Hermes engine instead of JSC, run: `USE_HERMES=1 bundle exec pod install` instead. - Open the generated `RNTesterPods.xcworkspace`. This is not checked in, as it is generated by CocoaPods. Do not open `RNTesterPods.xcodeproj` directly. ### Running on Android diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index 4eb217c9704efa..0b9b534cd68f37 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -7,7 +7,15 @@ #import "AppDelegate.h" +#if __has_include() +#define RCT_USE_HERMES 1 +#endif +#if RCT_USE_HERMES +#import +#else #import +#endif + #import #import #import @@ -165,7 +173,11 @@ - (void)loadSourceForBridge:(RCTBridge *)bridge #endif __weak __typeof(self) weakSelf = self; +#if RCT_USE_HERMES + return std::make_unique( +#else return std::make_unique( +#endif facebook::react::RCTJSIExecutorRuntimeInstaller([weakSelf, bridge](facebook::jsi::Runtime &runtime) { if (!bridge) { return; diff --git a/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m b/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m index 3c04e32fe1bc7b..36b47a79b7e846 100644 --- a/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m +++ b/packages/rn-tester/RNTesterIntegrationTests/RCTLoggingTests.m @@ -90,7 +90,7 @@ - (void)testLogging XCTAssertEqual(_lastLogLevel, RCTLogLevelError); XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript); - XCTAssertEqualObjects(_lastLogMessage, @"Invariant Violation: Invariant failed"); + XCTAssertTrue([_lastLogMessage containsString:@"Invariant Violation: Invariant failed"]); [_bridge enqueueJSCall:@"LoggingTestModule.logErrorToConsole" args:@[@"Invoking console.error"]]; dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER); @@ -114,7 +114,7 @@ - (void)testLogging XCTAssertEqual(_lastLogLevel, RCTLogLevelError); XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript); - XCTAssertEqualObjects(_lastLogMessage, @"Error: Throwing an error"); + XCTAssertTrue([_lastLogMessage containsString:@"Error: Throwing an error"]); } @end diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj index 0d6f7f8f5ea501..34448696748ce0 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj +++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj @@ -60,6 +60,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + ADA4EF572546F3F8000B7E75 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 13B07F861A680F5B00A75B9A; + remoteInfo = RNTester; + }; E7DB215822B2F332005AC45F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; @@ -399,6 +406,7 @@ 68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */, 5CF0FD27207FC6EC00C13D65 /* Start Metro */, C1C7A9D58CE1D09515F20577 /* [CP] Copy Pods Resources */, + 1FBC81357AE903DE578716B1 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -418,10 +426,12 @@ E7DB209C22B2BA84005AC45F /* Frameworks */, E7DB209D22B2BA84005AC45F /* Resources */, D45F7C4830D42738CAAC9684 /* [CP] Copy Pods Resources */, + 05A8BE11026FB5DBCC2D66D6 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( + ADA4EF582546F3F8000B7E75 /* PBXTargetDependency */, ); name = RNTesterUnitTests; productName = RNTesterUnitTests; @@ -437,6 +447,7 @@ E7DB215022B2F332005AC45F /* Frameworks */, E7DB215122B2F332005AC45F /* Resources */, CD1D70F24AD74F4E13B7435D /* [CP] Copy Pods Resources */, + EE8E566CD59E43F57B8CEA59 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -515,6 +526,40 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 05A8BE11026FB5DBCC2D66D6 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 1FBC81357AE903DE578716B1 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTester/Pods-RNTester-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 56D84768A7BBB2750D674CF3 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -639,6 +684,23 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; + EE8E566CD59E43F57B8CEA59 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; F9CB97B0D9633939D43E75E0 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -723,6 +785,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + ADA4EF582546F3F8000B7E75 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 13B07F861A680F5B00A75B9A /* RNTester */; + targetProxy = ADA4EF572546F3F8000B7E75 /* PBXContainerItemProxy */; + }; E7DB215922B2F332005AC45F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 13B07F861A680F5B00A75B9A /* RNTester */; diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh index fcc60ef7cabd82..9b059a6597d776 100755 --- a/scripts/react-native-xcode.sh +++ b/scripts/react-native-xcode.sh @@ -107,14 +107,26 @@ fi # shellcheck source=/dev/null source "$REACT_NATIVE_DIR/scripts/node-binary.sh" +[ -z "$HERMES_CLI_PATH" ] && HERMES_CLI_PATH="$PODS_ROOT/hermes-engine/destroot/bin/hermesc" + +if [[ -z "$USE_HERMES" && -f "$HERMES_CLI_PATH" ]]; then + echo "Enabling Hermes byte-code compilation. Disable with USE_HERMES=false if needed." + USE_HERMES=true +fi + +if [[ $USE_HERMES == true && ! -f "$HERMES_CLI_PATH" ]]; then + echo "error: USE_HERMES is set to true but the hermesc binary could not be " \ + "found at ${HERMES_CLI_PATH}. Perhaps you need to run pod install or otherwise " \ + "point the HERMES_CLI_PATH variable to your custom location." >&2 + exit 2 +fi + [ -z "$NODE_ARGS" ] && export NODE_ARGS="" [ -z "$CLI_PATH" ] && export CLI_PATH="$REACT_NATIVE_DIR/cli.js" [ -z "$BUNDLE_COMMAND" ] && BUNDLE_COMMAND="bundle" -[ -z "$HERMES_PATH" ] && HERMES_PATH="$PROJECT_ROOT/node_modules/hermes-engine-darwin/destroot/bin/hermesc" - [ -z "$COMPOSE_SOURCEMAP_PATH" ] && COMPOSE_SOURCEMAP_PATH="$REACT_NATIVE_DIR/scripts/compose-source-maps.js" if [[ -z "$BUNDLE_CONFIG" ]]; then @@ -136,11 +148,6 @@ case "$PLATFORM_NAME" in ;; esac -USE_HERMES= -if [[ "$BUNDLE_PLATFORM" == "macos" && -f "$HERMES_PATH" ]]; then - USE_HERMES=true -fi - EMIT_SOURCEMAP= if [[ ! -z "$SOURCEMAP_FILE" ]]; then EMIT_SOURCEMAP=true @@ -180,14 +187,12 @@ else if [[ $EMIT_SOURCEMAP == true ]]; then EXTRA_COMPILER_ARGS="$EXTRA_COMPILER_ARGS -output-source-map" fi - HBC_FILE="$CONFIGURATION_BUILD_DIR/$(basename $BUNDLE_FILE)" - "$HERMES_PATH" -emit-binary $EXTRA_COMPILER_ARGS -out "$HBC_FILE" "$BUNDLE_FILE" - mv "$HBC_FILE" "$DEST/" - BUNDLE_FILE="$DEST/main.jsbundle" + "$HERMES_CLI_PATH" -emit-binary $EXTRA_COMPILER_ARGS -out "$DEST/main.jsbundle" "$BUNDLE_FILE" if [[ $EMIT_SOURCEMAP == true ]]; then - HBC_SOURCEMAP_FILE="$HBC_FILE.map" + HBC_SOURCEMAP_FILE="$BUNDLE_FILE.map" "$NODE_BINARY" "$COMPOSE_SOURCEMAP_PATH" "$PACKAGER_SOURCEMAP_FILE" "$HBC_SOURCEMAP_FILE" -o "$SOURCEMAP_FILE" fi + BUNDLE_FILE="$DEST/main.jsbundle" fi if [[ $DEV != true && ! -f "$BUNDLE_FILE" ]]; then diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 72182de1a2e6c1..5b97c630af4eb7 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -6,7 +6,6 @@ def use_react_native! (options={}) # The prefix to the react-native prefix = options[:path] ||= "../node_modules/react-native" - hermes_engine_prefix = options[:hermes_path] ||= "../node_modules/hermes-engine-darwin" # Include Fabric dependencies fabric_enabled = options[:fabric_enabled] ||= false @@ -64,7 +63,7 @@ def use_react_native! (options={}) if hermes_enabled pod 'React-Core/Hermes', :path => "#{prefix}/" - pod 'hermes', :path => hermes_engine_prefix + pod 'hermes-engine' pod 'libevent', :podspec => "#{prefix}/third-party-podspecs/libevent.podspec" end end diff --git a/third-party-podspecs/RCT-Folly.podspec b/third-party-podspecs/RCT-Folly.podspec index ae1d4f471b69dd..cacafb825d3fa3 100644 --- a/third-party-podspecs/RCT-Folly.podspec +++ b/third-party-podspecs/RCT-Folly.podspec @@ -67,7 +67,7 @@ Pod::Spec.new do |spec| spec.libraries = "stdc++" spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", - "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\"" } + "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/libevent/include/\"" } # TODO: The boost spec should really be selecting these files so that dependents of Folly can also access the required headers. spec.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\"" } @@ -97,20 +97,21 @@ Pod::Spec.new do |spec| 'folly/futures/detail/*.{h,cpp}', 'folly/executors/*.{h,cpp}', 'folly/executors/thread_factory/{NamedThreadFactory,ThreadFactory}.{h,cpp}', - 'folly/executors/task_queue/{BlockingQueue,LifoSemMPMCQueue,PriorityLifoSemMPMCQueue}.{h,cpp}', + 'folly/executors/task_queue/{BlockingQueue,UnboundedBlockingQueue,LifoSemMPMCQueue,PriorityUnboundedBlockingQueue,PriorityLifoSemMPMCQueue}.{h,cpp}', 'folly/concurrency/*.{h,cpp}', - 'folly/system/{ThreadId,ThreadName}.{h,cpp}', + 'folly/system/{ThreadId,ThreadName,HardwareConcurrency}.{h,cpp}', 'folly/synchronization/*.{h,cpp}', 'folly/synchronization/detail/*.{h,cpp}', - 'folly/experimental/{ExecutionObserver,ReadMostlySharedPtr,TLRefCount}.{h,cpp}', - 'folly/io/async/{AsyncTimeout,DelayedDestruction,DelayedDestructionBase,EventBase,EventBaseManager,EventHandler,EventUtil,HHWheelTimer,NotificationQueue,Request,TimeoutManager,VirtualEventBase}.{h,cpp}', + 'folly/experimental/{ExecutionObserver,ReadMostlySharedPtr,SingleWriterFixedHashMap,TLRefCount}.{h,cpp}', + 'folly/io/async/{AsyncTimeout,DelayedDestruction,DelayedDestructionBase,EventBase,EventBaseManager,EventBaseBackendBase,EventHandler,EventUtil,HHWheelTimer,HHWheelTimer-fwd,NotificationQueue,Request,TimeoutManager,VirtualEventBase}.{h,cpp}', 'folly/io/{Cursor,Cursor-inl,IOBuf,IOBufQueue}.{h,cpp}', 'folly/tracing/StaticTracepoint.{h,cpp}', 'folly/{Executor,ExceptionWrapper,ExceptionWrapper-inl,FileUtil,Singleton,SharedMutex}.{h,cpp}', - 'folly/detail/{AtFork,Futex,Futex-inl,MemoryIdler,StaticSingletonManager,ThreadLocalDetail}.{h,cpp}', + 'folly/detail/{AsyncTrace,AtFork,Futex,Futex-inl,MemoryIdler,SingletonStackTrace,StaticSingletonManager,ThreadLocalDetail}.{h,cpp}', 'folly/lang/SafeAssert.{h,cpp}', 'folly/memory/MallctlHelper.{h,cpp}', - 'folly/portability/SysUio.{h,cpp}' + 'folly/portability/{GFlags,SysUio}.{h,cpp}', + 'folly/chrono/Hardware.{h,cpp}' # TODO: Perhaps some of the wildcards above can be further trimmed down with some of these: # # 'folly/executors/{DrivableExecutor,InlineExecutor,QueuedImmediateExecutor,TimedDrivableExecutor}.{h,cpp}', @@ -122,6 +123,7 @@ Pod::Spec.new do |spec| # 'folly/experimental/{ReadMostlySharedPtr,TLRefCount}.h', end - # Pinning to the same version as React.podspec. - spec.platforms = { :ios => "10.0", :tvos => "10.0" } + # Folly has issues when compiled with iOS 10 set as deployment target + # See https://github.com/facebook/folly/issues/1470 for details + spec.platforms = { :ios => "9.0", :tvos => "9.0" } end diff --git a/third-party-podspecs/libevent.podspec b/third-party-podspecs/libevent.podspec index 000e39e50d7d3a..ca7fb852f398ef 100644 --- a/third-party-podspecs/libevent.podspec +++ b/third-party-podspecs/libevent.podspec @@ -549,27 +549,17 @@ Pod::Spec.new do |spec| spec.homepage = "https://libevent.org" spec.license = { :type => "BSD 3-Clause", :file => "LICENSE" } spec.author = "Niels Provos and Nick Mathewson" - spec.platforms = { :osx => "10.13" } + spec.platforms = { :osx => "10.13", :ios => "10.0" } spec.source = { :git => "https://github.com/libevent/libevent.git", :tag => "release-#{spec.version}-stable" } - spec.default_subspec = "core" spec.prepare_command = "touch evconfig-private.h; echo -e #{Shellwords.escape(CONFIG_WITHOUT_OPENSSL)} > include/event2/event-config.h" - - # This subspec only exists so we can namespace these headers. - spec.subspec "event2-headers" do |ss| - ss.source_files = "include/event2/*.h" - ss.public_header_files = "include/event2/*.h" - ss.header_dir = "event2" - end - - spec.subspec "core" do |ss| - ss.dependency "libevent/event2-headers" - ss.source_files = - "include/*.h", "*-{internal,private}.h", - "buffer.c", "bufferevent.c", "bufferevent_filter.c", "bufferevent_pair.c", "bufferevent_ratelim.c", "bufferevent_sock.c", - "event.c", "evmap.c", "evthread.c", "evutil.c", "evutil_rand.c", "evutil_time.c", - "kqueue.c", "listener.c", "log.c", "poll.c", "select.c", "signal.c", "strlcpy.c", "watch.c", - "evdns.c", "event_tagging.c", "evrpc.c", "http.c" - ss.private_header_files = "*-{internal,private}.h" - ss.public_header_files = "include/*.h" - end + spec.source_files = + "include/*.h", "*-{internal,private}.h", + "buffer.c", "bufferevent.c", "bufferevent_filter.c", "bufferevent_pair.c", "bufferevent_ratelim.c", "bufferevent_sock.c", + "event.c", "evmap.c", "evthread.c", "evutil.c", "evutil_rand.c", "evutil_time.c", + "kqueue.c", "listener.c", "log.c", "poll.c", "select.c", "signal.c", "strlcpy.c", "watch.c", + "evdns.c", "event_tagging.c", "evrpc.c", "http.c" + spec.private_header_files = "*-{internal,private}.h" + spec.public_header_files = "include/*.h" + spec.preserve_paths = "include/event2/*.h" + spec.xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/include/\"" } end