Prebuild React Native iOS binaries with cmake #3649
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theRealmReact
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. TheRealmReact
project now contains theGCDWebServer
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
Compatibility
label is updated or copied from previous entry📝 Public documentation PR created or is not necessary💥Breaking
label has been applied or is not necessary