Repository navigation
fix: make the opt-in SPM path build and launch - #334
Merged
Merged
Conversation
Two bugs kept NEWRELIC_USE_SPM=1 apps from working: - The podspec passed sdkVersions.ios (a CocoaPods requirement such as '~>7.7.8' since 1.9.0) to SPM as an exact version; Xcode crashes resolving it. It now uses upToNextMinorVersion from that version, the SPM equivalent of '~>'. - React Native's spm_dependency links the pod against NewRelic.xcframework but never embeds the dynamic framework, so the app crashed at launch (Library not loaded: @rpath/NewRelic.framework/NewRelic), and Xcode 26+ archives failed on a duplicate xcframework signature. newrelic_spm.rb adds NewRelic.framework to the app's [CP] Embed Pods Frameworks script and removes the duplicate signature, as react/react-native#58781 does in unreleased React Native; it steps aside when React Native already does it. Verified on the SPM example (RN 0.76.5, Xcode 27.1): Debug and Release simulator builds embed NewRelic.framework 7.7.9 and launch with the agent started, the archive succeeds, a second pod install changes nothing, the app's .xcodeproj is never edited, and turning SPM off removes the embed call.
Contributor
Release notes check: passedThis PR will appear under Bug fixes (from its label) as:
Release notes are reviewed and edited by a person before they are published. |
ndesai-newrelic
approved these changes
Oct 22, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #334 +/- ##
=======================================
Coverage 89.25% 89.25%
=======================================
Files 12 12
Lines 484 484
Branches 103 103
=======================================
Hits 432 432
Misses 46 46
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What & why
The opt-in Swift Package Manager path (
NEWRELIC_USE_SPM=1, added in #313) didn't work. An app that opted in failed at the first of these:sdkVersions.iosto SPM as an exact version. Since 1.9.0 (chore: Update native agents to v1.9.0 #315) that value is a CocoaPods requirement such as~>7.7.8, and Xcode fails on it:non-numerical characters in version core identifier '~>7'.spm_dependencylinks the pod againstNewRelic.xcframework, but nothing embeds that dynamic framework in the app:dyld: Library not loaded: @rpath/NewRelic.framework/NewRelic. Xcode 26+ archives also failed on a duplicateNewRelic.xcframework-ios.signature.React Native fixes the second problem upstream in react/react-native#58781, which no released version has yet (0.86 and earlier).
Changes
newrelic-react-native-agent.podspec: the SPM requirement is nowupToNextMinorVersionfrom the version insdkVersions.ios. That's the SPM equivalent of CocoaPods'~>(~> 7.7.8means ≥ 7.7.8 and < 7.8.0).newrelic_spm.rb(new, loaded by the podspec), in SPM mode only:install_spm_framework "NewRelic"to each app's[CP] Embed Pods Frameworksscript, using the same shell function as #58781;CocoaPods regenerates that script on every install, so apps need no Podfile changes, the app's
.xcodeprojis never edited, and turning SPM off leaves nothing behind. The approach follows stripe-react-native'sstripe_spm.rb.NewRelicExampleApp-SPM/README.md: the "is SPM active" check now includes the embed call and an actual launch. The old check passed while the app crashed.Testing
On
NewRelicExampleApp-SPM(React Native 0.76.5, Xcode 27.1, CocoaPods 1.16.2), with this branch as the plugin:xcodebuild -resolvePackageDependencies'~>7')NewRelic7.7.9Library not loaded)NewRelic.framework7.7.9 embedded, launches[NRMA] React Native agent started.xcodebuild archivepod installNewRelicAgent7.7.8 from CocoaPods as beforeNot tested: a physical device, other React Native versions, and the new architecture.
Note: with
upToNextMinorVersion, SPM apps already get iOS agent 7.7.9. It's on GitHub and SPM but not yet on CocoaPods, where the default path still reads from.Release note
Fixed the opt-in Swift Package Manager integration (
NEWRELIC_USE_SPM=1): apps no longer crash at launch withLibrary not loaded: @rpath/NewRelic.framework/NewRelic, archives no longer fail on a duplicate xcframework signature, and the iOS agent resolves to the newest 7.7.x release.🤖 Generated with Claude Code