Skip to content

Conversation

stevensJourney
Copy link
Contributor

Overview

This applies the workaround mentioned in #9 for restoring XCode previews.

Context

Currently users are required to enable Use Legacy Previews Execution in order to use XCode's screen preview functionality. The previews fail to load with an error "Failed to launch app [App name] in reasonable time". The diagnostics report provided does not seem to provide any meaningful information to assist with debugging.

PowerSync SPM Package Context

The PowerSync SPM package currently includes a PowerSync library product which uses the default value for the type setting. According to the SPM docs for the type setting:

Creates a library product to allow clients that declare a dependency on this package to use the package's functionality.

A library's product can be either statically or dynamically linked. It's recommended that you don't explicitly declare the type of library, so Swift Package Manager can choose between static or dynamic linking based on the preference of the package's consumer.

We therefore currently support both static and dynamic linking with the PowerSync library product

XCode Previews Context

Some background on how XCode previews are executed can be found here.

It seems like for Previews XCode will build the application as a dynamically linked project. ENABLE_DEBUG_DYLIB_SUPPORT is required for previews to function.

There are multiple potential issue threads on the XCode forums related to Previews not loading:

  • Suggests there might be an issue with running previews when libraries with binaryTargets are loaded statically.
  • Suggests static libraries have known issues with XCode previews

While our SPM package should theoretically allow consumers to specify the linkage type, I could not find any trivial method of configuring the current PowerSync framework as dynamically linked in the XCode project settings. This seems to be a limitation with XCode's SPM integration.

The Fix

The current fix is to add an explicit PowerSyncDynamic library product which forces dynamic linking when added. Adding this to an Xcode project restores the preview functionality without the need for enabling the legacy preview mode.

This product has been configured for out PowerSync example demo. The screen previews now function for our demo.

image

Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@stevensJourney stevensJourney marked this pull request as ready for review August 28, 2025 09:42
@stevensJourney stevensJourney merged commit 4dbaedf into main Aug 28, 2025
4 checks passed
@stevensJourney stevensJourney deleted the previews branch August 28, 2025 09:42
@stevensJourney stevensJourney mentioned this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants