Skip to content

Commit 552204a

Browse files
committed
Enable macOS support
1 parent 5136934 commit 552204a

File tree

17 files changed

+35
-24
lines changed

17 files changed

+35
-24
lines changed

PowerSyncKotlin/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ kotlin {
1919
iosX64(),
2020
iosArm64(),
2121
iosSimulatorArm64(),
22+
macosArm64(),
23+
macosX64(),
2224
).forEach {
2325
it.binaries.framework {
2426
export(project(":core"))
File renamed without changes.

compose/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ kotlin {
1919
iosX64()
2020
iosArm64()
2121
iosSimulatorArm64()
22+
macosArm64()
23+
macosX64()
2224

2325
explicitApi()
2426

File renamed without changes.

connectors/supabase/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ kotlin {
2727
iosX64()
2828
iosArm64()
2929
iosSimulatorArm64()
30+
macosArm64()
31+
macosX64()
3032

3133
explicitApi()
3234

core/build.gradle.kts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ kotlin {
156156
iosX64()
157157
iosArm64()
158158
iosSimulatorArm64()
159+
macosX64()
160+
macosArm64()
159161

160162
targets.withType<KotlinNativeTarget> {
161163
compilations.named("main") {
@@ -184,16 +186,6 @@ kotlin {
184186
linkerOpts("-rpath", frameworkRoot)
185187
}
186188
}
187-
/*
188-
If we ever need macOS support:
189-
{
190-
binaries.withType<TestExecutable>().configureEach {
191-
linkTaskProvider.dependsOn(downloadPowersyncDesktopBinaries)
192-
linkerOpts("-lpowersync")
193-
linkerOpts("-L", binariesFolder.map { it.dir("powersync") }.get().asFile.path)
194-
}
195-
}
196-
*/
197189
}
198190

199191
explicitApi()
@@ -234,7 +226,7 @@ kotlin {
234226
implementation(libs.sqlite.jdbc)
235227
}
236228

237-
iosMain.dependencies {
229+
appleMain.dependencies {
238230
implementation(libs.ktor.client.ios)
239231
}
240232

@@ -248,11 +240,12 @@ kotlin {
248240
}
249241

250242
// We're putting the native libraries into our JAR, so integration tests for the JVM can run as part of the unit
251-
// tests.
252-
jvmTest.get().dependsOn(commonIntegrationTest)
253-
254-
// We're linking the xcframework for the simulator tests, so they can use integration tests too
255-
iosSimulatorArm64Test.orNull?.dependsOn(commonIntegrationTest)
243+
// tests. For iOS and macOS targets, we're linking the xcframework into the test executable, so they can use
244+
// integration tests too.
245+
val canRunIntegrationTestsAsUnitTest = listOf(jvmTest, appleTest)
246+
canRunIntegrationTestsAsUnitTest.forEach {
247+
it.orNull?.dependsOn(commonIntegrationTest)
248+
}
256249
}
257250
}
258251

File renamed without changes.

core/src/iosMain/kotlin/com/powersync/DatabaseDriverFactory.ios.kt renamed to core/src/appleMain/kotlin/com/powersync/DatabaseDriverFactory.apple.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ public actual class DatabaseDriverFactory {
2525
private var driver: PsSqlDriver? = null
2626

2727
init {
28-
init_powersync_sqlite_extension()
28+
val result = init_powersync_sqlite_extension()
29+
println("load result $result")
30+
if (result != 0) {
31+
throw IllegalStateException("Could not load PowerSync extension, status code $result")
32+
}
2933
}
3034

3135
@Suppress("unused", "UNUSED_PARAMETER")
File renamed without changes.

core/src/commonIntegrationTest/kotlin/com/powersync/DatabaseTest.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ class DatabaseTest {
1515

1616
@BeforeTest
1717
fun setupDatabase() {
18-
database =
19-
PowerSyncDatabase(
20-
factory = com.powersync.testutils.factory,
21-
schema = Schema(UserRow.table),
22-
dbFilename = "testdb",
23-
)
18+
println("Setup")
19+
try {
20+
database =
21+
PowerSyncDatabase(
22+
factory = com.powersync.testutils.factory,
23+
schema = Schema(UserRow.table),
24+
dbFilename = "testdb",
25+
)
26+
} catch (e: Throwable) {
27+
println("Initialization failed: $e")
28+
}
2429

30+
println("Setup done")
2531
runBlocking {
2632
database.disconnectAndClear(true)
2733
}

0 commit comments

Comments
 (0)