Repository navigation
Add a Swift Package Manager manifest for React Native SPM apps #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+93
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // swift-tools-version:5.9 | ||
| import PackageDescription | ||
|
|
||
| // How this package finds React Native's header products (ReactHeaders etc.). | ||
| // | ||
| // `react-native spm scaffold` emits this same path, and react-native-screens, reanimated and | ||
| // Sentry ship this same pattern. | ||
| // RN generates these products in a local package inside each app, at | ||
| // <app>/ios/build/xcframeworks, and gives a hand-written manifest no way to locate the app. The | ||
| // path works because the autolinker loads this manifest through a symlink at | ||
| // <app>/ios/build/generated/autolinking/libs/CodePush, and SwiftPM resolves relative paths from | ||
| // that symlink, not from node_modules. Shipping no manifest is not an option: the autolinker | ||
| // rejects a dependency without one. | ||
| // | ||
| // It breaks in remote mode (RN_SPM_REMOTE_URL) and with a custom `--xcframeworks-path`. | ||
| // RN's documented contract for hand-written manifests is a remote package dependency instead, | ||
| // which RN doesn't publish as of 0.88: | ||
| // https://github.com/react/react-native/blob/v0.88.0/packages/react-native/scripts/spm/__docs__/spm-header-paths-contract.md#hand-authored-community-library-contract | ||
| let reactNativePackagePath = "../../../../xcframeworks" | ||
|
|
||
| let package = Package( | ||
| name: "CodePush", | ||
| platforms: [ | ||
| .iOS("15.5"), | ||
| .tvOS("15.5"), | ||
| ], | ||
| products: [ | ||
| .library(name: "CodePush", targets: ["CodePush"]), | ||
| ], | ||
| dependencies: [ | ||
| .package(name: "ReactNative", path: reactNativePackagePath), | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional and not fixable today. See PR description for details. |
||
| .package(url: "https://github.com/ZipArchive/ZipArchive", .upToNextMinor(from: "2.5.5")), | ||
| ], | ||
| targets: [ | ||
| .target( | ||
| name: "CodePush", | ||
| dependencies: [ | ||
| "CodePushCore", | ||
| "CodePushHDiffPatch", | ||
| .product(name: "ZipArchive", package: "ZipArchive"), | ||
| .product(name: "ReactHeaders", package: "ReactNative"), | ||
| .product(name: "ReactNativeHeaders", package: "ReactNative"), | ||
| .product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"), | ||
| ], | ||
| path: "ios/CodePush", | ||
| publicHeadersPath: "include" | ||
| ), | ||
| .target( | ||
| name: "CodePushCore", | ||
| path: "ios/CodePushCore/Sources/CodePushCore" | ||
| ), | ||
| .target( | ||
| name: "CodePushHDiffPatch", | ||
| path: "shared", | ||
| sources: [ | ||
| "diffpatch/bspatch_bridge.c", | ||
| "third_party/hdiffpatch/libHDiffPatch/HPatch/patch.c", | ||
| "third_party/hdiffpatch/bsdiff_wrapper/bspatch_wrapper.c", | ||
| "third_party/hdiffpatch/file_for_patch.c", | ||
| ], | ||
| publicHeadersPath: "diffpatch", | ||
| cSettings: [ | ||
| // Keep in sync with CodePush.podspec and android/app/src/main/cpp/CMakeLists.txt. | ||
| .define("_IS_NEED_BLOCK_DEV", to: "0"), | ||
| .define("_IS_USED_MULTITHREAD", to: "0"), | ||
| .define("_IS_NEED_DIR_DIFF_PATCH", to: "0"), | ||
| .headerSearchPath("."), | ||
| .headerSearchPath("third_party/hdiffpatch"), | ||
| .headerSearchPath("third_party/hdiffpatch/libHDiffPatch/HPatch"), | ||
| ], | ||
| linkerSettings: [ | ||
| .linkedLibrary("z"), | ||
| .linkedLibrary("bz2"), | ||
| ] | ||
| ), | ||
| ] | ||
| ) | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // SwiftPM exposes only include/ to dependents, so this gives them `#import <CodePush/CodePush.h>`. | ||
| // SwiftPM also generates the CodePush module map from this umbrella header. | ||
| #import "../../CodePush.h" |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is meant to prevent accidentally picking up
.swiftfiles from the mainCodePushsource dir. New Swift code should go toCodePushCore