4
4
import PackageDescription
5
5
let packageName = " PowerSync "
6
6
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
+
7
36
let package = Package (
8
37
name: packageName,
9
38
platforms: [
@@ -18,31 +47,19 @@ let package = Package(
18
47
] ,
19
48
dependencies: [
20
49
. package ( url: " https://github.com/powersync-ja/powersync-sqlite-core-swift.git " , " 0.3.14 " ..< " 0.4.0 " )
21
- ] ,
50
+ ] + conditionalDependencies ,
22
51
targets: [
23
52
// Targets are the basic building blocks of a package, defining a module or a test suite.
24
53
// Targets can depend on other targets in this package and products from dependencies.
25
54
. target(
26
55
name: packageName,
27
56
dependencies: [
28
- . target ( name : " PowerSyncKotlin " ) ,
57
+ kotlinTargetDependency ,
29
58
. product( name: " PowerSyncSQLiteCore " , package : " powersync-sqlite-core-swift " )
30
59
] ) ,
31
60
. testTarget(
32
61
name: " PowerSyncTests " ,
33
62
dependencies: [ " PowerSync " ]
34
63
) ,
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
48
65
)
0 commit comments