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

RCOCOA-2343 Enable building RealmSwift as a dynamic framework with SPM #8561

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented Apr 29, 2024

While App Store Connect supports static libraries, Xcode doesn't actually build static libraries for static targets; it just links the object files directly into the app. It also doesn't implement the xcprivacy manifest merging that the documentation claims exists, so the only way to actually use our privacy manifest is to build a dynamic framework.

Because Xcode is very weird, setting the library type to .dynamic doesn't actually result in it being built as a dynamic framework; it just gives the consuming app the option of building it as dynamic. It also makes it so that having multiple targets depend on the product is broken. Hopefully that will not be a problem.

Building Realm.framework as dynamic and then RealmSwift.framework as static doesn't work, so this adds the privacy manifest to RealmSwift.framework as well.

@tgoyne tgoyne self-assigned this Apr 29, 2024
@cla-bot cla-bot bot added the cla: yes label Apr 29, 2024
@tgoyne tgoyne changed the title Force Realm to be built as a dynamic library when installing via SPM RCOCOA-2343 Force Realm to be built as a dynamic library when installing via SPM Apr 29, 2024
@tgoyne tgoyne changed the title RCOCOA-2343 Force Realm to be built as a dynamic library when installing via SPM RCOCOA-2343 Enable building RealmSwift as a dynamic framework with SPM Apr 29, 2024
@tgoyne tgoyne marked this pull request as ready for review April 30, 2024 04:11
@tgoyne
Copy link
Member Author

tgoyne commented Apr 30, 2024

This appears to work but the process for validating app privacy manifests is so awful that it's hard to be sure.

@tgoyne tgoyne requested a review from nirinchev April 30, 2024 04:12
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@dianaafanador3 dianaafanador3 left a comment

Choose a reason for hiding this comment

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

LGTM!, Just a few minor comments

- To actually build RealmSwift as a dynamic framework, change "Do Not Embed"
to "Embed & Sign" in the "Frameworks, Libraries, and Embedded Content"
section on the General tab of your target's settings.
([#8561](https://github.com/realm/realm-swift/pull/8561)).
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we tag the docs teams for this to be added to this page? https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/install/

libraries in a way compatible with xcprivacy embedding. Due to some bugs in
Xcode, this may require manual changes to your project:
- Targets must now depend on only Realm or RealmSwift. If you use both the
obj-c and swift API, depending on RealmSwift will let you import Realm.
Copy link
Contributor

Choose a reason for hiding this comment

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

This means, that by importing RealmSwift, user will have access to Realm API

Copy link
Member Author

Choose a reason for hiding this comment

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

No, Realm is still a separate import. They just don't have to add it as a dependency in the project.

This is required for compliance with the new privacy manifest rules. While App
Store Connect supports static libraries, Xcode doesn't actually build static
libraries for static targets; it just links the object files directly into the
app. It also doesn't implement the xcprivacy manifest merging that the
documentation claims exists, so our privacy manfiest is never actually used.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants