Skip to content

Commit 4dbaedf

Browse files
XCode Previews (#71)
* Update Demo Screens for Previews. Add forced dynamic product. * Add Readme note * Add changelog * update tests
1 parent 872a269 commit 4dbaedf

File tree

8 files changed

+34
-8
lines changed

8 files changed

+34
-8
lines changed

.github/workflows/build_and_test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
xcode-version: latest-stable
1717
- name: Build and Test
1818
run: |
19-
xcodebuild test -scheme PowerSync -destination "platform=iOS Simulator,name=iPhone 16"
20-
xcodebuild test -scheme PowerSync -destination "platform=macOS,arch=arm64,name=My Mac"
21-
xcodebuild test -scheme PowerSync -destination "platform=watchOS Simulator,arch=arm64,name=Apple Watch Ultra 2 (49mm)"
19+
xcodebuild test -scheme PowerSync-Package -destination "platform=iOS Simulator,name=iPhone 16"
20+
xcodebuild test -scheme PowerSync-Package -destination "platform=macOS,arch=arm64,name=My Mac"
21+
xcodebuild test -scheme PowerSync-Package -destination "platform=watchOS Simulator,arch=arm64,name=Apple Watch Ultra 2 (49mm)"
2222
2323
buildSwift6:
2424
name: Build and test with Swift 6

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
* *Potential Breaking Change*: Attachment helpers have been updated to better support Swift 6 strict concurrency checking. `Actor` isolation is improved, but developers who customize or extend `AttachmentQueue` will need to update their implementations. The default instantiation of `AttachmentQueue` remains unchanged.
1212
`AttachmentQueueProtocol` now defines the basic requirements for an attachment queue, with most base functionality provided via an extension. Custom implementations should extend `AttachmentQueueProtocol`.
13+
* Added `PowerSyncDynamic` product to package. Importing this product should restore XCode preview functionality.
1314
* [Internal] Instantiate Kotlin Kermit logger directly.
1415
* [Internal] Improved connection context error handling.
1516

Demo/PowerSyncExample.xcodeproj/project.pbxproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
B666587C2C63B88700159A81 /* SwiftUINavigationCore in Frameworks */ = {isa = PBXBuildFile; productRef = B666587B2C63B88700159A81 /* SwiftUINavigationCore */; };
4040
B69F7D862C8EE27400565448 /* AnyCodable in Frameworks */ = {isa = PBXBuildFile; productRef = B69F7D852C8EE27400565448 /* AnyCodable */; };
4141
B6B3698A2C64F4B30033C307 /* Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6B369892C64F4B30033C307 /* Navigation.swift */; };
42-
B6FFD5322D06DA8000EEE60F /* PowerSync in Frameworks */ = {isa = PBXBuildFile; productRef = B6FFD5312D06DA8000EEE60F /* PowerSync */; };
4342
BE2F26EC2DA54B2F0080F1AE /* SupabaseRemoteStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE2F26EB2DA54B2A0080F1AE /* SupabaseRemoteStorage.swift */; };
43+
BEDBE19C2E5F0299004E1AB5 /* PowerSyncDynamic in Frameworks */ = {isa = PBXBuildFile; productRef = BEDBE19B2E5F0299004E1AB5 /* PowerSyncDynamic */; };
44+
BEDBE19D2E5F0299004E1AB5 /* PowerSyncDynamic in Embed Frameworks */ = {isa = PBXBuildFile; productRef = BEDBE19B2E5F0299004E1AB5 /* PowerSyncDynamic */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
4445
BEE4708B2E3BBB2500140D11 /* Secrets.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEE4708A2E3BBB2500140D11 /* Secrets.swift */; };
4546
/* End PBXBuildFile section */
4647

