Skip to content

feat(ios): add Swift Package Manager support - #919

Merged
sboily merged 2 commits into
react-native-webrtc:masterfrom
chrfalch:spm-support
Nov 16, 2026
Merged

sboily merged 2 commits into
react-native-webrtc:masterfrom
chrfalch:spm-support

Conversation

@chrfalch

Copy link
Copy Markdown
Contributor

Summary

React Native 0.88 can build iOS libraries with Swift Package Manager (SwiftPM) instead of CocoaPods. react-native-callkeep has no Package.swift, so apps that use SwiftPM cannot use it.

This PR adds SwiftPM support. CocoaPods users see no change, and no source file changes.

  1. Package.swift: the manifest that React Native's SwiftPM autolinking uses. It builds ios/RNCallKeep and defines RCT_NEW_ARCH_ENABLED=1, as React Native's SwiftPM library manifests do. The callkeep sources do not read this define. It bundles ios/PrivacyInfo.xcprivacy as a resource, as the podspec's resource_bundles does.
  2. include/RNCallKeep/RNCallKeep.h: a one-line public header that re-exports ios/RNCallKeep/RNCallKeep.h. App code can keep #import <RNCallKeep/RNCallKeep.h>, for example for setup from native code.
  3. package.json: the Swift package name (swiftpmConfig.name, RNCallKeep, the same as the podspec). The package has no files list, so npm already ships the new files.

Would you like SwiftPM support in this library? I am glad to change the approach.

Test plan

  • New React Native 0.88.1 app, set up for SwiftPM with npx react-native spm add --deintegrate --yes, with react-native-callkeep from this branch.
  • Without this change, spm add fails: Package.swift is missing for library "react-native-callkeep".
  • xcodebuild Debug and Release, iOS simulator: both BUILD SUCCEEDED. The app's Swift AppDelegate calls RNCallKeep.isCallActive through a bridging header with #import <RNCallKeep/RNCallKeep.h>.
  • The built app contains PrivacyInfo.xcprivacy in the RNCallKeep_RNCallKeep.bundle resource bundle, byte-identical to ios/PrivacyInfo.xcprivacy.
  • Release build, without Metro: JavaScript calls RNCallKeep.isCallActive with an unknown call UUID, and the native module returns false.
  • npm run check passes, and npm pack includes Package.swift and include/RNCallKeep/RNCallKeep.h.
  • Not covered: a real call through CallKit, and Swift import RNCallKeep without a bridging header.

@sboily sboily self-assigned this Nov 16, 2026
@sboily sboily added the ios label Nov 16, 2026

@sboily sboily left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I checked it with React Native 0.88.1 and Xcode 27, on the iOS 27 simulator:

  • Without this PR, npx react-native spm add --deintegrate --yes fails with Package.swift is missing for library "react-native-callkeep". With it, the autolinker uses the manifest (Self-managed: RNCallKeep), and the Debug and Release builds succeed.
  • A Swift scene delegate can import RNCallKeep without a bridging header, as our iOS docs show. RNCallKeep.isCallActive and RNCallKeep.continueUserActivity compile, and at launch the Release app's isCallActive call returns false. From JavaScript, isCallActive resolves false too.
  • The app's RNCallKeep_RNCallKeep.bundle holds the privacy manifest, byte-identical to ios/PrivacyInfo.xcprivacy.
  • RNCallKeep.m is compiled with DEBUG=1 in Debug and without it in Release, as with CocoaPods, so CallKeep's debug logging doesn't change.
  • For CocoaPods, pod ipc spec gives the same JSON as 4.6.1.

I'll add the changelog entry and a SwiftPM section to the iOS installation docs in a follow-up.

@sboily
sboily merged commit eaefcff into react-native-webrtc:master Nov 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants