diff --git a/package/Package.swift b/package/Package.swift new file mode 100644 index 00000000..84689708 --- /dev/null +++ b/package/Package.swift @@ -0,0 +1,68 @@ +// swift-tools-version: 6.0 +import PackageDescription + +// Swift Package Manager support for React Native's SwiftPM autolinking +// (react-native >= 0.87, `npx react-native spm`). CocoaPods users are unaffected: +// react-native-slider.podspec stays the source of truth there. +// +// The two React Native packages are resolved by the autolinker relative to +// build/generated/autolinking/libs/react-native-slider in the app, as in +// react-native-safe-area-context. They do not resolve in a bare clone. +let package = Package( + name: "react-native-slider", + platforms: [.iOS("15.1")], + products: [ + .library(name: "react-native-slider", targets: ["react-native-slider"]), + ], + dependencies: [ + .package(name: "ReactNative", path: "../../../../xcframeworks"), + .package(name: "React-GeneratedCode", path: "../../../ios"), + ], + targets: [ + .target( + name: "react-native-slider", + dependencies: [ + .product(name: "ReactHeaders", package: "ReactNative"), + .product(name: "ReactNativeHeaders", package: "ReactNative"), + .product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"), + .product(name: "ReactAppHeaders", package: "React-GeneratedCode"), + ], + path: ".", + exclude: [ + "ios/RNCSlider.xcodeproj", + ], + sources: [ + "ios", + "common/cpp", + ], + publicHeadersPath: "ios", + cSettings: [ + .headerSearchPath("ios"), + .headerSearchPath("common/cpp"), + .headerSearchPath("common/cpp/react/renderer/components/RNCSlider"), + ], + cxxSettings: [ + .headerSearchPath("ios"), + .headerSearchPath("common/cpp"), + .headerSearchPath("common/cpp/react/renderer/components/RNCSlider"), + // Same flags the podspec build gets from React Native's CocoaPods setup. + .unsafeFlags([ + "-DFOLLY_NO_CONFIG", + "-DFOLLY_CFG_NO_COROUTINES=1", + "-DFOLLY_MOBILE=1", + "-DFOLLY_USE_LIBCPP=1", + "-DRCT_NEW_ARCH_ENABLED=1", + "-Wno-comma", + "-Wno-shorten-64-to-32", + ]), + .define("DEBUG", .when(configuration: .debug)), + .define("NDEBUG", .when(configuration: .release)), + ], + linkerSettings: [ + .linkedFramework("UIKit"), + .linkedFramework("Foundation"), + ] + ), + ], + cxxLanguageStandard: .cxx20 +) diff --git a/package/ios/RNCSliderComponentView.mm b/package/ios/RNCSliderComponentView.mm index cf14ae6f..a442f81c 100644 --- a/package/ios/RNCSliderComponentView.mm +++ b/package/ios/RNCSliderComponentView.mm @@ -8,10 +8,18 @@ #import #import #import +#if __has_include() +#import +#else #import "RCTImagePrimitivesConversions.h" +#endif #import #import +#if __has_include() +#import +#else #import "RCTFabricComponentsPlugins.h" +#endif #import "RNCSlider.h" using namespace facebook::react; diff --git a/package/package.json b/package/package.json index df8933e3..a8f1c59f 100644 --- a/package/package.json +++ b/package/package.json @@ -77,6 +77,9 @@ "bracketSpacing": false, "jsxBracketSameLine": true }, + "swiftpmConfig": { + "name": "react-native-slider" + }, "codegenConfig": { "name": "RNCSlider", "type": "components",