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

Prebuild React Native iOS binaries with cmake #3649

Merged
merged 3 commits into from
Mar 16, 2021
Merged

Conversation

fealebenpae
Copy link
Member

@fealebenpae fealebenpae commented Mar 15, 2021

What, How & Why?

The highlight of this PR is prebuilding the SDK for iOS, like we do on Android, and using CMake to do so.

Previously, the SDK itself along with Object Store would be compiled on user machines, either as part of the podspec or the RealmReact Xcode project. Using realm-core as a submodule makes this impossible due to the sheer complexity of expressing the realm-core build system in Xcode and CocoaPods, and maintaining it.

This PR introduces a new branch of the CMake project that can build the SDK and realm-core for the iOS/JavaScriptCore combo. scripts/build-ios.sh produces a static XCFramework bundle which contains the SDK and realm-core. This framework is embedded in the npm package similarly to the Android JNI libraries, and it is consumed by the RealmReact project and the podspec. Using XCFramework as the library format also enables realm-js to be used on the Apple Silicon iOS Simulator, because it supports the arm64 architecture for the simulator, unlike fat static libraries.

All the code from the podspec related to building the SDK has been removed, leaving only a reference to the xcframework. Likewise, the RealmJS Xcode project is no more. The RealmReact project now contains the GCDWebServer target and the version string needed for analytics.

Because the only relevant file to be compiled alongside user apps is RealmReact.mm, the prebuilt XCFramework needed to expose the minimum API header surface, without leaking any Realm headers. That's why the RPC server C++ API had to be changed to hide all internals behind an opaque implementation class pointer.

To the best of my knowledge this should be a non-breaking change for users - the RealmReact.xcodeproj and CocoaPods integrations entrypoints are unchanged.

☑️ ToDos

  • 📝 Changelog entry
  • 📝 Compatibility label is updated or copied from previous entry
  • 🚦 Tests
  • 📝 Public documentation PR created or is not necessary
  • 💥 Breaking label has been applied or is not necessary

@fealebenpae fealebenpae self-assigned this Mar 15, 2021
@fealebenpae fealebenpae force-pushed the yg/rn-cmake branch 5 times, most recently from 0683d9c to c666b8e Compare March 16, 2021 00:28
@fealebenpae fealebenpae marked this pull request as ready for review March 16, 2021 01:03
RealmJS.podspec Show resolved Hide resolved
@kraenhansen
Copy link
Member

We definitely have an outstanding task of documenting the developer flow after this change. I would like to volunteer to do that.

@fealebenpae fealebenpae merged commit dec8854 into develop Mar 16, 2021
@fealebenpae fealebenpae deleted the yg/rn-cmake branch March 16, 2021 15:19
@kneth kneth mentioned this pull request Mar 17, 2021
7 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants