-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[iOS] add SPM build support #4510
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
Merged
m-bert
merged 7 commits into
software-mansion:main
from
kacperzolkiewski:feat/spm-integration
Sep 15, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5ecb5d9
feat(iOS): add SPM build support
kacperzolkiewski 4d2c4f2
ci: add workflow for blank RN app SPM build
kacperzolkiewski c154ecb
fix: review changes
kacperzolkiewski 0a032ac
ci: add gesture handler build with worklets
kacperzolkiewski ac152fd
ci: use macos-26
kacperzolkiewski 1f1e961
fix: worklets exists path
kacperzolkiewski 968cb1d
ci: simplify spm build
kacperzolkiewski 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| name: Build iOS (SPM) | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - packages/react-native-gesture-handler/Package.swift | ||
| - packages/react-native-gesture-handler/package.json | ||
| - packages/react-native-gesture-handler/react-native.config.js | ||
| - packages/react-native-gesture-handler/package.json | ||
| - packages/react-native-gesture-handler/RNGestureHandler.podspec | ||
| - packages/react-native-gesture-handler/apple/** | ||
| - packages/react-native-gesture-handler/shared/** | ||
| - packages/react-native-gesture-handler/src/** | ||
| - rnrepo.config.json | ||
| - yarn.lock | ||
| - '!packages/react-native-gesture-handler/src/**/*.test.*' | ||
| - .github/workflows/ios-spm-build-test.yml | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ios-spm-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| ios-spm: | ||
| if: github.repository == 'software-mansion/react-native-gesture-handler' | ||
|
|
||
| runs-on: macos-26 | ||
| timeout-minutes: 60 | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| worklets: [false, true] | ||
|
|
||
| env: | ||
| APP_NAME: GHSpmTest | ||
| WORKLETS_VERSION: 0.13.0-nightly-20260913-5336bb7f4 | ||
|
|
||
| steps: | ||
| - name: checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Select Xcode | ||
| run: | | ||
| XCODE_APP="/Applications/Xcode_26.4.1.app" | ||
| if [ ! -d "$XCODE_APP" ]; then | ||
| echo "Xcode 26.4.1 is not installed on this runner. Available:" >&2 | ||
| ls -d /Applications/Xcode*.app >&2 | ||
| fi | ||
| echo "Using $XCODE_APP" | ||
| echo "DEVELOPER_DIR=$XCODE_APP/Contents/Developer" >> "$GITHUB_ENV" | ||
| DEVELOPER_DIR="$XCODE_APP/Contents/Developer" xcodebuild -version | ||
|
|
||
| - name: Use Node.js 24 | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24 | ||
| cache: yarn | ||
|
|
||
| - name: Read React Native version | ||
| id: rn-version | ||
| run: | | ||
| RN_VERSION=$(node -p "require('./packages/react-native-gesture-handler/package.json').devDependencies['react-native']") | ||
| echo "version=$RN_VERSION" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Install monorepo dependencies | ||
| run: yarn --immutable | ||
|
|
||
| - name: Build and pack library | ||
| working-directory: packages/react-native-gesture-handler | ||
| run: | | ||
| yarn build | ||
| mkdir -p /tmp/packs | ||
| npm pack --pack-destination /tmp/packs | ||
| echo "GH_TARBALL=$(ls /tmp/packs/react-native-gesture-handler-*.tgz)" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Create blank RN app | ||
| run: | | ||
| npx @react-native-community/cli@latest init "${{ env.APP_NAME }}" \ | ||
| --version "${{ steps.rn-version.outputs.version }}" | ||
|
|
||
| - name: Install GH from tarball | ||
| working-directory: ${{ env.APP_NAME }} | ||
| run: npm install "${{ env.GH_TARBALL }}" | ||
|
|
||
| - name: Install react-native-worklets | ||
| if: matrix.worklets | ||
| working-directory: ${{ env.APP_NAME }} | ||
| run: npm install "react-native-worklets@${{ env.WORKLETS_VERSION }}" | ||
|
|
||
| - name: SPM scaffold | ||
| working-directory: ${{ env.APP_NAME }} | ||
| run: npx react-native spm scaffold --deintegrate --yes | ||
|
|
||
| - name: Assert worklets are linked into RNGestureHandler | ||
| if: matrix.worklets | ||
| working-directory: ${{ env.APP_NAME }} | ||
| run: | | ||
| swift package --package-path ios/build/generated/autolinking show-dependencies --format dot \ | ||
| | grep 'libs/RNGestureHandler" -> ".*libs/RNWorklets"' | ||
|
|
||
| - name: Build iOS (SPM) | ||
| working-directory: ${{ env.APP_NAME }}/ios | ||
| run: | | ||
| xcodebuild build \ | ||
| -project "${{ env.APP_NAME }}.xcodeproj" \ | ||
| -scheme "${{ env.APP_NAME }}" \ | ||
| -configuration Debug \ | ||
| -sdk iphonesimulator \ | ||
| -destination 'generic/platform=iOS Simulator' \ | ||
| -quiet |
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,84 @@ | ||
| // swift-tools-version: 6.0 | ||
|
|
||
| import Foundation | ||
| import PackageDescription | ||
|
|
||
| let packageDirectory = Context.packageDirectory | ||
|
|
||
| func rnWorkletsPackageExists() -> Bool { | ||
| let url = URL(fileURLWithPath: packageDirectory) | ||
| .deletingLastPathComponent() | ||
| .appendingPathComponent("RNWorklets/Package.swift") | ||
| return FileManager.default.fileExists(atPath: url.path) | ||
| } | ||
|
|
||
| let useWorklets = rnWorkletsPackageExists() | ||
|
m-bert marked this conversation as resolved.
|
||
|
|
||
| let reactHeaders: [Target.Dependency] = [ | ||
| .product(name: "ReactHeaders", package: "ReactNative"), | ||
| .product(name: "ReactNativeHeaders", package: "ReactNative"), | ||
| .product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"), | ||
| .product(name: "ReactAppHeaders", package: "React-GeneratedCode"), | ||
| ] | ||
|
|
||
| var packageDependencies: [Package.Dependency] = [ | ||
| .package(name: "ReactNative", path: "../../../../xcframeworks"), | ||
| .package(name: "React-GeneratedCode", path: "../../../ios"), | ||
| ] | ||
|
|
||
| var targetDependencies: [Target.Dependency] = reactHeaders | ||
|
|
||
| if useWorklets { | ||
| packageDependencies.append(.package(name: "RNWorklets", path: "../RNWorklets")) | ||
| targetDependencies.append(.product(name: "RNWorklets", package: "RNWorklets")) | ||
| } | ||
|
|
||
| var cSettings: [CSetting] = [ | ||
| .headerSearchPath("apple"), | ||
| .headerSearchPath("shared/runtime"), | ||
| .headerSearchPath("shared/shadowNodes"), | ||
| .headerSearchPath( | ||
| "shared/shadowNodes/react/renderer/components/rngesturehandler_codegen"), | ||
| .define("DEBUG", .when(configuration: .debug)), | ||
| .define("NDEBUG", .when(configuration: .release)), | ||
| ] | ||
|
|
||
| var cxxSettings: [CXXSetting] = [ | ||
| .headerSearchPath("apple"), | ||
| .headerSearchPath("shared/runtime"), | ||
| .headerSearchPath("shared/shadowNodes"), | ||
| .headerSearchPath( | ||
| "shared/shadowNodes/react/renderer/components/rngesturehandler_codegen"), | ||
| .define("DEBUG", .when(configuration: .debug)), | ||
| .define("NDEBUG", .when(configuration: .release)), | ||
| ] | ||
|
|
||
| if useWorklets { | ||
| cxxSettings.append(.define("RNGH_USE_WORKLETS", to: "1")) | ||
| } | ||
|
|
||
| let package = Package( | ||
|
kacperzolkiewski marked this conversation as resolved.
|
||
| name: "RNGestureHandler", | ||
| platforms: [.iOS(.v15)], | ||
| products: [ | ||
| .library(name: "RNGestureHandler", targets: ["RNGestureHandler"]), | ||
| ], | ||
| dependencies: packageDependencies, | ||
| targets: [ | ||
| .target( | ||
| name: "RNGestureHandler", | ||
| dependencies: targetDependencies, | ||
| path: ".", | ||
| exclude: ["apple/RNGestureHandler.xcodeproj"], | ||
| sources: ["apple", "shared"], | ||
| cSettings: cSettings, | ||
| cxxSettings: cxxSettings, | ||
| linkerSettings: [ | ||
| .linkedFramework("UIKit"), | ||
| .linkedFramework("Foundation"), | ||
| .linkedFramework("CoreGraphics"), | ||
| ] | ||
| ), | ||
| ], | ||
| cxxLanguageStandard: .cxx20 | ||
| ) | ||
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
|
m-bert marked this conversation as resolved.
|
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 @@ | ||
| // Gesture Handler exposes no SPM-facing headers, so Package.swift omits publicHeadersPath. | ||
| // Without publicHeadersPath, SPM defaults to the "include/" directory. | ||
| // We need to provide the "include/" directory so the iOS SPM build succeeds. |
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 |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| module.exports = { | ||
| spm: { | ||
| name: 'RNGestureHandler', | ||
| }, | ||
| dependency: { | ||
| platforms: { | ||
| android: { | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.