Skip to content
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

Use static libs for the iOS Swift framework #236

Merged
merged 1 commit into from
Sep 15, 2023

Conversation

matt-livefront
Copy link
Contributor

Type of change

- [ ] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [X] Other

Objective

Running an iOS app linked against the SDK on a device results in a crash because the dynamic library can't be found.

dyld[11647]: Library not loaded: libbitwarden_uniffi.dylib

In looking through the Apple docs, I found the following:

Avoid using dynamic library files (.dylib files) for dynamic linking. An XCFramework can include dynamic library files, but only macOS supports these libraries for dynamic linking. Dynamic linking on iOS, watchOS, and tvOS requires the XCFramework to contain .framework bundles.

For each library and each platform, build a binary static libary file (.a file) that includes slices for all the possible architectures the platform uses.

https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle#Avoid-issues-when-using-alternate-build-systems

This updates the build script to build the framework with static libraries instead. I've tested on a device and it seems to be working.

Code changes

  • build.sh: Updates the script to use static libraries when building the XCFramework.

Before you submit

  • Please add unit tests where it makes sense to do so (encouraged but not required)

Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

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

We'll revisit this if needed. It should be possible to embed .dylib within .framework if need be. It sounds like things might be dynamically linked either way though.

@Hinton Hinton enabled auto-merge (squash) September 15, 2023 08:33
@Hinton Hinton merged commit 45d77e0 into bitwarden:master Sep 15, 2023
@matt-livefront matt-livefront deleted the swift-static-libs branch October 2, 2023 03:09
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