Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ jobs:
flavor: ${{ matrix.flavor }}

prebuild_apple_dependencies:
uses: ./.github/workflows/prebuild-ios.yml
uses: ./.github/workflows/prebuild-ios-dependencies.yml
secrets: inherit

prebuild_react_native_core:
uses: ./.github/workflows/prebuild-ios-core.yml
secrets: inherit
needs: [prebuild_apple_dependencies, build_hermes_macos]

build_hermesc_linux:
runs-on: ubuntu-latest
needs: prepare_hermes_workspace
Expand Down
199 changes: 199 additions & 0 deletions .github/workflows/prebuild-ios-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
name: Prebuild iOS Dependencies

on:
workflow_call: # this directive allow us to call this workflow from other workflows


jobs:
build-rn-slice:
runs-on: macos-14
strategy:
fail-fast: false
matrix:
flavor: ['Debug', 'Release']
slice: [
'ios',
'ios-simulator',
'mac-catalyst',
]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore cache if present
id: restore-ios-slice
uses: actions/cache/restore@v4
with:
path: packages/react-native/third-party/
key: v2-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
- name: Setup node.js
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-node
- name: Setup xcode
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-xcode
with:
xcode-version: '16.2.0'
- name: Yarn Install
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
uses: ./.github/actions/yarn-install
- name: Download Hermes
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: hermes-darwin-bin-${{ matrix.flavor }}
path: /tmp/hermes/hermes-runtime-darwin
- name: Extract Hermes
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
shell: bash
run: |
HERMES_TARBALL_ARTIFACTS_DIR=/tmp/hermes/hermes-runtime-darwin
if [ ! -d $HERMES_TARBALL_ARTIFACTS_DIR ]; then
echo "Hermes tarball artifacts dir not present ($HERMES_TARBALL_ARTIFACTS_DIR)."
exit 0
fi

TARBALL_FILENAME=$(node ./packages/react-native/scripts/hermes/get-tarball-name.js --buildType "${{ matrix.flavor }}")
TARBALL_PATH=$HERMES_TARBALL_ARTIFACTS_DIR/$TARBALL_FILENAME

echo "Looking for $TARBALL_FILENAME in $HERMES_TARBALL_ARTIFACTS_DIR"
echo "$TARBALL_PATH"

if [ ! -f $TARBALL_PATH ]; then
echo "Hermes tarball not present ($TARBALL_PATH). Build Hermes from source."
exit 0
fi

echo "Found Hermes tarball at $TARBALL_PATH"
echo "HERMES_ENGINE_TARBALL_PATH=$TARBALL_PATH" >> $GITHUB_ENV
- name: Download ReactNativeDependencies
uses: actions/download-artifact@v4
with:
name: ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz
path: /tmp/third-party/
- name: Extract ReactNativeDependencies
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
shell: bash
run: |
# Extract ReactNativeDependencies
tar -xzf /tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz -C /tmp/third-party/

# Create destination folder
mkdir -p packages/react-native/third-party/

# Move the XCFramework in the destination directory
mv /tmp/third-party/packages/react-native/third-party/ReactNativeDependencies.xcframework packages/react-native/third-party/ReactNativeDependencies.xcframework

VERSION=$(jq -r '.version' package.json)
echo "$VERSION-${{matrix.flavor}}" > "packages/react-native/third-party/version.txt"
cat "packages/react-native/third-party/version.txt"
# Check destination directory
ls -lR packages/react-native/third-party/
- name: Setup the workspace
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
shell: bash
run: |
cd packages/react-native
node scripts/ios-prebuild.js -s -f "${{ matrix.flavor }}"
- name: Build React Native
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
shell: bash
run: |
# This is going to be replaced by a CLI script
cd packages/react-native
node scripts/ios-prebuild -b -f "${{ matrix.flavor }}" -p "${{ matrix.slice }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4.3.4
with:
name: prebuild-ios-core-slice-${{ matrix.flavor }}-${{ matrix.slice }}
path: |
packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products
- name: Save Cache
uses: actions/cache/save@v4
if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode
with:
key: v2-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
enableCrossOsArchive: true
path: |
packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products

