Skip to content

Commit 6157eb5

Browse files
chrfalchclaude
andcommitted
feat(spm): SwiftPM package generation tooling
The scripts/spm toolchain that generates a SwiftPM Package.swift + xcodeproj for React Native and community libraries, on top of the headers-spec header layout (React.framework + ReactNativeHeaders, no VFS). Consumes headers-compose.ensureHeadersLayout to compose the header artifacts; ships the compose runtime + scripts/spm via the npm files allowlist. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4d48e1f commit 6157eb5

36 files changed

Lines changed: 18899 additions & 1 deletion

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"workspaces": [
4444
"packages/*",
45+
"packages/react-native-test-library/*",
4546
"private/*",
4647
"!private/helloworld"
4748
],

packages/react-native/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@
107107
"scripts/hermes/hermes-utils.js",
108108
"scripts/hermes/prepare-hermes-for-build.js",
109109
"scripts/ios-configure-glog.sh",
110+
"scripts/ios-prebuild/headers-compose.js",
111+
"scripts/ios-prebuild/headers-config.js",
112+
"scripts/ios-prebuild/headers-inventory.js",
113+
"scripts/ios-prebuild/headers-spec.js",
114+
"scripts/ios-prebuild/headers.js",
115+
"scripts/ios-prebuild/utils.js",
110116
"scripts/native_modules.rb",
111117
"scripts/node-binary.sh",
112118
"scripts/packager-reporter.js",
@@ -115,6 +121,8 @@
115121
"scripts/react_native_pods_utils/script_phases.sh",
116122
"scripts/react_native_pods.rb",
117123
"scripts/react-native-xcode.sh",
124+
"scripts/setup-apple-spm.js",
125+
"scripts/spm",
118126
"scripts/xcode/ccache-clang.sh",
119127
"scripts/xcode/ccache-clang++.sh",
120128
"scripts/xcode/ccache.conf",
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// swift-tools-version: 6.0
2+
/*
3+
* Copyright (c) Meta Platforms, Inc. and affiliates.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
// AUTO-GENERATED by scripts/setup-apple-spm.js – do not edit manually.
10+
// This SPM-specific template replaces the CocoaPods codegen template
11+
// with xcframework configuration built in.
12+
13+
import PackageDescription
14+
15+
// React headers need NO search paths: React/react namespaces come from the
16+
// React binaryTarget (auto -F; headers + module map inside the framework),
17+
// every other namespace from the ReactNativeHeaders binaryTarget, and the
18+
// per-app generated headers from the ReactAppHeaders target below — all
19+
// auto-served by SPM through product/target dependencies.
20+
let headersDep: [Target.Dependency] = [
21+
.product(name: "ReactNativeHeaders", package: "ReactNative"),
22+
"ReactAppHeaders",
23+
]
24+
25+
let package = Package(
26+
name: "React-GeneratedCode",
27+
platforms: [.iOS(.v15), .macCatalyst(SupportedPlatform.MacCatalystVersion.v13)],
28+
products: [
29+
.library(
30+
name: "ReactCodegen",
31+
targets: ["ReactCodegen"]),
32+
.library(
33+
name: "ReactAppDependencyProvider",
34+
targets: ["ReactAppDependencyProvider"]),
35+
.library(
36+
name: "ReactAppHeaders",
37+
targets: ["ReactAppHeaders"]),
38+
],
39+
dependencies: [
40+
.package(name: "ReactNative", path: "../../xcframeworks"),
41+
],
42+
targets: [
43+
.target(
44+
name: "ReactCodegen",
45+
dependencies: [
46+
.product(name: "ReactNative", package: "ReactNative"),
47+
.product(name: "ReactNativeDependencies", package: "ReactNative"),
48+
] + headersDep,
49+
path: "ReactCodegen",
50+
exclude: ["ReactCodegen.podspec"],
51+
publicHeadersPath: ".",
52+
cSettings: [.headerSearchPath("headers")],
53+
cxxSettings: [.headerSearchPath("headers")],
54+
linkerSettings: [
55+
.linkedFramework("Foundation")
56+
]
57+
),
58+
.target(
59+
name: "ReactAppDependencyProvider",
60+
dependencies: ["ReactCodegen"] + headersDep,
61+
path: "ReactAppDependencyProvider",
62+
exclude: ["ReactAppDependencyProvider.podspec"],
63+
publicHeadersPath: ".",
64+
cSettings: [.headerSearchPath(".."), .headerSearchPath("headers")],
65+
cxxSettings: [.headerSearchPath(".."), .headerSearchPath("headers")],
66+
linkerSettings: [
67+
.linkedFramework("Foundation")
68+
]
69+
),
70+
// The per-app generated-headers farm (built by spm sync), vended as a
71+
// normal SPM headers target.
72+
.target(
73+
name: "ReactAppHeaders",
74+
path: "ReactAppHeaders",
75+
publicHeadersPath: "."
76+
),
77+
],
78+
// React Native headers require C++20 (concepts, std::optional, etc.)
79+
cxxLanguageStandard: .cxx20
80+
)

0 commit comments

Comments
 (0)