mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
feat(iOS): ReactNativeDependenciesHeaders sidecar + pure-RN ReactNativeHeaders, published to Maven (#57442)
Summary: Step 2 of the prebuilt-deps roadmap: ship the deps headers as a **SwiftPM-ready, self-contained artifact** and make every header namespace have exactly **one physical home**. 1. **New artifact: `ReactNativeDependenciesHeaders.xcframework`** — the binary `ReactNativeDependencies.xcframework` is framework-type, so its root `Headers/` is invisible to SwiftPM binaryTargets (`HeadersPath` is rejected on framework entries; verified empirically). The deps prebuild now emits a headers-only library-type sidecar (stub archives + per-slice `Headers/` + `HeadersPath` — the exact `ReactNativeHeaders` recipe, factored into a shared `headers-xcframework.js` emitter) carrying all seven deps namespaces incl. SocketRocket, with slice parity derived from the binary artifact's Info.plist. Ships inside the deps tarball *and* standalone. 2. **`ReactNativeHeaders` goes pure-RN** — the R2 relocation of deps namespaces (and the `DEPS_NAMESPACES_NOT_RELOCATED` SocketRocket exclusion list) is deleted. Relocated copies are what enabled the SocketRocket dual-copy regression (duplicate `interface` / poisoned module graph under `use_frameworks!`); that bug class is now structurally impossible. Headers gate flipped: deps namespaces must be **absent** from RNH; the sidecar emitter enforces set-equality with `DEPS_NAMESPACES` fail-closed in both directions. On the CocoaPods side, a new `ReactNativeDependenciesUtils.configure_aggregate_xcconfig` injects the deps pod's `Headers/` globally (aggregate + every pod target), mirroring the rncore injection — this replaces the folly/glog resolution pods previously got via the flattened `React-Core-prebuilt/Headers`. 3. **CI: prebuilt + dynamic-frameworks lane** — the regression's exact config had no coverage (the `test-ios-rntester` action hard-coupled `use-frameworks:true` to source builds). New `use-prebuilds` input; `test_ios_rntester`'s dynamic cells now consume the workflow-built prebuilt artifacts. 4. **Maven publishing** — `ReactNativeHeaders` and `ReactNativeDependenciesHeaders` publish standalone on `react-native-artifacts` (classifiers `reactnative-headers-*`, `reactnative-dependencies-headers-*`); `verifyArtifactsAreOnMaven` now HEAD-checks every classifier tarball instead of only the POM. Stacked on https://github.com/react/react-native/issues/57440. The SwiftPM preview (https://github.com/react/react-native/issues/57332) rebases on top and wires the sidecar as its 5th binaryTarget. ## Changelog: [IOS] [CHANGED] - Prebuilt artifacts: ReactNativeHeaders is pure-RN; third-party deps headers ship in the new ReactNativeDependenciesHeaders.xcframework sidecar (and the ReactNativeDependencies pod), published standalone to Maven Pull Request resolved: https://github.com/react/react-native/pull/57442 Test Plan: - Headers gate: include-health, structural (deps absent from RNH, byte-matched module maps), and compile smokes (React module + 14 namespace modules + Expo-shape ObjC++/Swift fixtures vs the deps include path) — ALL PASSED - jest: 33/33 (`scripts/ios-prebuild/__tests__`, incl. new sidecar set-equality tests) - ESLint (`--max-warnings 0`), Prettier, Flow (`yarn flow-check`): clean - E2E (locally built artifacts): rn-tester prebuilt static ✅, prebuilt `USE_FRAMEWORKS=dynamic` ✅ (the regression config — verified `React-Core-prebuilt/Headers` contains no deps namespaces and the deps pod serves all seven), helloworld static ✅, source-core + prebuilt-deps ✅ (React compiled from source resolves folly via the deps pod), source-mode control with unchanged dependency graph ✅ - Sidecar inspected: per-slice `HeadersPath`, 7 namespaces, slice parity with the binary - Publication validated end-to-end with `publishReleasePublicationToMavenLocal`: all 12 files + POM land with the expected classifier names 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed By: fabriziocucci Differential Revision: D111449462 Pulled By: cipolleschi fbshipit-source-id: e1217d14c0588d00a207622d346c9e6f4705a95d
This commit is contained in:
1 parent
a8156acf8b
commit
6aa147f6c9
25 files changed
+974
-253
No files matched your search
@@ -22,6 +22,28 @@ jest.mock('../utils.js', () => ({
|
||||
process.exit = mockExit;
|
||||
global.fetch = mockFetch;
|
||||
|
||||
const BASE_URL =
|
||||
'https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts';
|
||||
|
||||
// The verifier HEAD-checks the POM plus every classifier tarball attached to
|
||||
// the react-native-artifacts publication (external-artifacts/build.gradle.kts).
|
||||
const expectedUrls = version => [
|
||||
`${BASE_URL}/${version}/react-native-artifacts-${version}.pom`,
|
||||
...[
|
||||
'reactnative-core-debug',
|
||||
'reactnative-core-release',
|
||||
'reactnative-dependencies-debug',
|
||||
'reactnative-dependencies-release',
|
||||
'reactnative-headers-debug',
|
||||
'reactnative-headers-release',
|
||||
'reactnative-dependencies-headers-debug',
|
||||
'reactnative-dependencies-headers-release',
|
||||
].map(
|
||||
classifier =>
|
||||
`${BASE_URL}/${version}/react-native-artifacts-${version}-${classifier}.tar.gz`,
|
||||
),
|
||||
];
|
||||
|
||||
describe('#verifyArtifactsAreOnMaven', () => {
|
||||
beforeEach(jest.clearAllMocks);
|
||||
|
||||
@@ -29,17 +51,18 @@ describe('#verifyArtifactsAreOnMaven', () => {
|
||||
mockSleep.mockReturnValueOnce(Promise.resolve()).mockImplementation(() => {
|
||||
throw new Error('Should not be called again!');
|
||||
});
|
||||
// First attempt: the POM is not there yet. Second attempt: every URL is.
|
||||
mockFetch
|
||||
.mockReturnValueOnce(Promise.resolve({status: 404}))
|
||||
.mockReturnValueOnce(Promise.resolve({status: 200}));
|
||||
.mockReturnValue(Promise.resolve({status: 200}));
|
||||
|
||||
const version = '0.78.1';
|
||||
await verifyArtifactsAreOnMaven(version);
|
||||
|
||||
expect(mockSleep).toHaveBeenCalledTimes(1);
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
'https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.78.1/react-native-artifacts-0.78.1.pom',
|
||||
);
|
||||
for (const url of expectedUrls('0.78.1')) {
|
||||
expect(mockFetch).toHaveBeenCalledWith(url, {method: 'HEAD'});
|
||||
}
|
||||
});
|
||||
|
||||
it('waits for the packages to be published on maven, when version starts with v', async () => {
|
||||
@@ -48,27 +71,46 @@ describe('#verifyArtifactsAreOnMaven', () => {
|
||||
});
|
||||
mockFetch
|
||||
.mockReturnValueOnce(Promise.resolve({status: 404}))
|
||||
.mockReturnValueOnce(Promise.resolve({status: 200}));
|
||||
.mockReturnValue(Promise.resolve({status: 200}));
|
||||
|
||||
const version = 'v0.78.1';
|
||||
await verifyArtifactsAreOnMaven(version);
|
||||
|
||||
expect(mockSleep).toHaveBeenCalledTimes(1);
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
'https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.78.1/react-native-artifacts-0.78.1.pom',
|
||||
);
|
||||
for (const url of expectedUrls('0.78.1')) {
|
||||
expect(mockFetch).toHaveBeenCalledWith(url, {method: 'HEAD'});
|
||||
}
|
||||
});
|
||||
|
||||
it('passes immediately if packages are already on Maven', async () => {
|
||||
mockFetch.mockReturnValueOnce(Promise.resolve({status: 200}));
|
||||
mockFetch.mockReturnValue(Promise.resolve({status: 200}));
|
||||
|
||||
const version = '0.78.1';
|
||||
await verifyArtifactsAreOnMaven(version);
|
||||
|
||||
expect(mockSleep).toHaveBeenCalledTimes(0);
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
'https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.78.1/react-native-artifacts-0.78.1.pom',
|
||||
);
|
||||
// All nine URLs (POM + 8 classifier tarballs) are verified in one pass.
|
||||
expect(mockFetch).toHaveBeenCalledTimes(9);
|
||||
for (const url of expectedUrls('0.78.1')) {
|
||||
expect(mockFetch).toHaveBeenCalledWith(url, {method: 'HEAD'});
|
||||
}
|
||||
});
|
||||
|
||||
it('waits when a classifier artifact is missing even though the POM exists', async () => {
|
||||
mockSleep.mockReturnValueOnce(Promise.resolve()).mockImplementation(() => {
|
||||
throw new Error('Should not be called again!');
|
||||
});
|
||||
// First attempt: POM ok, first classifier missing. Second attempt: all ok.
|
||||
mockFetch
|
||||
.mockReturnValueOnce(Promise.resolve({status: 200}))
|
||||
.mockReturnValueOnce(Promise.resolve({status: 404}))
|
||||
.mockReturnValue(Promise.resolve({status: 200}));
|
||||
|
||||
const version = '0.78.1';
|
||||
await verifyArtifactsAreOnMaven(version);
|
||||
|
||||
expect(mockSleep).toHaveBeenCalledTimes(1);
|
||||
expect(mockExit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('tries 90 times and then exits', async () => {
|
||||
@@ -82,6 +124,7 @@ describe('#verifyArtifactsAreOnMaven', () => {
|
||||
expect(mockExit).toHaveBeenCalledWith(1);
|
||||
expect(mockFetch).toHaveBeenCalledWith(
|
||||
'https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.78.1/react-native-artifacts-0.78.1.pom',
|
||||
{method: 'HEAD'},
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -7,6 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
// @flow
|
||||
const {log, sleep} = require('./utils');
|
||||
|
||||
const SLEEP_S = 60; // 1 minute
|
||||
@@ -15,23 +16,64 @@ const ARTIFACT_URL =
|
||||
'https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/';
|
||||
const ARTIFACT_NAME = 'react-native-artifacts-';
|
||||
|
||||
async function verifyArtifactsAreOnMaven(version, retries = MAX_RETRIES) {
|
||||
// The primary xcframework classifier tarballs attached to the
|
||||
// react-native-artifacts publication (external-artifacts/build.gradle.kts).
|
||||
// The 4 dSYM classifiers (core/deps dSYM debug+release) are intentionally
|
||||
// excluded — they are debug-symbol sidecars, not consumed at install time.
|
||||
// The POM check alone would pass even when a classifier artifact never made
|
||||
// it to Maven.
|
||||
const ARTIFACT_CLASSIFIERS = [
|
||||
'reactnative-core-debug',
|
||||
'reactnative-core-release',
|
||||
'reactnative-dependencies-debug',
|
||||
'reactnative-dependencies-release',
|
||||
'reactnative-headers-debug',
|
||||
'reactnative-headers-release',
|
||||
'reactnative-dependencies-headers-debug',
|
||||
'reactnative-dependencies-headers-release',
|
||||
];
|
||||
|
||||
async function verifyArtifactsAreOnMaven(
|
||||
version: string,
|
||||
retries: number = MAX_RETRIES,
|
||||
): Promise<void> {
|
||||
if (version.startsWith('v')) {
|
||||
version = version.substring(1);
|
||||
}
|
||||
|
||||
const artifactUrl = `${ARTIFACT_URL}${version}/${ARTIFACT_NAME}${version}.pom`;
|
||||
const urls = [
|
||||
`${ARTIFACT_URL}${version}/${ARTIFACT_NAME}${version}.pom`,
|
||||
...ARTIFACT_CLASSIFIERS.map(
|
||||
classifier =>
|
||||
`${ARTIFACT_URL}${version}/${ARTIFACT_NAME}${version}-${classifier}.tar.gz`,
|
||||
),
|
||||
];
|
||||
for (let currentAttempt = 1; currentAttempt <= retries; currentAttempt++) {
|
||||
const response = await fetch(artifactUrl);
|
||||
let missingUrl = null;
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const response = await fetch(url, {method: 'HEAD'});
|
||||
if (response.status === 200) {
|
||||
continue;
|
||||
}
|
||||
log(`Got status ${response.status} while checking ${url}`);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
log(`Network error while checking ${url}: ${message}`);
|
||||
missingUrl = url;
|
||||
break;
|
||||
}
|
||||
missingUrl = url;
|
||||
break;
|
||||
}
|
||||
|
||||
if (response.status !== 200) {
|
||||
log(
|
||||
`${currentAttempt}) Artifact's for version ${version} are not on maven yet.\nURL: ${artifactUrl}\nLet's wait a minute and try again.\n`,
|
||||
);
|
||||
await sleep(SLEEP_S);
|
||||
} else {
|
||||
if (missingUrl == null) {
|
||||
return;
|
||||
}
|
||||
log(
|
||||
`${currentAttempt}) Artifact's for version ${version} are not on maven yet.\nURL: ${missingUrl}\nLet's wait a minute and try again.\n`,
|
||||
);
|
||||
await sleep(SLEEP_S);
|
||||
}
|
||||
|
||||
log(
|
||||
|
||||
Reference in new issue
Block a user