compose-xcframework:
runs-on: macos-14
needs: [build-rn-slice]
strategy:
fail-fast: false
matrix:
flavor: ['Debug', 'Release']
env:
REACT_ORG_CODE_SIGNING_P12_CERT: ${{ secrets.REACT_ORG_CODE_SIGNING_P12_CERT }}
REACT_ORG_CODE_SIGNING_P12_CERT_PWD: ${{ secrets.REACT_ORG_CODE_SIGNING_P12_CERT_PWD }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore cache if present
id: restore-ios-xcframework
uses: actions/cache/restore@v4
with:
path: packages/react-native/.build/output/xcframeworks
key: v2-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
- name: Setup node.js
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-node
- name: Setup xcode
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
uses: ./.github/actions/setup-xcode
with:
xcode-version: '16.2.0'
- name: Yarn Install
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
uses: ./.github/actions/yarn-install
- name: Download slice artifacts
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
pattern: prebuild-ios-core-slice-${{ matrix.flavor }}-*
path: packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products
merge-multiple: true
- name: Setup Keychain
if: ${{ steps.restore-ios-xcframework.outputs.cache-hit != 'true' && env.REACT_ORG_CODE_SIGNING_P12_CERT != '' }}
uses: apple-actions/import-codesign-certs@v3 # https://github.com/marketplace/actions/import-code-signing-certificates
with:
p12-file-base64: ${{ secrets.REACT_ORG_CODE_SIGNING_P12_CERT }}
p12-password: ${{ secrets.REACT_ORG_CODE_SIGNING_P12_CERT_PWD }}
- name: Create XCFramework
if: ${{ steps.restore-ios-xcframework.outputs.cache-hit != 'true' && env.REACT_ORG_CODE_SIGNING_P12_CERT == '' }}
run: |
cd packages/react-native
node scripts/ios-prebuild -c -f "${{ matrix.flavor }}"
- name: Create and Sign XCFramework
if: ${{ steps.restore-ios-xcframework.outputs.cache-hit != 'true' && env.REACT_ORG_CODE_SIGNING_P12_CERT != '' }}
run: |
cd packages/react-native
node scripts/ios-prebuild -c -f "${{ matrix.flavor }}" -i "React Org"
- name: Compress and Rename XCFramework
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
run: |
cd packages/react-native/.build/output/xcframeworks/${{matrix.flavor}}
tar -cz -f ../React${{matrix.flavor}}.xcframework.tar.gz React.xcframework
- name: Compress and Rename dSYM
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
run: |
cd packages/react-native/.build/output/xcframeworks/${{matrix.flavor}}/Symbols
tar -cz -f ../../React${{ matrix.flavor }}.framework.dSYM.tar.gz .
- name: Upload XCFramework Artifact
uses: actions/upload-artifact@v4
with:
name: React${{ matrix.flavor }}.xcframework.tar.gz
path: packages/react-native/.build/output/xcframeworks/React${{matrix.flavor}}.xcframework.tar.gz
- name: Upload dSYM Artifact
uses: actions/upload-artifact@v4
with:
name: React${{ matrix.flavor }}.framework.dSYM.tar.gz
path: packages/react-native/.build/output/xcframeworks/React${{matrix.flavor}}.framework.dSYM.tar.gz
- name: Save cache if present
if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode
uses: actions/cache/save@v4
with:
path: |
packages/react-native/.build/output/xcframeworks/React${{matrix.flavor}}.xcframework.tar.gz
packages/react-native/.build/output/xcframeworks/React${{matrix.flavor}}.framework.dSYM.tar.gz
key: v2-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift') }}-${{ hashFiles('packages/react-native/scripts/ios-prebuild/setup.js') }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Prebuild iOS
name: Prebuild iOS Dependencies

on:
workflow_call: # this directive allow us to call this workflow from other workflows
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,15 @@ jobs:
hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }}
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
flavor: ${{ matrix.flavor }}

prebuild_apple_dependencies:
uses: ./.github/workflows/prebuild-ios.yml
uses: ./.github/workflows/prebuild-ios-dependencies.yml
secrets: inherit

