From 4fe8727d92841e9b160c048d66d66ef13b6d5242 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Fri, 10 Apr 2026 21:10:21 -0700 Subject: [PATCH 1/4] fix: fix "Invalid platform macos" in init integration test Three fixes for the CI "Test react-native-macos init" job: 1. Simplify apple platform resolution in react-native.config.js to use the same pattern as ios/android (resolve from cwd directly). 2. Use glob patterns in package.json files array ("scripts/cocoapods/**" instead of "scripts/cocoapods") so yarn pack includes directory contents. See facebook/react-native#56407. 3. Replace `npm install ` (creates symlinks) with `yarn pack` + `npm install ` + `chmod +x`. The symlink approach caused module instance duplication (setFrameworkDefaults targeting wrong @react-native/metro-config instance) and missing pre-generated codegen headers. The tarball approach matches what users get from npm. Co-Authored-By: Claude Opus 4.6 --- ...microsoft-test-react-native-macos-init.yml | 24 +++++++++++++++++-- packages/react-native/package.json | 6 ++--- packages/react-native/react-native.config.js | 4 ---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/microsoft-test-react-native-macos-init.yml b/.github/workflows/microsoft-test-react-native-macos-init.yml index d16c97c42ffc..bce3133ff0af 100644 --- a/.github/workflows/microsoft-test-react-native-macos-init.yml +++ b/.github/workflows/microsoft-test-react-native-macos-init.yml @@ -26,7 +26,12 @@ jobs: run: yarn install - name: Build community CLI plugin - run: yarn build + run: | + yarn build + # yarn build rewrites package.json "exports" from ./src to ./dist + # for publishing. Restore the original exports so that any + # monorepo tooling that still runs from source continues to work. + git checkout -- packages/*/package.json - name: Build react-native-macos-init working-directory: packages/react-native-macos-init @@ -47,11 +52,26 @@ jobs: npx --yes @react-native-community/cli init testcli --version ${{ steps.rn-version.outputs.version }} working-directory: ${{ runner.temp }} + - name: Pack local react-native-macos + working-directory: packages/react-native + run: | + set -eox pipefail + # Pack the local package into a tarball. This runs the "prepack" + # script which generates the FBReactNativeSpec codegen headers + # (React/FBReactNativeSpec/) that are shipped in published releases. + yarn pack -o ${{ runner.temp }}/react-native-macos.tgz + - name: Install local react-native-macos working-directory: ${{ runner.temp }}/testcli run: | set -eox pipefail - npm install ${{ github.workspace }}/packages/react-native + # Install from the tarball so the test project matches a normal + # user's node_modules layout: no symlinks (which cause module + # instance duplication) and pre-generated codegen headers present + # (which the build relies on to skip regeneration). + npm install ${{ runner.temp }}/react-native-macos.tgz + # yarn pack strips execute permissions from shell scripts + chmod +x node_modules/react-native-macos/scripts/*.sh node_modules/react-native-macos/scripts/xcode/*.sh - name: Apply macOS template working-directory: ${{ runner.temp }}/testcli diff --git a/packages/react-native/package.json b/packages/react-native/package.json index d3e0ca84270e..874cc2cb47f8 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -109,8 +109,8 @@ "README.md", "rn-get-polyfills.js", "scripts/bundle.js", - "scripts/cocoapods", - "scripts/codegen", + "scripts/cocoapods/**", + "scripts/codegen/**", "scripts/compose-source-maps.js", "scripts/find-node-for-xcode.sh", "scripts/generate-codegen-artifacts.js", @@ -133,7 +133,7 @@ "scripts/xcode/ccache.conf", "scripts/xcode/with-environment.sh", "sdks/.hermesversion", - "sdks/hermes-engine", + "sdks/hermes-engine/**", "sdks/hermesc", "settings.gradle.kts", "src", diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js index 4fc760e979c0..6700ec369f4a 100644 --- a/packages/react-native/react-native.config.js +++ b/packages/react-native/react-native.config.js @@ -71,13 +71,9 @@ try { // [macOS let apple; try { - const iosPath = require.resolve('@react-native-community/cli-platform-ios', { - paths: [process.cwd()], - }); // $FlowFixMe[untyped-import] apple = findCommunityPlatformPackage( '@react-native-community/cli-platform-apple', - iosPath, ); } catch { if (verbose) { From a21429c5a80ba416695c1b01c23f2120deb327cb Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Fri, 10 Apr 2026 21:31:14 -0700 Subject: [PATCH 2/4] fix: chmod +x all .sh files recursively under scripts/ The previous glob only matched scripts/*.sh and scripts/xcode/*.sh but missed scripts/react_native_pods_utils/script_phases.sh. Use find to recursively chmod all .sh files. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/microsoft-test-react-native-macos-init.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/microsoft-test-react-native-macos-init.yml b/.github/workflows/microsoft-test-react-native-macos-init.yml index bce3133ff0af..f2f9749f3005 100644 --- a/.github/workflows/microsoft-test-react-native-macos-init.yml +++ b/.github/workflows/microsoft-test-react-native-macos-init.yml @@ -71,7 +71,7 @@ jobs: # (which the build relies on to skip regeneration). npm install ${{ runner.temp }}/react-native-macos.tgz # yarn pack strips execute permissions from shell scripts - chmod +x node_modules/react-native-macos/scripts/*.sh node_modules/react-native-macos/scripts/xcode/*.sh + find node_modules/react-native-macos/scripts -name '*.sh' -exec chmod +x {} + - name: Apply macOS template working-directory: ${{ runner.temp }}/testcli From 135a8dd86264565958ce68d4579d2d5fac2019f3 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Fri, 10 Apr 2026 21:53:09 -0700 Subject: [PATCH 3/4] fix: simplify workflow comments Co-Authored-By: Claude Opus 4.6 --- .../microsoft-test-react-native-macos-init.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/microsoft-test-react-native-macos-init.yml b/.github/workflows/microsoft-test-react-native-macos-init.yml index f2f9749f3005..4e81027a205a 100644 --- a/.github/workflows/microsoft-test-react-native-macos-init.yml +++ b/.github/workflows/microsoft-test-react-native-macos-init.yml @@ -28,9 +28,7 @@ jobs: - name: Build community CLI plugin run: | yarn build - # yarn build rewrites package.json "exports" from ./src to ./dist - # for publishing. Restore the original exports so that any - # monorepo tooling that still runs from source continues to work. + # yarn build rewrites package.json exports; restore them git checkout -- packages/*/package.json - name: Build react-native-macos-init @@ -56,21 +54,15 @@ jobs: working-directory: packages/react-native run: | set -eox pipefail - # Pack the local package into a tarball. This runs the "prepack" - # script which generates the FBReactNativeSpec codegen headers - # (React/FBReactNativeSpec/) that are shipped in published releases. + # Use a tarball instead of a direct path to avoid symlinks yarn pack -o ${{ runner.temp }}/react-native-macos.tgz - name: Install local react-native-macos working-directory: ${{ runner.temp }}/testcli run: | set -eox pipefail - # Install from the tarball so the test project matches a normal - # user's node_modules layout: no symlinks (which cause module - # instance duplication) and pre-generated codegen headers present - # (which the build relies on to skip regeneration). npm install ${{ runner.temp }}/react-native-macos.tgz - # yarn pack strips execute permissions from shell scripts + # yarn pack strips execute bits from shell scripts find node_modules/react-native-macos/scripts -name '*.sh' -exec chmod +x {} + - name: Apply macOS template From b42ed172eecb898a0bf556ea1da97f5cb1114efc Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Fri, 10 Apr 2026 22:37:37 -0700 Subject: [PATCH 4/4] fix: note publishConfig.executableFiles alternative in comment Co-Authored-By: Claude Opus 4.6 --- .github/workflows/microsoft-test-react-native-macos-init.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/microsoft-test-react-native-macos-init.yml b/.github/workflows/microsoft-test-react-native-macos-init.yml index 4e81027a205a..cf5543cb372a 100644 --- a/.github/workflows/microsoft-test-react-native-macos-init.yml +++ b/.github/workflows/microsoft-test-react-native-macos-init.yml @@ -62,7 +62,8 @@ jobs: run: | set -eox pipefail npm install ${{ runner.temp }}/react-native-macos.tgz - # yarn pack strips execute bits from shell scripts + # yarn pack strips execute bits from shell scripts. + # publishConfig.executableFiles could fix this but doesn't support globs. find node_modules/react-native-macos/scripts -name '*.sh' -exec chmod +x {} + - name: Apply macOS template