diff --git a/.github/actions/test-ios-helloworld/action.yml b/.github/actions/test-ios-helloworld/action.yml index 687a9d24970..092c741898c 100644 --- a/.github/actions/test-ios-helloworld/action.yml +++ b/.github/actions/test-ios-helloworld/action.yml @@ -46,6 +46,14 @@ runs: uses: ruby/setup-ruby@v1.170.0 with: ruby-version: ${{ inputs.ruby-version }} + - name: Download ReactNativeDependencies + uses: actions/download-artifact@v4 + with: + name: ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz + path: /tmp/third-party + - name: Print third-party folder + shell: bash + run: ls -lR /tmp/third-party - name: Install iOS dependencies - Configuration ${{ inputs.flavor }}; New Architecture ${{ inputs.architecture }}; JS Engine ${{ inputs.jsengine }} shell: bash run: | @@ -77,8 +85,10 @@ runs: BUILD_TYPE="${{ inputs.flavor }}" TARBALL_FILENAME=$(node ../react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE") - HERMES_PATH="$HERMES_WS_DIR/hermes-runtime-darwin/$TARBALL_FILENAME" - HERMES_ENGINE_TARBALL_PATH="$HERMES_PATH" yarn bootstrap ios "${args[@]}" | cat + export HERMES_ENGINE_TARBALL_PATH="$HERMES_WS_DIR/hermes-runtime-darwin/$TARBALL_FILENAME" + export RCT_USE_LOCAL_RN_DEP="/tmp/third-party/ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz" + + yarn bootstrap ios "${args[@]}" | cat fi - name: Build HelloWorld project shell: bash diff --git a/.github/actions/test-ios-rntester/action.yml b/.github/actions/test-ios-rntester/action.yml index 010cf4219b9..80123a9275d 100644 --- a/.github/actions/test-ios-rntester/action.yml +++ b/.github/actions/test-ios-rntester/action.yml @@ -92,6 +92,14 @@ runs: else echo 'No Hermes tarball found.' fi + - name: Download ReactNativeDependencies + uses: actions/download-artifact@v4 + with: + name: ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz + path: /tmp/third-party/ + - name: Print third-party folder + shell: bash + run: ls -lR /tmp/third-party - name: Setup xcode build cache uses: ./.github/actions/setup-xcode-build-cache with: @@ -118,6 +126,7 @@ runs: export RCT_NEW_ARCH_ENABLED=0 fi + export RCT_USE_LOCAL_RN_DEP="/tmp/third-party/ReactNativeDependencies${{ inputs.flavor }}.xcframework.tar.gz" cd packages/rn-tester bundle install diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml index 470ea622b4e..0eb5bc98566 100644 --- a/.github/workflows/test-all.yml +++ b/.github/workflows/test-all.yml @@ -123,7 +123,7 @@ jobs: test_ios_rntester_ruby_3_2_0: runs-on: macos-13 needs: - [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos] + [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies] env: HERMES_WS_DIR: /tmp/hermes HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin @@ -140,7 +140,7 @@ jobs: test_ios_rntester_dynamic_frameworks: runs-on: macos-13 needs: - [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos] + [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies] env: HERMES_WS_DIR: /tmp/hermes HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin @@ -163,7 +163,7 @@ jobs: test_ios_rntester: runs-on: macos-13-large needs: - [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos] + [build_apple_slices_hermes, prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies] env: HERMES_WS_DIR: /tmp/hermes HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin @@ -232,7 +232,7 @@ jobs: test_e2e_ios_templateapp: if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }} runs-on: macos-13-large - needs: build_npm_package + needs: [build_npm_package, prebuild_apple_dependencies] env: HERMES_WS_DIR: /tmp/hermes HERMES_TARBALL_ARTIFACTS_DIR: /tmp/hermes/hermes-runtime-darwin @@ -268,6 +268,14 @@ jobs: path: /tmp/react-native-tmp - name: Print /tmp folder run: ls -lR /tmp/react-native-tmp + - name: Download ReactNativeDependencies + uses: actions/download-artifact@v4 + with: + name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz + path: /tmp/third-party + - name: Print third-party folder + shell: bash + run: ls -lR /tmp/third-party - name: Prepare artifacts run: | REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz") @@ -292,6 +300,8 @@ jobs: echo "Disable the New Architecture" NEW_ARCH_ENABLED=0 fi + + export RCT_USE_LOCAL_RN_DEP=/tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz HERMES_ENGINE_TARBALL_PATH=$HERMES_PATH RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install xcodebuild \ @@ -580,7 +590,7 @@ jobs: test_ios_helloworld_with_ruby_3_2_0: runs-on: macos-13 - needs: [prepare_hermes_workspace, build_hermes_macos] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs + needs: [prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs env: PROJECT_NAME: iOSTemplateProject HERMES_WS_DIR: /tmp/hermes @@ -598,7 +608,7 @@ jobs: test_ios_helloworld: runs-on: macos-13 - needs: [prepare_hermes_workspace, build_hermes_macos] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs + needs: [prepare_hermes_workspace, build_hermes_macos, prebuild_apple_dependencies] # prepare_hermes_workspace must be there because we need its reference to retrieve a couple of outputs strategy: matrix: flavor: [Debug, Release] diff --git a/packages/react-native/scripts/cocoapods/rndependencies.rb b/packages/react-native/scripts/cocoapods/rndependencies.rb index e95af1040b7..e020c15a7ed 100644 --- a/packages/react-native/scripts/cocoapods/rndependencies.rb +++ b/packages/react-native/scripts/cocoapods/rndependencies.rb @@ -86,6 +86,12 @@ class ReactNativeDependenciesUtils artifacts_exists = ENV["RCT_USE_RN_DEP"] == "1" && release_artifact_exists(@@react_native_version) use_local_xcframework = ENV["RCT_USE_LOCAL_RN_DEP"] && File.exist?(ENV["RCT_USE_LOCAL_RN_DEP"]) + if ENV["RCT_USE_LOCAL_RN_DEP"] + if !File.exist?(ENV["RCT_USE_LOCAL_RN_DEP"]) + abort("RCT_USE_LOCAL_RN_DEP is set to #{ENV["RCT_USE_LOCAL_RN_DEP"]} but the file does not exist!") + end + end + @@build_from_source = !use_local_xcframework && !artifacts_exists rndeps_log("Building from source: #{@@build_from_source}") diff --git a/packages/react-native/third-party-podspecs/ReactNativeDependencies.podspec b/packages/react-native/third-party-podspecs/ReactNativeDependencies.podspec index 2eb07ec077f..1d1268b9fc4 100644 --- a/packages/react-native/third-party-podspecs/ReactNativeDependencies.podspec +++ b/packages/react-native/third-party-podspecs/ReactNativeDependencies.podspec @@ -52,27 +52,31 @@ Pod::Spec.new do |spec| find "$CURRENT_PATH" -type d -empty -delete CMD - script_phase = { - :name => "[RNDeps] Replace React Native Dependencies for the right configuration, if needed", - :execution_position => :before_compile, - :script => <<-EOS - . "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh" + # If we are passing a local tarball, we don't want to switch between Debug and Release + if !ENV["RCT_USE_LOCAL_RN_DEP"] + script_phase = { + :name => "[RNDeps] Replace React Native Dependencies for the right configuration, if needed", + :execution_position => :before_compile, + :script => <<-EOS + . "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh" - CONFIG="Release" - if echo $GCC_PREPROCESSOR_DEFINITIONS | grep -q "DEBUG=1"; then - CONFIG="Debug" - fi + CONFIG="Release" + if echo $GCC_PREPROCESSOR_DEFINITIONS | grep -q "DEBUG=1"; then + CONFIG="Debug" + fi - "$NODE_BINARY" "$REACT_NATIVE_PATH/third-party-podspecs/replace_dependencies_version.js" -c "$CONFIG" -r "#{version}" -p "$PODS_ROOT" - EOS - } + "$NODE_BINARY" "$REACT_NATIVE_PATH/third-party-podspecs/replace_dependencies_version.js" -c "$CONFIG" -r "#{version}" -p "$PODS_ROOT" + EOS + } - # :always_out_of_date is only available in CocoaPods 1.13.0 and later - if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.13.0') - # always run the script without warning - script_phase[:always_out_of_date] = "1" + + # :always_out_of_date is only available in CocoaPods 1.13.0 and later + if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.13.0') + # always run the script without warning + script_phase[:always_out_of_date] = "1" + end + + spec.script_phase = script_phase end - spec.script_phase = script_phase - end