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

Add a working xcframework target #6238

Merged
merged 3 commits into from
Sep 9, 2019
Merged

Add a working xcframework target #6238

merged 3 commits into from
Sep 9, 2019

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented Aug 30, 2019

This adds build.sh xcframework [platforms] which produces the following output with support for all of the listed platforms (or iOS, macOS, tvOS and watchOS if no platforms are specified):

  • build/Realm.xcframework: A dynamic framework containing only the obj-c API.
  • build/RealmSwift.xcframework: A dynamic framework containing both the obj-c and swift APIs, with the obj-c library statically linked in.
  • build/RealmObjc.xcframework: A header-only framework which exposes the obj-c API from RealmSwift.xcframework. Apps using RealmSwift.xcframework must link against this.

The main complication here is that loading swiftinterface files uses different scoping rules from normal Swift, which results in our module named Realm conflicting with the class named RealmSwift.Realm. To work around this, the build script statically links Realm into RealmSwift and then supplies a header-only framework named RealmObjc which exposes the relevant symbols.

This also reverts the change to make some of the pre-existing targets build single-platform xcframeworks rather than fat libraries, and makes build.sh build produce a xcframework when building with Xcode 11.

The new installation tests currently aren't run on CI due to requiring Xcode 11, and will need to be enabled as part of enabling CI builds with Xcode 11. Everything in examples/installation is just a copy-paste of the existing examples with Realm.framework changed to Realm.xcframework, so it doesn't need much review attention.

Copy link
Contributor

@jsflax jsflax left a comment

Choose a reason for hiding this comment

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

Nice job– the comments in the build script make it clear for what is going on, and the example should be helpful for users. LGTM.

This adds `build.sh xcframework [platforms]` which produces the following
output with support for all of the listed platforms (or iOS, macOS, tvOS and
watchOS if no platforms are specified):

build/Realm.xcframework: A dynamic framework containing only the obj-c API.
build/RealmSwift.xcframework: A dynamic framework containing both the obj-c and
                              swift APIs, with the obj-c library statically linked in.
build/RealmObjc.xcframework: A header-only framework which exposes the obj-c
                             API from RealmSwift.xcframework. Apps using
                             RealmSwift.xcframework must link against this.

This also reverts the change to make some of the pre-existing targets build
single-platform xcframeworks rather than fat libraries, and makes `build.sh
build` produce a xcframework when building with Xcode 11.

The new installation tests currently aren't run on CI due to requiring Xcode
11, and will need to be enabled as part of enabling CI builds with Xcode 11.
XCFrameworks aren't ready to be the default installation method and should
require explicitly requesting one.
@tgoyne tgoyne merged commit 8ed9590 into master Sep 9, 2019
@tgoyne tgoyne deleted the tg/xcframework branch September 9, 2019 23:56
@decazuk
Copy link

decazuk commented Mar 31, 2020

@tgoyne Hello, I got a problem with this script, when I use this script to build xcframework, I got RealmObjc.xcframework and RealmSwift.xcframework.
When I import theses two framework to the install example project, then I got many build error. "RLMPropertyType is not a member of Realm", "RLMNotificationToken is not a member of Realm". Could you test the build.sh and install example project again? Very appreciate.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants