Skip to content

Commit 71bb73e

Browse files
Saadnajmiclaude
andcommitted
ci: fix ReactNativeDependencies resolution and improve job names
Map ReactNativeDependencies version to upstream RN using the same peerDependencies pattern as Hermes. For the main branch (1000.0.0), fall back to the latest stable RN release from NPM. Also improve Build SPM job names for readability in the GitHub UI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1118a7a commit 71bb73e

3 files changed

Lines changed: 63 additions & 7 deletions

File tree

.github/workflows/microsoft-build-spm.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
retention-days: 1
5555

5656
build-hermesc:
57-
name: "Build HermesC"
57+
name: "Build hermesc"
5858
if: ${{ needs.resolve-hermes.outputs.cache-hit != 'true' }}
5959
needs: resolve-hermes
6060
runs-on: macos-15
@@ -92,7 +92,7 @@ jobs:
9292
retention-days: 1
9393

9494
build-hermes-slice:
95-
name: "Hermes (${{ matrix.slice }})"
95+
name: "Hermes ${{ matrix.slice }}"
9696
if: ${{ needs.resolve-hermes.outputs.cache-hit != 'true' }}
9797
needs: [resolve-hermes, build-hermesc]
9898
runs-on: macos-15
@@ -154,7 +154,7 @@ jobs:
154154
retention-days: 1
155155

156156
assemble-hermes:
157-
name: "Assemble Hermes"
157+
name: "Assemble Hermes xcframework"
158158
if: ${{ needs.resolve-hermes.outputs.cache-hit != 'true' }}
159159
needs: [resolve-hermes, build-hermes-slice]
160160
runs-on: macos-15
@@ -210,7 +210,7 @@ jobs:
210210
retention-days: 1
211211

212212
build-spm:
213-
name: "${{ matrix.platform }}"
213+
name: "SPM ${{ matrix.platform }}"
214214
needs: [resolve-hermes, assemble-hermes]
215215
# Run when upstream jobs succeeded or were skipped (cache hit)
216216
if: ${{ always() && !cancelled() && !failure() }}
@@ -249,7 +249,7 @@ jobs:
249249
250250
- name: Setup SPM workspace (using prebuilt Hermes)
251251
working-directory: packages/react-native
252-
run: SKIP_REACT_NATIVE_DEPENDENCIES=1 node scripts/ios-prebuild.js -s -f Debug
252+
run: node scripts/ios-prebuild.js -s -f Debug
253253

254254
- name: Build SPM (${{ matrix.platform }})
255255
working-directory: packages/react-native

packages/react-native/Package.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,15 @@ let reactCore = RNTarget(
366366
)
367367

368368
/// React-Fabric.podspec
369+
// [macOS: conditionally include macOS-specific platform sources for view components
370+
#if os(macOS)
371+
let reactFabricViewPlatformSources = ["components/view/platform/macos"]
372+
let reactFabricViewPlatformExcludes = ["components/view/platform/cxx"]
373+
#else
374+
let reactFabricViewPlatformSources = ["components/view/platform/cxx"]
375+
let reactFabricViewPlatformExcludes = ["components/view/platform/macos"]
376+
#endif
377+
// macOS]
369378
let reactFabric = RNTarget(
370379
name: .reactFabric,
371380
path: "ReactCommon/react/renderer",
@@ -398,9 +407,9 @@ let reactFabric = RNTarget(
398407
"components/unimplementedview",
399408
"components/virtualview",
400409
"components/root/tests",
401-
],
410+
] + reactFabricViewPlatformExcludes, // [macOS]
402411
dependencies: [.reactNativeDependencies, .reactJsiExecutor, .rctTypesafety, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .reactRendererDebug, .reactGraphics, .yoga],
403-
sources: ["animations", "attributedstring", "core", "componentregistry", "componentregistry/native", "components/root", "components/view", "components/view/platform/cxx", "components/scrollview", "components/scrollview/platform/cxx", "components/legacyviewmanagerinterop", "dom", "scheduler", "mounting", "observers/events", "telemetry", "consistency", "leakchecker", "uimanager", "uimanager/consistency"]
412+
sources: ["animations", "attributedstring", "core", "componentregistry", "componentregistry/native", "components/root", "components/view", "components/scrollview", "components/scrollview/platform/cxx", "components/legacyviewmanagerinterop", "dom", "scheduler", "mounting", "observers/events", "telemetry", "consistency", "leakchecker", "uimanager", "uimanager/consistency"] + reactFabricViewPlatformSources // [macOS]
404413
)
405414

