Skip to content

feat(ios): Swift Package Manager in both React Native iOS build modes - #74

Merged
mikemilla merged 9 commits into
mainfrom
mike/c-22201-spm
Nov 16, 2026
Merged

mikemilla merged 9 commits into
mainfrom
mike/c-22201-spm

Conversation

@mikemilla

@mikemilla mikemilla commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

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):

  • Podspec: when spm_dependency is available (React Native 0.75+), the podspec adds courier-ios to the Pods project as a Swift package, pinned exactly. Older React Native falls back to s.dependency "Courier_iOS".
  • Two pins: courier_ios_version (6.0.10) feeds spm_dependency and 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.
  • React Native 0.87 and 0.88 fall back to trunk: on those versions, React Native's spm_dependency helper 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.
  • Xcode 26 required: on Xcode 16, Courier_iOS from spm_dependency links 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, with swiftpmConfig.name set to CourierReactNative. React Native's scaffolder can't generate one for a package that mixes Swift and Objective-C, so it has two targets:
    • a Swift target;
    • an Objective-C target for the RCT_EXTERN_MODULE declarations and CourierReactNativeDelegate, moved to ios/ObjC.
  • Swift sources:
    • They import UIKit and React explicitly, because a Swift package can't use the bridging header.
    • They build in Swift 5 mode, the same as under CocoaPods.
    • The bridge classes are now public. In Release, internal classes' Objective-C symbols stay local to the Swift target, so the Objective-C target's RCT_EXTERN_MODULE declarations couldn't link to them.
  • Delegate header: imports <React/RCTAppDelegate.h> when it's available, and otherwise keeps the old import.
  • Podspec: excludes ios/Package.swift.

CI:

  • A new build-ios (SwiftPM mode) job creates a fresh React Native 0.88.1 app, installs the packed library, runs npx react-native spm add, and builds it. The required build-ios check waits for it.
  • The CocoaPods build checks that ios/Package.swift and the podspec pin the same Courier_iOS. It also fails if Podfile.lock lists Courier_iOS, and checks that the resolved package matches the pin.

README: pod install (or npx 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.

  • SwiftPM mode: a new React Native 0.88.1 app with this package from npm pack, switched with npx react-native spm add --deintegrate.
    • React Native reports the package as self-managed ("using its own Package.swift").
    • There are no Pods, and courier-ios resolves to 6.0.10.
    • Release and Debug both build.
    • Signed in, the inbox loads, a POST /send message arrives live, and preferences load.
    • The new CI job's recipe was run the same way locally.
  • CocoaPods mode, example-085 (React Native 0.85.3):
    • pod install resolves courier-ios 6.0.10 through SPM, and the Release build succeeds after the file moves.
    • The in-app test suite on the Tests tab ran twice against the live API. Run 1 had no failures. Run 2 had one: "Open Message" timed out waiting for its test message to be delivered. It passed in run 1.
  • CocoaPods mode, fresh apps with a notification service extension that links Courier_iOS through SPM (Up to Next Major):
    • React Native 0.88.1 falls back to trunk 6.0.10. Before the fallback, it failed with the module map error.
    • React Native 0.89.0-rc.1 resolves courier-ios 6.0.10 through spm_dependency.
    • Both build with the extension embedded, sign in, and load the inbox, and a live message arrived on 0.89.

Notes

  • The Expo example wasn't rebuilt. Its Podfile.lock keeps the Courier_iOS pod until its next pod install.
  • courier-ios#74 changes the iOS release so it bumps courier_ios_version and ios/Package.swift here, and not the trunk fallback. Merge it after this PR.

🤖 Generated with Claude Code

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>
@linear

linear Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

C-22201

C-22272

mikemilla and others added 3 commits November 3, 2026 11:49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mikemilla mikemilla changed the title feat(ios): pull Courier_iOS through Swift Package Manager feat(ios): pull Courier_iOS 6.0.8 through Swift Package Manager (6.1.0) Nov 6, 2026
@mikemilla

Copy link
Copy Markdown
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.

@mikemilla mikemilla closed this Nov 9, 2026
mikemilla and others added 2 commits November 16, 2026 10:22
# 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>
@mikemilla mikemilla reopened this Nov 16, 2026
@mikemilla mikemilla changed the title feat(ios): pull Courier_iOS 6.0.8 through Swift Package Manager (6.1.0) feat(ios): pull Courier_iOS through Swift Package Manager Nov 16, 2026
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>
@mikemilla mikemilla changed the title feat(ios): pull Courier_iOS through Swift Package Manager feat(ios): Swift Package Manager in both React Native iOS build modes Nov 16, 2026
mikemilla and others added 2 commits November 16, 2026 11:32
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>
@mikemilla
mikemilla merged commit 33440bb into main Nov 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant