From a02a6bc8e6595004c50d2fa2df765136742cfd2f Mon Sep 17 00:00:00 2001 From: VladyslavMartynov10 Date: Sat, 7 Nov 2026 17:24:16 +0200 Subject: [PATCH 1/4] feat: spm support for rn 0.89 --- Package.swift | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 ++++ 2 files changed, 69 insertions(+) create mode 100644 Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..840a4e18 --- /dev/null +++ b/Package.swift @@ -0,0 +1,65 @@ +// swift-tools-version: 6.0 + +// Swift Package Manager manifest consumed by React Native's SwiftPM autolinking +// (react-native >= 0.88, `npx react-native spm`). CocoaPods keeps using +// RNTrueSheet.podspec and is unaffected. +// +// The autolinker references this package through a symlink at +// /ios/build/generated/autolinking/libs/RNTrueSheet, and SwiftPM resolves +// the relative `.package(path:)` entries below against that symlink, so they +// point at the app's prebuilt React Native and codegen packages. They do not +// resolve in a bare clone of this repository. + +import PackageDescription + +let package = Package( + name: "react-native-true-sheet", + platforms: [.iOS("15.1")], + products: [ + .library(name: "RNTrueSheet", targets: ["RNTrueSheet"]), + ], + dependencies: [ + .package(name: "ReactNative", path: "../../../../xcframeworks"), + .package(name: "React-GeneratedCode", path: "../../../ios"), + ], + targets: [ + .target( + name: "RNTrueSheet", + dependencies: [ + .product(name: "ReactHeaders", package: "ReactNative"), + .product(name: "ReactNativeHeaders", package: "ReactNative"), + .product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"), + .product(name: "ReactAppHeaders", package: "React-GeneratedCode"), + ], + path: ".", + // tvOS builds stubs only (see the podspec); SwiftPM autolinking targets iOS. + exclude: ["ios/tvos"], + sources: ["ios", "common/cpp"], + publicHeadersPath: "ios", + cSettings: [ + .define("RCT_NEW_ARCH_ENABLED", to: "1"), + .headerSearchPath("ios"), + .headerSearchPath("ios/core"), + .headerSearchPath("ios/events"), + .headerSearchPath("ios/utils"), + .headerSearchPath("common/cpp"), + ], + cxxSettings: [ + .define("RCT_NEW_ARCH_ENABLED", to: "1"), + // Must match the prebuilt React.framework's config-gated C++ ABI. + .define("DEBUG", .when(configuration: .debug)), + .define("NDEBUG", .when(configuration: .release)), + .headerSearchPath("ios"), + .headerSearchPath("ios/core"), + .headerSearchPath("ios/events"), + .headerSearchPath("ios/utils"), + .headerSearchPath("common/cpp"), + ], + linkerSettings: [ + .linkedFramework("UIKit"), + .linkedFramework("Foundation"), + ] + ), + ], + cxxLanguageStandard: .cxx20 +) diff --git a/package.json b/package.json index fb19b3ff..277a5add 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "ios", "common", "*.podspec", + "Package.swift", "react-native.config.js", "!ios/build", "!android/build", @@ -308,5 +309,8 @@ } } } + }, + "swiftpmConfig": { + "name": "RNTrueSheet" } } From 0975dddca80dd808efe8bed3be241469a56287d2 Mon Sep 17 00:00:00 2001 From: VladyslavMartynov10 Date: Sat, 7 Nov 2026 17:36:10 +0200 Subject: [PATCH 2/4] chore: changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0b51ec5..186d2a68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### 🎉 New features + +- **iOS**: Added Swift Package Manager support for React Native's SwiftPM mode (react-native 0.88 and later, `npx react-native spm`). The package now ships a `Package.swift`, so apps built without CocoaPods autolink TrueSheet without scaffolding a manifest. CocoaPods is unchanged. ([#1013](https://github.com/lodev09/react-native-true-sheet/pull/1013) by [@VladyslavMartynov10](https://github.com/VladyslavMartynov10)) + ### 🐛 Bug fixes - **Android**: A sheet whose keyboard starts rising as the present slide ends, such as one that focuses an input around `onWillPresent`, now finishes presenting. It used to never fire `onDidPresent` or resolve `present()`, and kept swallowing taps. ([#1012](https://github.com/lodev09/react-native-true-sheet/pull/1012) by [@JacquesLeupin](https://github.com/JacquesLeupin)) From bc1f00ef50fc1963111e193a1912d945b4456fb9 Mon Sep 17 00:00:00 2001 From: Jovanni Lo Date: Mon, 16 Nov 2026 22:52:21 +0800 Subject: [PATCH 3/4] fix(ios): keep the screens integration under SwiftPM Resolve the react-native-screens protocol header at the path SwiftPM exposes it. List the header search paths once in Package.swift, name the package RNTrueSheet and link CoreGraphics. --- AGENTS.md | 4 ++++ Package.swift | 24 +++++++++--------------- ios/TrueSheetViewController.h | 4 ++++ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index af8ee3c0..9b3d3037 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -70,6 +70,10 @@ Both platforms: `TrueSheetView` (hidden host) → Controller → `ContainerView` 2. Create event class in `ios/events/` and `android/.../events/` 3. Emit from native view +### Adding an iOS source folder + +`RNTrueSheet.podspec` (CocoaPods) and `Package.swift` (SwiftPM) both build `ios/` and `common/cpp/`. CocoaPods flattens headers and SwiftPM does not, so add any new folder that holds headers to `headerSearchPaths` in `Package.swift`. CI only builds CocoaPods, so a missing entry breaks SwiftPM apps silently. + ### Updating the AI skill `skills/truesheet-usage/` is the consumer-facing skill installed via `npx skills add lodev09/react-native-true-sheet`. Whenever docs under `docs/content/docs/next/` change (new prop, event, method, guide, limitation, or troubleshooting entry), update the skill to match in the same PR: diff --git a/Package.swift b/Package.swift index 840a4e18..17d49796 100644 --- a/Package.swift +++ b/Package.swift @@ -12,8 +12,12 @@ import PackageDescription +// CocoaPods flattens a pod's headers into one directory and SwiftPM does not, +// so every folder that holds headers must be listed here. +let headerSearchPaths = ["ios", "ios/core", "ios/events", "ios/utils", "common/cpp"] + let package = Package( - name: "react-native-true-sheet", + name: "RNTrueSheet", platforms: [.iOS("15.1")], products: [ .library(name: "RNTrueSheet", targets: ["RNTrueSheet"]), @@ -36,28 +40,18 @@ let package = Package( exclude: ["ios/tvos"], sources: ["ios", "common/cpp"], publicHeadersPath: "ios", - cSettings: [ - .define("RCT_NEW_ARCH_ENABLED", to: "1"), - .headerSearchPath("ios"), - .headerSearchPath("ios/core"), - .headerSearchPath("ios/events"), - .headerSearchPath("ios/utils"), - .headerSearchPath("common/cpp"), - ], + cSettings: [.define("RCT_NEW_ARCH_ENABLED", to: "1")] + + headerSearchPaths.map { CSetting.headerSearchPath($0) }, cxxSettings: [ .define("RCT_NEW_ARCH_ENABLED", to: "1"), // Must match the prebuilt React.framework's config-gated C++ ABI. .define("DEBUG", .when(configuration: .debug)), .define("NDEBUG", .when(configuration: .release)), - .headerSearchPath("ios"), - .headerSearchPath("ios/core"), - .headerSearchPath("ios/events"), - .headerSearchPath("ios/utils"), - .headerSearchPath("common/cpp"), - ], + ] + headerSearchPaths.map { CXXSetting.headerSearchPath($0) }, linkerSettings: [ .linkedFramework("UIKit"), .linkedFramework("Foundation"), + .linkedFramework("CoreGraphics"), ] ), ], diff --git a/ios/TrueSheetViewController.h b/ios/TrueSheetViewController.h index a4c7c22e..a6647b7a 100644 --- a/ios/TrueSheetViewController.h +++ b/ios/TrueSheetViewController.h @@ -14,6 +14,10 @@ #if __has_include() #import #define RNS_DISMISSIBLE_MODAL_PROTOCOL_AVAILABLE 1 +// SwiftPM does not flatten headers: react-native-screens is exposed under its package paths +#elif __has_include() +#import +#define RNS_DISMISSIBLE_MODAL_PROTOCOL_AVAILABLE 1 #else #define RNS_DISMISSIBLE_MODAL_PROTOCOL_AVAILABLE 0 #endif From 4f82a580abe8e0b3e793c1fae4147337b71d94d8 Mon Sep 17 00:00:00 2001 From: Jovanni Lo Date: Mon, 16 Nov 2026 22:52:22 +0800 Subject: [PATCH 4/4] docs: add SwiftPM install note and update changelog entry for #1013 --- CHANGELOG.md | 2 +- README.md | 2 ++ docs/content/docs/next/install.mdx | 2 ++ skills/truesheet-usage/SKILL.md | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 186d2a68..c13397f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### 🎉 New features -- **iOS**: Added Swift Package Manager support for React Native's SwiftPM mode (react-native 0.88 and later, `npx react-native spm`). The package now ships a `Package.swift`, so apps built without CocoaPods autolink TrueSheet without scaffolding a manifest. CocoaPods is unchanged. ([#1013](https://github.com/lodev09/react-native-true-sheet/pull/1013) by [@VladyslavMartynov10](https://github.com/VladyslavMartynov10)) +- **iOS**: Added Swift Package Manager support for apps using React Native's SwiftPM setup (`npx react-native spm`, React Native 0.88 and later). CocoaPods is unchanged. ([#1013](https://github.com/lodev09/react-native-true-sheet/pull/1013) by [@VladyslavMartynov10](https://github.com/VladyslavMartynov10) and [@lodev09](https://github.com/lodev09)) ### 🐛 Bug fixes diff --git a/README.md b/README.md index 057971e2..df10a43f 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ yarn add @lodev09/react-native-true-sheet cd ios && pod install ``` +On apps using React Native's Swift Package Manager setup (React Native 0.88+), run `npx react-native spm` instead of `pod install`. + ## Documentation - [Example](example) diff --git a/docs/content/docs/next/install.mdx b/docs/content/docs/next/install.mdx index 8d5af9ee..94046ee4 100644 --- a/docs/content/docs/next/install.mdx +++ b/docs/content/docs/next/install.mdx @@ -45,3 +45,5 @@ Then install the native dependencies: ```sh cd ios && pod install ``` + +On apps using React Native's Swift Package Manager setup (React Native 0.88+), run `npx react-native spm` instead of `pod install`. diff --git a/skills/truesheet-usage/SKILL.md b/skills/truesheet-usage/SKILL.md index 086be933..f5406cf0 100644 --- a/skills/truesheet-usage/SKILL.md +++ b/skills/truesheet-usage/SKILL.md @@ -15,7 +15,7 @@ description: >- Use this skill to produce correct, idiomatic code for apps that consume `@lodev09/react-native-true-sheet` (v4). It covers choosing the right integration pattern, applying the public API correctly, and avoiding platform-specific pitfalls. -Requires React Native >= 0.82 (Expo SDK 55+) with the New Architecture. +Requires React Native >= 0.82 (Expo SDK 55+) with the New Architecture. On iOS it links through CocoaPods (`pod install`) or React Native's Swift Package Manager setup (`npx react-native spm`, RN 0.88+). ## Quick Start