44import PackageDescription
55let packageName = " PowerSync "
66
7+ // Set this to the absolute path of your Kotlin SDK checkout if you want to use a local Kotlin
8+ // build. Also see docs/LocalBuild.md for details
9+ let localKotlinSdkOverride : String ? = nil
10+
11+ // Our target and dependency setup is different when a local Kotlin SDK is used. Without the local
12+ // SDK, we have no package dependency on Kotlin and download the XCFramework from Kotlin releases as
13+ // a binary target.
14+ // With a local SDK, we point to a `Package.swift` within the Kotlin SDK containing a target pointing
15+ // towards a local framework build
16+ var conditionalDependencies : [ Package . Dependency ] = [ ]
17+ var conditionalTargets : [ Target ] = [ ]
18+ var kotlinTargetDependency = Target . Dependency. target ( name: " PowerSyncKotlin " )
19+
20+ if let kotlinSdkPath = localKotlinSdkOverride {
21+ // We can't depend on local XCFrameworks outside of this project's root, so there's a Package.swift
22+ // in the PowerSyncKotlin project pointing towards a local build.
23+ conditionalDependencies. append ( . package ( path: " \( kotlinSdkPath) /PowerSyncKotlin " ) )
24+
25+ kotlinTargetDependency = . product( name: " PowerSyncKotlin " , package : " PowerSyncKotlin " )
26+ } else {
27+ // Not using a local build, so download from releases
28+ conditionalTargets. append ( . binaryTarget(
29+ name: " PowerSyncKotlin " ,
30+ // TODO: Use GitHub release once https://github.com/powersync-ja/powersync-kotlin/releases/tag/untagged-fde4386dec502ec27067 is published
31+ url: " https://fsn1.your-objectstorage.com/simon-public/powersync.zip " ,
32+ checksum: " b6770dc22ae31315adc599e653fea99614226312fe861dbd8764e922a5a83b09 "
33+ ) )
34+ }
35+
736let package = Package (
837 name: packageName,
938 platforms: [
@@ -18,31 +47,19 @@ let package = Package(
1847 ] ,
1948 dependencies: [
2049 . package ( url: " https://github.com/powersync-ja/powersync-sqlite-core-swift.git " , " 0.3.14 " ..< " 0.4.0 " )
21- ] ,
50+ ] + conditionalDependencies ,
2251 targets: [
2352 // Targets are the basic building blocks of a package, defining a module or a test suite.
2453 // Targets can depend on other targets in this package and products from dependencies.
2554 . target(
2655 name: packageName,
2756 dependencies: [
28- . target ( name : " PowerSyncKotlin " ) ,
57+ kotlinTargetDependency ,
2958 . product( name: " PowerSyncSQLiteCore " , package : " powersync-sqlite-core-swift " )
3059 ] ) ,
3160 . testTarget(
3261 name: " PowerSyncTests " ,
3362 dependencies: [ " PowerSync " ]
3463 ) ,
35- // If you want to use a local build, comment out this reference and update the other.
36- // See docs/LocalBuild.md
37- . binaryTarget(
38- name: " PowerSyncKotlin " ,
39- // TODO: Use GitHub release once https://github.com/powersync-ja/powersync-kotlin/releases/tag/untagged-fde4386dec502ec27067 is published
40- url: " https://fsn1.your-objectstorage.com/simon-public/powersync.zip " ,
41- checksum: " b6770dc22ae31315adc599e653fea99614226312fe861dbd8764e922a5a83b09 "
42- ) ,
43- // .binaryTarget(
44- // name: "PowerSyncKotlin",
45- // path: "/path/to/powersync-kotlin/PowerSyncKotlin/build/XCFrameworks/debug/PowerSyncKotlin.xcframework"
46- // )
47- ]
64+ ] + conditionalTargets
4865)
0 commit comments