@@ -51,6 +52,7 @@
5152
dstPath = "";
5253
dstSubfolderSpec = 10;
5354
files = (
55+
BEDBE19D2E5F0299004E1AB5 /* PowerSyncDynamic in Embed Frameworks */,
5456
);
5557
name = "Embed Frameworks";
5658
runOnlyForDeploymentPostprocessing = 0;
@@ -120,11 +122,11 @@
120122
B66658772C63B7BB00159A81 /* IdentifiedCollections in Frameworks */,
121123
B69F7D862C8EE27400565448 /* AnyCodable in Frameworks */,
122124
B666587C2C63B88700159A81 /* SwiftUINavigationCore in Frameworks */,
123-
B6FFD5322D06DA8000EEE60F /* PowerSync in Frameworks */,
124125
6A9669022B9EE69500B05DCF /* Supabase in Frameworks */,
125126
6A9669002B9EE4FE00B05DCF /* PostgREST in Frameworks */,
126127
6A9668FE2B9EE4FE00B05DCF /* Auth in Frameworks */,
127128
B666587A2C63B88700159A81 /* SwiftUINavigation in Frameworks */,
129+
BEDBE19C2E5F0299004E1AB5 /* PowerSyncDynamic in Frameworks */,
128130
);
129131
runOnlyForDeploymentPostprocessing = 0;
130132
};
@@ -487,7 +489,7 @@
487489
B66658792C63B88700159A81 /* SwiftUINavigation */,
488490
B666587B2C63B88700159A81 /* SwiftUINavigationCore */,
489491
B69F7D852C8EE27400565448 /* AnyCodable */,
490-
B6FFD5312D06DA8000EEE60F /* PowerSync */,
492+
BEDBE19B2E5F0299004E1AB5 /* PowerSyncDynamic */,
491493
);
492494
productName = PowerSyncExample;
493495
productReference = 6A7315842B9854220004CB17 /* PowerSyncExample.app */;
@@ -885,10 +887,10 @@
885887
package = B69F7D842C8EE27300565448 /* XCRemoteSwiftPackageReference "AnyCodable" */;
886888
productName = AnyCodable;
887889
};
888-
B6FFD5312D06DA8000EEE60F /* PowerSync */ = {
890+
BEDBE19B2E5F0299004E1AB5 /* PowerSyncDynamic */ = {
889891
isa = XCSwiftPackageProductDependency;
890892
package = 18F30B282CCA4B3B00A58917 /* XCLocalSwiftPackageReference "../../powersync-swift" */;
891-
productName = PowerSync;
893+
productName = PowerSyncDynamic;
892894
};
893895
/* End XCSwiftPackageProductDependency section */
894896
};

Demo/PowerSyncExample/Screens/HomeScreen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ struct HomeScreen: View {
3333
NavigationStack{
3434
HomeScreen()
3535
.environment(SystemManager())
36+
.environment(NavigationModel())
3637
}
3738
}

Demo/PowerSyncExample/Screens/SignInScreen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ struct SignInScreen: View {
7878
NavigationStack {
7979
SignInScreen()
8080
.environment(SystemManager())
81+
.environment(NavigationModel())
8182
}
8283
}

Demo/PowerSyncExample/Screens/SignUpScreen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ struct SignUpScreen: View {
7878
NavigationStack {
7979
SignUpScreen()
8080
.environment(SystemManager())
81+
.environment(NavigationModel())
8182
}
8283
}

Package.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ let package = Package(
6161
.library(
6262
name: packageName,
6363
targets: ["PowerSync"]
64+
),
65+
.library(
66+
name: "\(packageName)Dynamic",
67+
// The default value normally specifies that the library is compatible with both static and dynamic linking,
68+
// where the value used is typically specified by the consumer - which is usually defaulted to static linking.
69+
// It's not straight forward to configure the linking option used by XCode consumers - specifying
70+
// this additional product allows consumers to add it to their project, forcing dynamic linking.
71+
// Dynamic linking is particularly important for XCode previews.
72+
type: .dynamic,
73+
targets: ["PowerSync"]
6474
)
6575
],
6676
dependencies: conditionalDependencies,

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,13 @@ For more details, see the [Swift SDK reference](https://docs.powersync.com/clien
8080
## Attachments
8181

8282
See the attachments [README](./Sources/PowerSync/attachments/README.md) for more information.
83+
84+
## XCode Previews
85+
86+
XCode previews currently fail to load in a reasonable time after adding PowerSync to an XCode project. XCode requires dynamic linking for previews. This is enabled by enabling `ENABLE_DEBUG_DYLIB` in the XCode project. It seems like the previews fail to load due to PowerSync providing a `binaryTarget` which is linked statically by default.
87+
88+
XCode previews can be enabled by either:
89+
90+
Enabling `Editor -> Canvas -> Use Legacy Previews Execution` in XCode.
91+
92+
Or adding the `PowerSyncDynamic` product when adding PowerSync to your project. This product will assert that PowerSync should be dynamically linked, which restores XCode previews.

0 commit comments

Comments
 (0)