Skip to content

Commit 378e7cc

Browse files
committed
Merge upstream main and resolve iOS prebuild cache conflicts
2 parents 71581e8 + 897cca8 commit 378e7cc

480 files changed

Lines changed: 16935 additions & 2663 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.flowconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module.name_mapper='^react-native/src/fb_internal/\(.*\)$' -> '<PROJECT_ROOT>/pa
6868
# `src/fb_internal/*` stay importable.
6969
module.name_mapper='^react-native/\(Libraries\|src/private\|src/types\)/.*$' -> 'react-native-deep-import-is-not-part-of-the-public-api'
7070
module.name_mapper='^@react-native/dev-middleware$' -> '<PROJECT_ROOT>/packages/dev-middleware'
71-
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\|xml\|ktx\|heic\|heif\)$' -> '<PROJECT_ROOT>/packages/react-native/Libraries/Image/RelativeImageStub'
71+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\|xml\|ktx\|heic\|ttf\|heif\)$' -> '<PROJECT_ROOT>/packages/react-native/Libraries/Image/RelativeImageStub'
7272

7373
module.system.haste.module_ref_prefix=m#
7474

‎.github/actions/run-fantom-tests/action.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ runs:
2727
run: |
2828
for attempt in 1 2 3; do
2929
echo "Attempt $attempt of 3"
30-
if yarn fantom; then
30+
if yarn fantom --ci; then
3131
exit 0
3232
fi
3333
if [ "$attempt" -lt 3 ]; then
@@ -38,6 +38,14 @@ runs:
3838
exit 1
3939
env:
4040
LD_LIBRARY_PATH: ${{ github.workspace }}/private/react-native-fantom/build/tester
41+
- name: Upload failed screenshot comparisons
42+
if: ${{ always() }}
43+
uses: ./.github/actions/upload-artifact
44+
with:
45+
name: fantom-screenshot-failures
46+
compression-level: 1
47+
if-no-files-found: ignore
48+
path: private/react-native-fantom/build/screenshot-failures
4149
- name: Upload test results
4250
if: ${{ always() }}
4351
uses: ./.github/actions/upload-artifact
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
#
4+
# This source code is licensed under the MIT license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# Checks that `npx react-native spm deinit` left an iOS app with only its
8+
# CocoaPods files. It checks only what deinit removes; `pod install` restores
9+
# the CocoaPods references, so they are not checked here.
10+
#
11+
# It assumes the app had no Swift packages before `spm add`: any
12+
# packageReferences or packageProductDependencies left after deinit fail the
13+
# check. Do not use it on an app that already has Swift packages.
14+
#
15+
# Usage:
16+
# assert-spm-deinit.sh record <ios-dir>
17+
# Run before `spm add`. Prints PODFILE_SHA256 and GITIGNORE_SHA256, and
18+
# appends them to $GITHUB_ENV when it is set.
19+
# assert-spm-deinit.sh check <ios-dir> <name.xcodeproj> <podfile-sha256> <gitignore-sha256|absent>
20+
# Run after `spm deinit`, with the values that record printed.
21+
22+
usage() {
23+
echo "Usage: $0 record <ios-dir>"
24+
echo " $0 check <ios-dir> <name.xcodeproj> <podfile-sha256> <gitignore-sha256|absent>"
25+
exit 2
26+
}
27+
28+
sha256_or_absent() {
29+
if [ -f "$1" ]; then
30+
shasum -a 256 "$1" | cut -d ' ' -f 1
31+
else
32+
echo absent
33+
fi
34+
}
35+
36+
record() {
37+
local ios_dir=$1
38+
if [ ! -f "$ios_dir/Podfile" ]; then
39+
echo "::error::$ios_dir/Podfile is missing. Record the checksums while the app is still on CocoaPods."
40+
exit 1
41+
fi
42+
43+
local values
44+
values="PODFILE_SHA256=$(sha256_or_absent "$ios_dir/Podfile")
45+
GITIGNORE_SHA256=$(sha256_or_absent "$ios_dir/.gitignore")"
46+
echo "$values"
47+
if [ -n "$GITHUB_ENV" ]; then
48+
echo "$values" >> "$GITHUB_ENV"
49+
fi
50+
}
51+
52+
check() {
53+
local ios_dir=$1
54+
local xcodeproj="$ios_dir/$2"
55+
local expected_podfile_sha256=$3
56+
local expected_gitignore_sha256=$4
57+
local pbxproj="$xcodeproj/project.pbxproj"
58+
local failed=0
59+
60+
fail() {
61+
echo "::error::$1"
62+
failed=1
63+
}
64+
65+
local actual_podfile_sha256
66+
actual_podfile_sha256=$(sha256_or_absent "$ios_dir/Podfile")
67+
if [ "$actual_podfile_sha256" != "$expected_podfile_sha256" ]; then
68+
fail "Podfile changed: sha256 is '$actual_podfile_sha256', expected '$expected_podfile_sha256'."
69+
fi
70+
71+
local actual_gitignore_sha256
72+
actual_gitignore_sha256=$(sha256_or_absent "$ios_dir/.gitignore")
73+
if [ "$actual_gitignore_sha256" != "$expected_gitignore_sha256" ]; then
74+
fail ".gitignore changed: sha256 is '$actual_gitignore_sha256', expected '$expected_gitignore_sha256'."
75+
fi
76+
77+
if [ -e "$xcodeproj/.spm-injected.json" ]; then
78+
fail "$xcodeproj/.spm-injected.json is still there."
79+
fi
80+
81+
if [ -e "$ios_dir/ReactNativeSPM" ]; then
82+
fail "$ios_dir/ReactNativeSPM is still there."
83+
fi
84+
85+
if [ ! -f "$pbxproj" ]; then
86+
fail "$pbxproj is missing."
87+
else
88+
local injected
89+
for injected in \
90+
XCLocalSwiftPackageReference \
91+
XCSwiftPackageProductDependency \
92+
packageReferences \
93+
packageProductDependencies \
94+
ReactNativeSPM \
95+
"Sync SPM Autolinking" \
96+
"Embed React Native Flavored Frameworks"; do
97+
if grep -qF "$injected" "$pbxproj"; then
98+
fail "$pbxproj still contains '$injected'."
99+
fi
100+
done
101+
fi
102+
103+
local scheme
104+
for scheme in "$xcodeproj"/xcshareddata/xcschemes/*.xcscheme; do
105+
if [ -f "$scheme" ] && grep -qF 'title = "Sync SPM Autolinking"' "$scheme"; then
106+
fail "$scheme still has the Sync SPM Autolinking pre-action."
107+
fi
108+
done
109+
110+
if [ $failed -ne 0 ]; then
111+
exit 1
112+
fi
113+
echo "spm deinit removed every SwiftPM change."
114+
}
115+
116+
case "$1" in
117+
record)
118+
[ $# -eq 2 ] || usage
119+
record "$2"
120+
;;
121+
check)
122+
[ $# -eq 5 ] || usage
123+
check "$2" "$3" "$4" "$5"
124+
;;
125+
*)
126+
usage
127+
;;
128+
esac

‎.github/workflows/prebuild-ios-core.yml‎

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,27 @@ jobs:
2525
steps:
2626
- name: Checkout
2727
uses: actions/checkout@v6
28+
- name: Set Hermes version
29+
shell: bash
30+
env:
31+
USE_HERMES_PREBUILT: ${{ inputs.use-hermes-prebuilt }}
32+
run: |
33+
if [ "$USE_HERMES_PREBUILT" == "true" ]; then
34+
HERMES_VERSION=$(curl --fail --silent --show-error --retry 3 https://registry.npmjs.org/hermes-compiler/latest-v1 | jq -er '.version')
35+
else
36+
HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties)
37+
fi
38+
test -n "$HERMES_VERSION"
39+
echo "HERMES_VERSION=$HERMES_VERSION" >> "$GITHUB_ENV"
2840
- name: Restore cache if present
2941
id: restore-ios-slice
42+
if: inputs.version-type == ''
3043
uses: actions/cache/restore@v5
3144
with:
32-
key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }}
33-
path: packages/react-native/
45+
key: v4-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('.github/workflows/prebuild-ios-*.yml', '.github/actions/setup-*/action.yml', '.github/actions/yarn-install/action.yml', 'package.json', 'yarn.lock', 'babel.config.js', 'scripts/build/**/*', 'scripts/releases/ios-prebuild/**/*', 'scripts/releases/prepare-ios-prebuilds.js', 'packages/react-native/package.json', 'packages/react-native/Package.swift', 'packages/react-native/scripts/**/*', 'packages/react-native-codegen/**/*', 'packages/react-native/React/**/*', 'packages/react-native/ReactApple/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*', 'packages/react-native/src/private/specs*/**/*', 'packages/react-native/src/**/Native*.js', 'packages/react-native/src/**/*NativeComponent.js', 'packages/react-native/third-party-podspecs/**/PrivacyInfo.xcprivacy', 'packages/react-native/sdks/hermes-engine/version.properties', '!packages/react-native/Libraries/**/*.js', '!packages/react-native/Libraries/**/*.js.flow', '!packages/react-native/Libraries/**/*.ts', '!packages/react-native/Libraries/**/*.tsx') }}-${{ env.HERMES_VERSION }}
46+
path: |
47+
packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products
48+
packages/react-native/.build/headers
3449
- name: Setup node.js
3550
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
3651
uses: ./.github/actions/setup-node
@@ -40,19 +55,6 @@ jobs:
4055
- name: Yarn Install
4156
if: steps.restore-ios-slice.outputs.cache-hit != 'true'
4257
uses: ./.github/actions/yarn-install
43-
- name: Set Hermes version
44-
shell: bash
45-
run: |
46-
# Non-stable RN builds resolve Hermes from npm's latest-v1 dist-tag.
47-
# TODO: rename 'latest-v1' to 'latest' once V1 is the only Hermes on npm.
48-
# Stable builds use the version pinned in version.properties.
49-
if [ "${{ inputs.use-hermes-prebuilt }}" == "true" ]; then
50-
HERMES_VERSION="latest-v1"
51-
else
52-
HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties)
53-
fi
54-
echo "Using Hermes version: $HERMES_VERSION"
55-
echo "HERMES_VERSION=$HERMES_VERSION" >> $GITHUB_ENV
5658
- name: Set React Native version
5759
shell: bash
5860
run: |
@@ -111,9 +113,9 @@ jobs:
111113
path: ${{ runner.temp }}/prebuild-ios-core-slice-${{ matrix.flavor }}-${{ matrix.slice }}.tar.gz
112114
- name: Save Cache
113115
uses: actions/cache/save@v5
114-
if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode
116+
if: ${{ github.ref == 'refs/heads/main' && inputs.version-type == '' && steps.restore-ios-slice.outputs.cache-hit != 'true' }}
115117
with:
116-
key: v3-ios-core-${{ matrix.slice }}-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }}
118+
key: ${{ steps.restore-ios-slice.outputs.cache-primary-key }}
117119
path: |
118120
packages/react-native/.build/output/spm/${{ matrix.flavor }}/Build/Products
119121
packages/react-native/.build/headers
@@ -131,12 +133,28 @@ jobs:
131133
steps:
132134
- name: Checkout
133135
uses: actions/checkout@v6
136+
- name: Set Hermes version
137+
shell: bash
138+
env:
139+
USE_HERMES_PREBUILT: ${{ inputs.use-hermes-prebuilt }}
140+
run: |
141+
if [ "$USE_HERMES_PREBUILT" == "true" ]; then
142+
HERMES_VERSION=$(curl --fail --silent --show-error --retry 3 https://registry.npmjs.org/hermes-compiler/latest-v1 | jq -er '.version')
143+
else
144+
HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties)
145+
fi
146+
test -n "$HERMES_VERSION"
147+
echo "HERMES_VERSION=$HERMES_VERSION" >> "$GITHUB_ENV"
134148
- name: Restore cache if present
135149
id: restore-ios-xcframework
150+
if: inputs.version-type == ''
136151
uses: actions/cache/restore@v5
137152
with:
138-
path: packages/react-native/.build/output/xcframeworks
139-
key: v5-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }}
153+
path: |
154+
packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.xcframework.tar.gz
155+
packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.framework.dSYM.tar.gz
156+
packages/react-native/.build/output/xcframeworks/ReactNativeHeaders${{matrix.flavor}}.xcframework.tar.gz
157+
key: v5-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('.github/workflows/prebuild-ios-*.yml', '.github/actions/setup-*/action.yml', '.github/actions/yarn-install/action.yml', 'package.json', 'yarn.lock', 'babel.config.js', 'scripts/build/**/*', 'scripts/releases/ios-prebuild/**/*', 'scripts/releases/prepare-ios-prebuilds.js', 'packages/react-native/package.json', 'packages/react-native/Package.swift', 'packages/react-native/scripts/**/*', 'packages/react-native-codegen/**/*', 'packages/react-native/React/**/*', 'packages/react-native/ReactApple/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*', 'packages/react-native/src/private/specs*/**/*', 'packages/react-native/src/**/Native*.js', 'packages/react-native/src/**/*NativeComponent.js', 'packages/react-native/third-party-podspecs/**/PrivacyInfo.xcprivacy', 'packages/react-native/sdks/hermes-engine/version.properties', '!packages/react-native/Libraries/**/*.js', '!packages/react-native/Libraries/**/*.js.flow', '!packages/react-native/Libraries/**/*.ts', '!packages/react-native/Libraries/**/*.tsx') }}-${{ env.HERMES_VERSION }}
140158
- name: Setup node.js
141159
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
142160
uses: ./.github/actions/setup-node
@@ -185,20 +203,6 @@ jobs:
185203
tar -xzf /tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz -C /tmp/third-party/
186204
mkdir -p packages/react-native/third-party/
187205
mv /tmp/third-party/packages/react-native/third-party/ReactNativeDependencies.xcframework packages/react-native/third-party/ReactNativeDependencies.xcframework
188-
- name: Set Hermes version
189-
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
190-
shell: bash
191-
run: |
192-
# Non-stable RN builds resolve Hermes from npm's latest-v1 dist-tag.
193-
# TODO: rename 'latest-v1' to 'latest' once V1 is the only Hermes on npm.
194-
# Stable builds use the version pinned in version.properties.
195-
if [ "${{ inputs.use-hermes-prebuilt }}" == "true" ]; then
196-
HERMES_VERSION="latest-v1"
197-
else
198-
HERMES_VERSION=$(sed -n 's/^HERMES_VERSION_NAME=//p' packages/react-native/sdks/hermes-engine/version.properties)
199-
fi
200-
echo "Using Hermes version: $HERMES_VERSION"
201-
echo "HERMES_VERSION=$HERMES_VERSION" >> $GITHUB_ENV
202206
- name: Stage Hermes headers
203207
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
204208
working-directory: packages/react-native
@@ -232,16 +236,6 @@ jobs:
232236
# regressions here instead of in downstream builds.
233237
cd packages/react-native
234238
node scripts/ios-prebuild/headers-verify.js --flavor "${{ matrix.flavor }}" ${{ inputs.version-type != '' && '--require-stamped-version' || '' }}
235-
- name: Verify Mac Catalyst framework symlinks
236-
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
237-
run: |
238-
framework="packages/react-native/.build/output/xcframeworks/${{ matrix.flavor }}/React.xcframework/ios-arm64_x86_64-maccatalyst/React.framework"
239-
for link in React Resources Versions/Current; do
240-
if [ ! -L "$framework/$link" ]; then
241-
echo "::error::Expected framework symlink: $framework/$link. Archive build slices before uploading them."
242-
exit 1
243-
fi
244-
done
245239
- name: Compress and Rename XCFramework
246240
if: steps.restore-ios-xcframework.outputs.cache-hit != 'true'
247241
run: |
@@ -280,11 +274,11 @@ jobs:
280274
name: ReactNativeHeaders${{ matrix.flavor }}.xcframework.tar.gz
281275
path: packages/react-native/.build/output/xcframeworks/ReactNativeHeaders${{matrix.flavor}}.xcframework.tar.gz
282276
- name: Save cache if present
283-
if: ${{ github.ref == 'refs/heads/main' }} # To avoid that the cache explode
277+
if: ${{ github.ref == 'refs/heads/main' && inputs.version-type == '' && steps.restore-ios-xcframework.outputs.cache-hit != 'true' }}
284278
uses: actions/cache/save@v5
285279
with:
286280
path: |
287281
packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.xcframework.tar.gz
288282
packages/react-native/.build/output/xcframeworks/ReactCore${{matrix.flavor}}.framework.dSYM.tar.gz
289283
packages/react-native/.build/output/xcframeworks/ReactNativeHeaders${{matrix.flavor}}.xcframework.tar.gz
290-
key: v5-ios-core-xcframework-${{ matrix.flavor }}-${{ hashFiles('packages/react-native/Package.swift', 'packages/react-native/scripts/ios-prebuild/*.js', 'packages/react-native/scripts/ios-prebuild.js', 'packages/react-native/React/**/*', 'packages/react-native/ReactCommon/**/*', 'packages/react-native/Libraries/**/*') }}
284+
key: ${{ steps.restore-ios-xcframework.outputs.cache-primary-key }}

0 commit comments

Comments
 (0)