Commit 3f3a5a3
feat(macos): ship macOS support via RN's first-party SPM helper (#30)
The original blocker for #27 wasn't Swift sources — it was cocoapods-spm
0.1.20 producing a malformed Pods.xcodeproj on Xcode 26 (UUID collision
between its STTextView XCSwiftPackageProductDependency and the PBXProject
root, causing Xcode to send `_setSavedArchiveVersion:` to the wrong type
and bail). Issue trinhngocthuyen/cocoapods-spm#172 tracks it; no upstream
fix and the RN community is migrating off the plugin.
Switch the macOS path to React Native's first-party `spm_dependency`
helper (lives in `react_native_pods.rb`, present in react-native-macos
0.81). It registers SPM products via Xcodeproj-direct, sidestepping the
cocoapods-spm UUID allocator entirely. iOS-via-Expo-CNG keeps using
cocoapods-spm via `app.plugin.js` — that path was never broken.
Library
- `ReactNativeSourceEditor.podspec`: add `:osx => '14.0'` and gate the
SPM declaration on `ENV['RNSE_USE_RN_SPM']`. iOS branch keeps
`s.spm_dependency 'STTextView/STTextView'` (cocoapods-spm); macOS
branch calls RN's top-level `spm_dependency s, url:, requirement:,
products:`. The gate can't be `s.respond_to?(:spm_dependency)` —
cocoapods-spm monkey-patches Pod::Specification at gem load time
globally whenever installed.
- `ios/SourceEditor.mm`: guard the Swift bridging header import with
`__has_include`. iOS gets `<ReactNativeSourceEditor/...>` (framework
wrapper exists under `use_frameworks!`); macOS falls back to quote-form
which picks up the header from DerivedSources/ (no .framework wrapper
under default static-library linkage).
Example app
- `macos/Podfile`: drop `plugin 'cocoapods-spm'` and `spm_pkg`; set
`ENV['RNSE_USE_RN_SPM'] = '1'`. Stay on static linkage (the SPM warning
recommends dynamic, but `use_frameworks! :linkage => :dynamic` triggers
a separate RN-macOS bug where React-Core's `RCTView.m` hardcodes a
class ref to `RCTTextView` that doesn't resolve across dynamic
frameworks).
- `metro.config.js`: add `unstable_enablePackageExports` and
`unstable_conditionNames: ['source', 'react-native', ...]` so metro
reads the package's `source` exports condition (`src/index.ts`)
instead of the unbuilt `lib/module/index.js`. Expo's metro config does
this automatically for the iOS example; @react-native/metro-config
does not.
- `Info.plist`: add `RCTNewArchEnabled = true` for Fabric.
- `MacosApp.xcodeproj`: Pods integration auto-edits from `pod install`.
- `Podfile.lock`, `PrivacyInfo.xcprivacy`: track for reproducibility.
- `README.md`: rewrite — now ships, documents toolchain choices.
Hygiene
- `.gitignore`: add `Pods/`, `MacosApp.xcworkspace/`, `.xcode.env*`,
`.spm.pods/` under `example/macos-app/macos/`.
- `package.json`: drop `macos:plugin` (installed cocoapods-spm — no
longer needed on the macOS path).
Closes #27.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 7eb09fb commit 3f3a5a3
11 files changed
Lines changed: 2860 additions & 42 deletions
File tree
- example/macos-app
- macos
- MacosApp-macOS
- MacosApp.xcodeproj
- ios
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
34 | 59 | | |
35 | 60 | | |
36 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
0 commit comments