Skip to content

Fix symlinks in generated XCFramework #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented May 2, 2025

The kmmbridge Gradle plugin uses a Gradle Zip task to create a .zip archive of an XCFramework directory for the compiled Kotlin code.

On macOS, the layout of an XCFramework typically looks like this:

PowerSyncKotlin.xcframework/
├─ macos-arm64_x86_64/
│  ├─ Versions/
│  │  ├─ A/
│  │  │  ├─ .../
│  │  ├─ Current/    (symlink to ./A)

However, the Gradle Zip task does not support preserving symlinks when creating zip files. Instead, these files are copied into the uploaded archive. It looks like XCode is not consistently fine with this, sometimes attempting to readlink the Current/ directory in the xcframework even when it is a regular directory. This fails, breaking macOS builds.

This PR applies a hack to the publishing logic for the :PowerSyncKotlin project that will delete the archive created by Gradle only to re-create it with a zip invocation (we can't replace the task because it's created by the KMMBridge plugin). That allows using this project in macOS apps built with Swift.

I've tested this by changing Package.swift here, replacing the path for the binary target with the created archive:

.binaryTarget(
    name: packageName,
    path: "PowerSyncKotlin/build/faktory/zip/frameworkarchive.zip"
)

(run ./gradlew PowerSyncKotlin:zipXCFramework to create it). Pointing our Swift SDK at that package allows building macOS apps. See: powersync-ja/powersync-swift#44

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.

1 participant