406415
/// React-RCTFabric.podspec
@@ -471,9 +480,17 @@ let reactRCTImage = RNTarget(
471480
)
472481

473482
/// React-RCTText.podspec
483+
// [macOS: RCTUISecureTextField.m #includes RCTUITextField.mm, causing duplicate symbols on non-macOS
484+
#if os(macOS)
485+
let reactRCTTextExcludes: [String] = []
486+
#else
487+
let reactRCTTextExcludes = ["TextInput/Singleline/macOS"]
488+
#endif
489+
// macOS]
474490
let reactRCTText = RNTarget(
475491
name: .reactRCTText,
476492
path: "Libraries/Text",
493+
excludedPaths: reactRCTTextExcludes, // [macOS]
477494
dependencies: [.yoga, .reactTurboModuleCore]
478495
)
479496

packages/react-native/scripts/ios-prebuild/reactNativeDependencies.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
/*:: import type {BuildFlavor} from './types'; */
1212

13+
const {findMatchingHermesVersion} = require('./hermes'); // [macOS]
1314
const {computeNightlyTarballURL, createLogger} = require('./utils');
1415
const {execSync} = require('child_process');
1516
const fs = require('fs');
@@ -44,6 +45,27 @@ async function prepareReactNativeDependenciesArtifactsAsync(
4445
// Resolve the version from the environment variable or use the default version
4546
let resolvedVersion = process.env.RN_DEP_VERSION ?? version;
4647

48+
// [macOS] Map macOS version to upstream RN version for artifact lookup.
49+
// For stable branches, peerDependencies maps to the upstream version.
50+
// For the main branch (1000.0.0), fall back to the latest stable RN release.
51+
if (!process.env.RN_DEP_VERSION) {
52+
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
53+
const mappedVersion = findMatchingHermesVersion(packageJsonPath);
54+
if (mappedVersion != null) {
55+
dependencyLog(
56+
`Using mapped upstream version for ReactNativeDependencies lookup: ${mappedVersion}`,
57+
);
58+
resolvedVersion = mappedVersion;
59+
} else if (resolvedVersion === '1000.0.0') {
60+
const latestStable = await getLatestStableVersionFromNPM();
61+
dependencyLog(
62+
`Main branch detected. Using latest stable RN version for ReactNativeDependencies: ${latestStable}`,
63+
);
64+
resolvedVersion = latestStable;
65+
}
66+
}
67+
// macOS]
68+
4769
if (resolvedVersion === 'nightly') {
4870
dependencyLog('Using latest nightly tarball');
4971
const rnVersion = await getNightlyVersionFromNPM();
@@ -117,6 +139,23 @@ async function getNightlyVersionFromNPM() /*: Promise<string> */ {
117139
return latestNightly;
118140
}
119141

142+
// [macOS
143+
async function getLatestStableVersionFromNPM() /*: Promise<string> */ {
144+
const npmResponse /*: Response */ = await fetch(
145+
'https://registry.npmjs.org/react-native/latest',
146+
);
147+
148+
if (!npmResponse.ok) {
149+
throw new Error(
150+
`Couldn't get latest stable version from NPM: ${npmResponse.status} ${npmResponse.statusText}`,
151+
);
152+
}
153+
154+
const json = await npmResponse.json();
155+
return json.version;
156+
}
157+
// macOS]
158+
120159
/*::
121160
type ReactNativeDependenciesEngineSourceType =
122161
| 'download_prebuild_tarball'

0 commit comments

Comments
 (0)