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

Fix Swift build warnings #231

Merged
merged 1 commit into from
Sep 13, 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

This fixes a few build warnings when integrating the Swift SDK package within an app:

ld: warning: dylib (libbitwarden_uniffi.dylib) was built for newer iOS Simulator version (16.2) than being linked (15.0)

It looks like Rust probably uses the latest iOS deployment target/min iOS version if not specified. I added IPHONEOS_DEPLOYMENT_TARGET="13.0" to set this to iOS 13, which matches the version in Package.swift.
https://github.com/bitwarden/sdk/blob/c707fc9ff9a241b73ef7471f90a3d0b0e68c6e33/languages/swift/Package.swift#L9

ld: warning: linking against a dylib which is not safe for use in application extensions: libbitwarden_uniffi.dylib

We need to link the SDK within an iOS app extension to use for auto fill. RUSTFLAGS="-C link-arg=-Wl,-application_extension" enables a linker flag which specifies that this code is being linked for use in an extension. This prevents using some UIKit APIs that don't exist in extensions but shouldn't have any negative effects on the SDK.

Screenshot 2023-09-13 at 8 51 46 AM

There's a bunch of build warnings from the SDK. These all appear to be around how Rust escapes argument parameters in the generated code, so it seems safe enough to ignore these and add the -suppress-warnings Swift flag. Xcode does a pretty good job of hiding warnings from SPM packages, but they still show up in build logs so it would be nice to hide these.

Code changes

  • Package.swift: Adds a flag to suppress warnings from the SDK package.
  • build.sh: Adds two environment variables to fix build warnings.

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.

Thanks @matt-livefront.

This all looks good, I've triggered the GH actions and will merge once they complete.

@Hinton Hinton merged commit a6f3cca into bitwarden:master Sep 13, 2023
@matt-livefront matt-livefront deleted the fix-swift-build-warnings branch September 13, 2023 18:53
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