diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..ccf397a --- /dev/null +++ b/Package.swift @@ -0,0 +1,58 @@ +// swift-tools-version: 6.0 + +import Foundation +import PackageDescription + +// React Native resolves this package through build/generated/autolinking/libs/Ease. +let usedRootEntries: Set = ["ios", "spm-headers", "Package.swift"] +let unusedRootEntries = try! FileManager.default.contentsOfDirectory(atPath: Context.packageDirectory) + .filter { !usedRootEntries.contains($0) } + .sorted() +let iosProjects = try! FileManager.default.contentsOfDirectory( + atPath: Context.packageDirectory + "/ios" +).filter { $0.hasSuffix(".xcodeproj") }.map { "ios/" + $0 } + +let package = Package( + name: "Ease", + platforms: [.iOS("15.1")], + products: [ + .library(name: "Ease", targets: ["Ease"]), + ], + dependencies: [ + .package(name: "ReactNative", path: "../../../../xcframeworks"), + .package(name: "React-GeneratedCode", path: "../../../ios"), + ], + targets: [ + .target( + name: "Ease", + dependencies: [ + .product(name: "ReactHeaders", package: "ReactNative"), + .product(name: "ReactNativeHeaders", package: "ReactNative"), + .product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"), + .product(name: "ReactAppHeaders", package: "React-GeneratedCode"), + ], + path: ".", + exclude: unusedRootEntries + iosProjects, + sources: ["ios"], + publicHeadersPath: "ios", + cSettings: [ + .define("RCT_NEW_ARCH_ENABLED", to: "1"), + .headerSearchPath("spm-headers"), + .define("DEBUG", .when(configuration: .debug)), + .define("NDEBUG", .when(configuration: .release)), + ], + cxxSettings: [ + .define("RCT_NEW_ARCH_ENABLED", to: "1"), + .headerSearchPath("spm-headers"), + .define("DEBUG", .when(configuration: .debug)), + .define("NDEBUG", .when(configuration: .release)), + ], + linkerSettings: [ + .linkedFramework("UIKit"), + .linkedFramework("Foundation"), + .linkedFramework("CoreGraphics"), + ] + ), + ], + cxxLanguageStandard: .cxx20 +) diff --git a/README.md b/README.md index 8273138..d5d70e5 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,12 @@ npm install react-native-ease yarn add react-native-ease ``` +### Swift Package Manager (iOS) + +The package includes a `Package.swift` for apps that use Swift Package Manager instead of CocoaPods (React Native 0.88 or newer). An app moves to Swift Package Manager with `npx react-native spm add`. After that, React Native links this package automatically, and no extra step is needed. + +The Swift Package Manager setup supports iOS only. On tvOS, use CocoaPods. + ### Migration Skill If you're already using `react-native-reanimated` or React Native's `Animated` API, this project includes an [Agent Skill](https://agentskills.io) that scans your codebase for animations that can be replaced with `react-native-ease` and migrates them automatically. diff --git a/package.json b/package.json index 248a309..74b96e3 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,8 @@ "./package.json": "./package.json" }, "files": [ + "Package.swift", + "spm-headers", "src", "lib", "android", @@ -211,5 +213,8 @@ "release-it" ], "version": "0.57.2" + }, + "swiftpmConfig": { + "name": "Ease" } } diff --git a/spm-headers/RCTFabricComponentsPlugins.h b/spm-headers/RCTFabricComponentsPlugins.h new file mode 100644 index 0000000..04d7750 --- /dev/null +++ b/spm-headers/RCTFabricComponentsPlugins.h @@ -0,0 +1 @@ +#import