Repository navigation
Conversation
This branch has not been deployed
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.
Summary
React Native 0.88 can build apps with Swift Package Manager (SwiftPM). React Native 0.89 plans to make it the default. CocoaPods trunk is becoming read-only.
@segment/sovran-react-nativeand@segment/analytics-react-nativehave noPackage.swift, so SwiftPM apps cannot use them.This PR has two commits, one for each package:
feat(sovran): add Swift Package Manager supportfeat(core): add Swift Package Manager supportThe
sovranscope matches earlier commits such asfix(sovran): …(#1299).sovran
packages/sovran/Package.swiftwith one product,sovran_react_native. It has two targets:sovran_react_nativeforios/Sovran.swift, andSovranObjCforios/Sovran.m.packages/sovran/spm-headers/public/module.modulemap, an empty public module forSovranObjC.swiftpmConfig.nameand ship the new files through thefileslist inpackages/sovran/package.json.core
packages/core/Package.swiftwith one product,segment_analytics_react_native. It has two targets: one forios/AnalyticsReactNative.swift, andSegmentAnalyticsObjCforios/AnalyticsReactNative.m. The Swift target depends onsovran_react_native.packages/core/spm-support/React.swift. It imports React for the Swift code, because SwiftPM does not use the CocoaPods bridging header.packages/core/spm-headers/public/module.modulemap, an empty public module forSegmentAnalyticsObjC.swiftpmConfig.name, list@segment/sovran-react-nativeinswiftpmConfig.dependencies, and ship the new files through thefileslist inpackages/core/package.json.SwiftPM cannot compile Swift and Objective-C in one target, so each package has two targets. The product names are the pod names with underscores, because a hyphen is not valid in a Swift module name. Core's Swift code imports
sovran_react_native, so sovran's product must keep that name.The core Swift package includes
ios/PrivacyInfo.xcprivacyas a resource. The podspec does not ship this file.CocoaPods is unchanged. The podspecs and
ios/sources are untouched.Release order
Core's SwiftPM manifest needs a sovran release that has
Package.swift. The core range for sovran stays^1.1.0. Withdeps.bump: 'satisfy'inmulti-release.config.js, the release does not raise it. A SwiftPM app that resolves an older sovran stops atspm updatewith an error for sovran, because that release has noPackage.swift. You may want to raise the range to the first sovran release withPackage.swift. I left that choice to you.Limits: The Swift packages need iOS 15.1, the minimum of React Native 0.88. The podspecs stay at iOS 11. No CI job here builds the Swift packages yet.
RFC: react-native-community/discussions-and-proposals#994
Test plan
In a new React Native 0.88.1 app, with both packages installed from the local checkout:
Before this change,
spm updatestopped for both packages because each mixes Swift and Objective-C sources. After it, add and update passed. Debug and Release ended with** BUILD SUCCEEDED **.Runtime check: I ran the built app on an iOS simulator. All four checks passed:
getContextInforeturned the OS, bundle ID, device model, and screen size.Sovran.getConstantsreturnedON_STORE_ACTION.client.contextshowed the OS and the app.Not run: a device build, the CocoaPods build, and the repo's Jest tests.