feat(macos): macOS support via RN's first-party SPM helper#30
Merged
Conversation
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>
This was referenced May 10, 2026
LeslieOA
added a commit
that referenced
this pull request
May 10, 2026
Project hygiene now that #27 is closed: - README, docs/installation.md, docs/examples.md no longer say macOS is pending. Platform support tables, roadmap, and run instructions all reflect macOS shipping. - docs/installation.md: rewritten SPM bridging section. Two paths (cocoapods-spm for iOS-via-Expo-CNG, RN's first-party `spm_dependency` for bare react-native-macos) with full Podfile snippets, plus the static-linkage caveat and the fmt/Apple-Clang-17 patch pointer. - README's "Repo layout" updated: ios/ is shared across platforms (with `#if os(iOS) / #elseif os(macOS)` branching), example/macos-app/ is runnable, and `app.plugin.js` is iOS-only. - README's "Running the macOS example" section replaced with the actual npm scripts. Bump version 0.0.1 → 0.1.0 (still pre-npm; the README explicitly reserves npm publishing for v1.0). First milestone tag — both target platforms shipping. Add CHANGELOG.md following Keep a Changelog 1.1.0. The 0.1.0 entry covers all merged work to date (PRs #11 through #30). Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pods.xcodeprojon Xcode 26 — a UUID collision between its STTextView `XCSwiftPackageProductDependency` and the `PBXProject` root object, causing Xcode to send `_setSavedArchiveVersion:` to the wrong type and bail. (cocoapods-spm#172 tracks it; no upstream fix.)Key changes
Plus auto-edits from `pod install` (Pods integration in pbxproj, `RCTNewArchEnabled = true` in Info.plist), `Podfile.lock` and `PrivacyInfo.xcprivacy` checked in for reproducibility, and `example/macos-app/README.md` rewritten to document the now-shipping workflow.
Test plan
🤖 Generated with Claude Code