Repository navigation
feat: spm support for rn 0.89 - #449
Closed
VladyslavMartynov10 wants to merge 1 commit into
Closed
VladyslavMartynov10 wants to merge 1 commit into
VladyslavMartynov10 wants to merge 1 commit into
Conversation
Owner
|
Thanks for putting this together. For 2.0 we've decided that apps install the iOS part through CocoaPods only. The Swift package in the repository is used only to run the library's own tests, and supporting it for apps would mean building and testing two install paths. The reasoning is in ADR 0015 (https://github.com/duguyihou/react-native-turbo-image/blob/main/docs/adr/0015-cocoapods-only-for-apps.md). 2.0 also restructures the iOS sources, so the files this PR changes no longer exist. If that changes, for example once React Native itself moves apps to Swift Package Manager, we'll revisit it. Closing this one, but thank you. |
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.
SPM support
React Native 0.87 added Swift Package Manager as an alternative to CocoaPods on iOS (
npx react-native spm), and 0.88 stabilised it. The plan for 0.89 is to make SwiftPM the default for new apps, with CocoaPods as the opt-out (see react-native-community/cli#2881). In SwiftPM mode the autolinker needs every native library to ship aPackage.swift; a library without one fails package resolution for the whole app unless the user scaffolds and patches a manifest locally.react-native-turbo-image currently ships only a podspec, so it cannot be used in a SwiftPM app today.
What this PR does
Adds a
Package.swiftand the few source changes SwiftPM needs. CocoaPods is unchanged; the podspec stays the source of truth for that path.Package.swift(new)TurboImage(Swift): the view, view manager, extensions and utilities.TurboImageObjC:TurboImageViewManager.monly, i.e. theRCT_EXTERN_MODULEdeclarations. It references the Swift class by name, so it does not import the Swift target.TurboImage.build/generated/autolinking/libs/TurboImagesymlink, so the manifest only resolves inside an app, same as react-native-safe-area-context and react-native-pager-view), plus Nuke/NukeUI, Gifu and APNGKit as SwiftPM source packages instead of the vendored xcframeworks and pods.12.8.0..<13.0.0, the same major as the vendored 12.8.0 frameworks.3.3.1..<4.0.0. Gifu 4.0.x ships aPackage@swift-6.0.swiftmanifest with an iOS 16 floor, which current Xcode toolchains select, and React Native's autolinking package sits at the app's deployment target with a 15.1 floor, so Gifu 4 cannot be resolved from a default RN app. 3.x is also what CocoaPods resolves today.from: 2.3.0.ios/TurboImageViewManager.swiftimport React. SwiftPM has no bridging headers; under CocoaPodsTurboImage-Bridging-Header.hprovidedRCTViewManager.The class is now
public,view()returnsUIView!, andrequiresMainQueueSetup()is public. With theRCT_EXTERN_MODULEcategory in a separate target, an optimized build hides an internal Swift class's Objective-C symbol and the Release link fails withUndefined symbols: _OBJC_CLASS_$_TurboImageViewManager.ios/Extensions/UIImage+BorderRadius.swift,ios/Extensions/UIImage+Thumbhash.swiftimport UIKit. CocoaPods provided it through the umbrella header.package.jsonPackage.swiftadded tofiles, otherwise it is not published.swiftpmConfig.name: "TurboImage", the product name the autolinker links.How it was tested
Fresh app from
@react-native-community/cli@20.2.0 init --version 0.88.1, converted withnpx react-native spm add --deintegrate, this package installed fromnpm packoutput. Xcode 26.6, iPhone 17 Pro simulator (iOS 26.5).