prebuild_react_native_core:
uses: ./.github/workflows/prebuild-ios-core.yml
secrets: inherit
needs: [prebuild_apple_dependencies, build_hermes_macos]

build_hermesc_linux:
runs-on: ubuntu-latest
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,14 @@ jobs:
flavor: ${{ matrix.flavor }}

prebuild_apple_dependencies:
uses: ./.github/workflows/prebuild-ios.yml
uses: ./.github/workflows/prebuild-ios-dependencies.yml
secrets: inherit

prebuild_react_native_core:
uses: ./.github/workflows/prebuild-ios-core.yml
secrets: inherit
needs: [prebuild_apple_dependencies, build_hermes_macos]

test_ios_rntester_ruby_3_2_0:
runs-on: macos-14
needs:
Expand Down
8 changes: 7 additions & 1 deletion packages/react-native/scripts/ios-prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ async function main() {
if (cli.tasks.compose) {
const productsFolder = computeProductsFolder(outputFolder);
const frameworkPaths = computeFrameworkPaths(productsFolder);
buildXCFrameworks(root, buildFolder, frameworkPaths, buildType);
buildXCFrameworks(
root,
buildFolder,
frameworkPaths,
buildType,
cli.identity,
);
}

// Done!
Expand Down
7 changes: 4 additions & 3 deletions packages/react-native/scripts/ios-prebuild/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

/*::
import type {Destination} from './types';
import type {BuildFlavor, Destination} from './types';
*/

const {createLogger} = require('./utils');
Expand Down Expand Up @@ -52,13 +52,14 @@ function computeFrameworkPaths(
function buildSwiftPackage(
rootFolder /*: string */,
buildFolder /*: string */,
buildType /*: 'debug' | 'release' */,
buildType /*: BuildFlavor */,
platform /*: Destination */,
outputFolder /*: string */,
) {
const buildCommand =
`xcodebuild -scheme React -destination "generic/platform=${platform}" -derivedDataPath "${outputFolder}" ` +
`-configuration "${buildType}" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES OTHER_SWIFT_FLAGS="-no-verify-emitted-module-interface"`;
`-configuration "${buildType}" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES OTHER_SWIFT_FLAGS="-no-verify-emitted-module-interface" ` +
`DEBUG_INFORMATION_FORMAT="dwarf-with-dsym"`;
buildLog(`Building Swift package for ${buildType}`);
buildLog(buildCommand);

Expand Down
12 changes: 6 additions & 6 deletions packages/react-native/scripts/ios-prebuild/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const yargs = require('yargs');

/*::
import type {Destination, Platform} from './types';
import type {BuildFlavor, Destination, Platform} from './types';
*/

const platforms /*: $ReadOnlyArray<Platform> */ = [
Expand Down Expand Up @@ -77,7 +77,7 @@ async function getCLIConfiguration() /*: Promise<?{|
build: boolean,
compose: boolean,
|},
flavor: 'debug' | 'release',
flavor: BuildFlavor,
destinations: $ReadOnlyArray<Destination>,
identity: ?string,
|}> */ {
Expand All @@ -103,10 +103,10 @@ async function getCLIConfiguration() /*: Promise<?{|
.map(p => platformToDestination[p]);

// Validate flavor
const resolvedFlavor = argv.flavor.toLowerCase();
if (resolvedFlavor !== 'debug' && resolvedFlavor !== 'release') {
const flavor = argv.flavor;
if (flavor !== 'Debug' && flavor !== 'Release') {
console.error(
`Invalid flavor specified: ${resolvedFlavor}\nValid flavors are: debug, release`,
`Invalid flavor specified: ${flavor}\nValid flavors are: Debug, Release`,
);
return undefined;
}
Expand All @@ -121,7 +121,7 @@ async function getCLIConfiguration() /*: Promise<?{|
build: runAllCommands || argv.build != null,
compose: runAllCommands || argv.compose != null,
},
flavor: resolvedFlavor,
flavor: flavor,
destinations: resolvedPlatforms,
identity: argv.identity,
};
Expand Down
Loading