Repository navigation
feat(ios): Swift Package Manager in both React Native iOS build modes - #74
Merged
Merged
Conversation
CocoaPods trunk stops accepting new podspecs on December 2, 2026, so a podspec dependency on Courier_iOS can't reach versions released after that. On React Native 0.75+, declare it with spm_dependency instead: CocoaPods adds courier-ios as a Swift package to the Pods project and resolves it from the GitHub tag. React Native versions without spm_dependency fall back to s.dependency and stay on the last Courier_iOS published to trunk. The pin moves into a courier_ios_version variable that both paths share. Tested on the example app (React Native 0.85, iOS Simulator): Debug and Release with the default static libraries, and Release with USE_FRAMEWORKS=static. Courier_iOS's resource bundle is embedded, and the native inbox and preferences views load messages. CI installs pods with `pod install` (Courier_iOS is no longer a pod), checks Podfile.lock doesn't list it, and checks the Swift package resolved to the podspec's pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Closing for now. We're shipping the CocoaPods releases first and will pick up Swift Package Manager later. The branch stays so this can be reopened. |
# Conflicts: # .github/workflows/ci.yml # android/src/main/java/com/courierreactnative/Utils.kt # courier-react-native.podspec # example-085/ios/Podfile.lock # ios/CourierReactNativeDelegate.m # ios/CourierReactNativeEventEmitter.swift # package.json
On React Native 0.75 and later the podspec adds Courier_iOS through spm_dependency, so it comes from GitHub instead of CocoaPods trunk. The README says so, names the 6.0.10 fallback for older React Native, and explains how to add Courier_iOS to a notification service extension without a second copy of the SDK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
React Native 0.87 added a SwiftPM mode (0.89 plans to make it the default), which needs a library to ship its own Package.swift. This package mixes Swift and Objective-C, so the scaffolder can't generate one. - ios/Package.swift: a Swift target and an Objective-C target (now under ios/ObjC), with courier-ios pinned like the podspec. swiftpmConfig names the package CourierReactNative. - The Swift sources import UIKit and React explicitly (a package can't use the bridging header), build in Swift 5 mode, and the bridge classes are public so the Objective-C RCT_EXTERN_MODULE declarations link to them across targets. - The podspec excludes ios/Package.swift. - CI: a new job builds a fresh React Native 0.88.1 app in SwiftPM mode, the CocoaPods build checks Package.swift's pin matches the podspec, and the CocoaPods build runs on Xcode 26 only. On Xcode 16, spm_dependency links Courier_iOS twice into the static pod libraries. - README: both install paths, and the Xcode 26 requirement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
React Native 0.87 and 0.88 build static pods with Swift package dependencies into the shared products dir, then rewrite the app's module map paths with the pod name instead of the module name. For a pod with a hyphen in its name, like this one, the app fails to build with "module map file not found". 0.89 fixed it (react/react-native#59182). The podspec checks React Native's own helper for the bug and, when it's there, depends on Courier_iOS from trunk (6.0.10) instead. A patched 0.88 picks up Swift Package Manager automatically. Tested on fresh apps with a notification service extension that links Courier_iOS through Swift Package Manager: 0.88.1 falls back to trunk and builds, 0.89.0-rc.1 uses Swift Package Manager and builds, and both sign in and load the inbox. The README's iOS section keeps to what apps have to do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 16, 2026
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.
Makes the iOS side work without CocoaPods trunk, in both of React Native's iOS build modes. CocoaPods trunk goes read-only on December 2, 2026.
Changes
CocoaPods mode (the default today):
spm_dependencyis available (React Native 0.75+), the podspec addscourier-iosto the Pods project as a Swift package, pinned exactly. Older React Native falls back tos.dependency "Courier_iOS".courier_ios_version(6.0.10) feedsspm_dependencyand moves with every Courier_iOS release.courier_ios_trunk_version(6.0.10) is the CocoaPods fallback and stays on the latest version on trunk.spm_dependencyhelper builds static pods into the shared products dir and rewrites the app's module map paths with the pod name instead of the module name. A hyphenated pod like this one then fails with "module map file not found". 0.89 fixed this (fix(iOS): use the module name when rewriting module map paths of spm_dependency pods react/react-native#59182). The podspec checks React Native's helper for the bug and, when it's present, depends on Courier_iOS 6.0.10 from trunk. A patched 0.88 gets SPM automatically.spm_dependencylinks twice into React Native's static pod libraries (duplicate symbols). React Native documents this limitation in Allow library podspec to declare Swift Package Manager dependencies react/react-native#44627. The App Store has required Xcode 26 since April 28, 2026. CI's CocoaPods build now runs on Xcode 26.6 only.React Native's Swift Package Manager mode (0.87+, planned as the default in 0.89):
ios/Package.swift: the package ships its own manifest, withswiftpmConfig.nameset toCourierReactNative. React Native's scaffolder can't generate one for a package that mixes Swift and Objective-C, so it has two targets:RCT_EXTERN_MODULEdeclarations andCourierReactNativeDelegate, moved toios/ObjC.UIKitandReactexplicitly, because a Swift package can't use the bridging header.public. In Release, internal classes' Objective-C symbols stay local to the Swift target, so the Objective-C target'sRCT_EXTERN_MODULEdeclarations couldn't link to them.<React/RCTAppDelegate.h>when it's available, and otherwise keeps the old import.ios/Package.swift.CI:
npx react-native spm add, and builds it. The requiredbuild-ioscheck waits for it.ios/Package.swiftand the podspec pin the same Courier_iOS. It also fails ifPodfile.locklists Courier_iOS, and checks that the resolved package matches the pin.README:
pod install(ornpx react-native spm), and the notification service extension callout.The version bump (6.1.0) goes in a separate release PR after this merges.
Testing
Run on 2026-11-16 on an iPhone 17 Pro simulator with Xcode 27.2.
npm pack, switched withnpx react-native spm add --deintegrate.courier-iosresolves to 6.0.10.POST /sendmessage arrives live, and preferences load.example-085(React Native 0.85.3):pod installresolvescourier-ios6.0.10 through SPM, and the Release build succeeds after the file moves.courier-ios6.0.10 throughspm_dependency.Notes
Podfile.lockkeeps the Courier_iOS pod until its nextpod install.courier_ios_versionandios/Package.swifthere, and not the trunk fallback. Merge it after this PR.🤖 Generated with Claude Code