Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/little-spiders-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/react-native': minor
---

Add experimental support for Swift Package Manager builds (requires React Native version 0.87.0 or later).
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ dist
.DS_STORE
.idea
.fleet
.build
packages/react-native/ios/Package.resolved

# TanStack Router generated files
routeTree.gen.ts
Expand Down
30 changes: 30 additions & 0 deletions packages/react-native/ios/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// swift-tools-version: 6.0
import PackageDescription

// When updating this, also update the version in powersync-react-native.podspec and android/build.gradle
let coreExtensionVersion: Version = "0.5.2"

let packageName = "PowerSyncReactNative"

let package = Package(
name: packageName,
platforms: [.iOS(.v15)],
products: [
.library(name: packageName, targets: [packageName])
],
dependencies: [
.package(
url: "https://github.com/powersync-ja/powersync-sqlite-core-swift.git",
exact: coreExtensionVersion
)
],
targets: [
.target(
name: packageName,
dependencies: [
.product(name: "PowerSyncSQLiteCore", package: "powersync-sqlite-core-swift")
],
path: "swiftpm"
)
],
)
2 changes: 2 additions & 0 deletions packages/react-native/ios/swiftpm/empty.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Deliberately left empty: We need a SwiftPM target with sources, but the only responsibility of
// the build is to link the core extension.
Comment thread
simolus3 marked this conversation as resolved.
Resolved
5 changes: 3 additions & 2 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"src",
"android",
"ios",
"*.podspec"
"*.podspec",
"react-native.config.js"
],
"scripts": {
"build": "tsc -b",
Expand All @@ -35,7 +36,7 @@
},
"homepage": "https://docs.powersync.com/",
"peerDependencies": {
"@op-engineering/op-sqlite": "^17.1.0",
"@op-engineering/op-sqlite": ">=17.1.0 <19.0.0",
"@powersync/common": "workspace:^2.1.0",
"react": "*",
"react-native": "*"
Expand Down
1 change: 1 addition & 0 deletions packages/react-native/powersync-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Pod::Spec.new do |s|

s.dependency "React-callinvoker"
s.dependency "React"
# When updating this, also update the version in Package.swift and android/build.gradle
s.dependency "powersync-sqlite-core", "~> 0.5.2"
if defined?(install_modules_dependencies())
install_modules_dependencies(s)
Expand Down
13 changes: 13 additions & 0 deletions packages/react-native/react-native.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Hack: @react-native-community/cli reads this file with import(), while react-native/scripts/spm/expand-spm-dependencies.js
// reads it using require(). Both are able to read this file, but in the require case we need to return the spm key we
// care about as a separate item because it otherwise gets exported as {default: ...} object.
export const spm = {
// Change the Swift Package name and target autolinking expects for this npm package. By default, it would use
// 'ReactNative' which conflicts with RN itself.
// This option appears to be undocumented, it's read here: https://github.com/react/react-native/blob/2dd6d4b482c2512d3e92fbaf0a10a9f8ac055e5d/packages/react-native/scripts/spm/expand-spm-dependencies.js#L59-L82
name: 'PowerSyncReactNative'
};

export default {
spm
};
1,958 changes: 900 additions & 1,058 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ catalog:
'@nuxt/devtools-kit': ^3.2.3
'@nuxt/devtools-ui-kit': ^3.2.3
'@nuxt/test-utils': ^4.0.3
'@op-engineering/op-sqlite': ^17.1.0
'@op-engineering/op-sqlite': ^18.1.1
'@pnpm/workspace.find-packages': ^1000.0.55
'@pnpm/workspace.read-manifest': ^1000.2.9
'@rollup/plugin-alias': ^5.1.0
Expand Down Expand Up @@ -82,3 +82,4 @@ trustPolicyExclude:
minimumReleaseAgeExclude:
- '@journeyapps/*'
- '@powersync/*'
- '@op-engineering/op-sqlite@18.1.1'
2 changes: 1 addition & 1 deletion tools/powersynctests/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ android {
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import com.facebook.soloader.SoLoader
class MainApplication : Application(), ReactApplication {

override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
object : DefaultReactNativeHost(this@MainApplication) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
PackageList(this@MainApplication).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
}
Expand Down
2 changes: 1 addition & 1 deletion tools/powersynctests/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
compileSdkVersion = 35
targetSdkVersion = 35
ndkVersion = "27.1.12297006"
kotlinVersion = "2.0.21"
kotlinVersion = "2.2.0"
}
repositories {
google()
Expand Down
5 changes: 5 additions & 0 deletions tools/powersynctests/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true

# Opt out of built-in kotlin and new DSL behavior that ships with AGP 9.
# Starting from AGP 10.x these opt outs will be removed.
android.builtInKotlin=false
android.newDsl=false

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 6 additions & 0 deletions tools/powersynctests/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# SPM – auto-generated at build time (do not commit)
Package.resolved
build/generated/
build/xcframeworks/
.build/
178 changes: 178 additions & 0 deletions tools/powersynctests/ios/powersynctests.xcodeproj/.spm-injected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"rootUuid": "83CBB9F71A601CBA00E9B192",
"target": "powersynctests",
"targetUuid": "13B07F861A680F5B00A75B9A",
"injectedUuids": [
"17CA21E30A8FFCB9D0FC1E35",
"27BDE9D743CB351F53154525",
"3AFDEFB917B01458307FDE0A",
"3F1E298E4A2D7CA403A328B5",
"50A8621D202A6CFB97E2C1B5",
"512EBECF5434FD7A6AF7C967",
"658A88AFBFD620F8BC6F91BA",
"69A7AB74931112BD2779B631",
"8332BE36B9C49BD2E49347C1",
"920F69A9DF98D37C8308D020",
"947DD5EF3BE079FB7F5AFF87",
"94F7C9B714A718310DA6BE9C",
"A700952B9A737913514EB28F",
"B174F870C259554596A4373B",
"C2FECF1430FDAAE3BF355839",
"D6BD17EA9023C9F39246B71F",
"F3857EDDA38AFC0011322D6D"
],
"createdArrayFields": [],
"buildSettingChanges": [
{
"configUuid": "13B07F941A680F5B00A75B9A",
"createdArrayKeys": [
"HEADER_SEARCH_PATHS",
"FRAMEWORK_SEARCH_PATHS"
],
"appendedArrayValues": {
"OTHER_LDFLAGS": [
"\"$(RN_SPM_REACT_BINARY)\"",
"\"$(RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY)\"",
"\"$(RN_SPM_HERMES_BINARY)\""
]
},
"createdScalars": [
"CLANG_CXX_LANGUAGE_STANDARD",
"REACT_NATIVE_PATH",
"HERMES_CLI_PATH",
"RN_SPM_FLAVOR",
"\"RN_SPM_REACT_FRAMEWORK[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_BINARY[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_SEARCH_PATH[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_FRAMEWORK[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_BINARY[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_SEARCH_PATH[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_FRAMEWORK[sdk=macosx*]\"",
"\"RN_SPM_REACT_BINARY[sdk=macosx*]\"",
"\"RN_SPM_REACT_SEARCH_PATH[sdk=macosx*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=appletvos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=appletvos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=appletvos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=appletvsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=appletvsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=appletvsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=macosx*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=macosx*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=macosx*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=xros*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=xros*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=xros*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=xrsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=xrsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=xrsimulator*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=appletvos*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=appletvos*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=appletvos*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=appletvsimulator*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=appletvsimulator*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=appletvsimulator*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=iphoneos*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=iphoneos*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=iphoneos*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=iphonesimulator*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=iphonesimulator*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=iphonesimulator*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=macosx*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=macosx*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=macosx*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=xros*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=xros*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=xros*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=xrsimulator*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=xrsimulator*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=xrsimulator*]\""
],
"replacedScalars": {}
},
{
"configUuid": "13B07F951A680F5B00A75B9A",
"createdArrayKeys": [
"HEADER_SEARCH_PATHS",
"FRAMEWORK_SEARCH_PATHS"
],
"appendedArrayValues": {
"OTHER_LDFLAGS": [
"\"$(RN_SPM_REACT_BINARY)\"",
"\"$(RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY)\"",
"\"$(RN_SPM_HERMES_BINARY)\""
]
},
"createdScalars": [
"CLANG_CXX_LANGUAGE_STANDARD",
"REACT_NATIVE_PATH",
"HERMES_CLI_PATH",
"RN_SPM_FLAVOR",
"\"RN_SPM_REACT_FRAMEWORK[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_BINARY[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_SEARCH_PATH[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_FRAMEWORK[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_BINARY[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_SEARCH_PATH[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_FRAMEWORK[sdk=macosx*]\"",
"\"RN_SPM_REACT_BINARY[sdk=macosx*]\"",
"\"RN_SPM_REACT_SEARCH_PATH[sdk=macosx*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=appletvos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=appletvos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=appletvos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=appletvsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=appletvsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=appletvsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=iphoneos*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=iphonesimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=macosx*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=macosx*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=macosx*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=xros*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=xros*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=xros*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_FRAMEWORK[sdk=xrsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_BINARY[sdk=xrsimulator*]\"",
"\"RN_SPM_REACT_NATIVE_DEPENDENCIES_SEARCH_PATH[sdk=xrsimulator*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=appletvos*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=appletvos*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=appletvos*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=appletvsimulator*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=appletvsimulator*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=appletvsimulator*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=iphoneos*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=iphoneos*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=iphoneos*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=iphonesimulator*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=iphonesimulator*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=iphonesimulator*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=macosx*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=macosx*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=macosx*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=xros*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=xros*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=xros*]\"",
"\"RN_SPM_HERMES_FRAMEWORK[sdk=xrsimulator*]\"",
"\"RN_SPM_HERMES_BINARY[sdk=xrsimulator*]\"",
"\"RN_SPM_HERMES_SEARCH_PATH[sdk=xrsimulator*]\""
],
"replacedScalars": {}
}
],
"generatedSources": {},
"artifactsVersionOverride": null,
"configCommand": null,
"scheme": {
"file": "powersynctests.xcscheme",
"created": false
}
}
Loading
Loading