arm64 simulators & catalyst support#475
Conversation
|
Hi @Arkkeeper! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
|
@Arkkeeper Thanks for contributing! While cc-ing @grabbou to review this, I noticed that The |
hermes-engine.podspec
Outdated
| # TODO(use the hash field as a validation mechanism when the process is stable) | ||
| spec.source = ENV['hermes-artifact-url'] ? { http: ENV['hermes-artifact-url'] } : { git: "https://github.com/facebook/hermes.git", tag: "v#{spec.version}" } | ||
| spec.platforms = { :osx => "10.13", :ios => "10.0" } | ||
| spec.platforms = { :osx => "11.0", :ios => "10.0" } |
There was a problem hiding this comment.
Maybe because of this version bump?
There was a problem hiding this comment.
I reverted that bump, I don't think that it's essential for Catalyst support.
Now CircleCI fails on Android tests, but my commits have nothing to do with the android part of code.
There was a problem hiding this comment.
Yeah do not worry about the Android tests. The android emulator image is somehow missing.
|
Friendly ping @grabbou For context why this is extremely important: RN 0.64 now ships with iOS Hermes support, but lack of support for iOS Simulator arm64 arch makes it impossible to work with it. Additionally, RN apps using turbo modules can only be debugged with Flipper's Hermes Debugger. |
|
@Arkkeeper is there any easy way to use this PR before it's merged? |
|
You have to patch react-native/scripts/react_native_pods.rb. First, add a variable to check whether it's ARM Mac, like: Then modify definition of hermes-engine and refer to repo with my PR: if is_arm == 1 then Make sure that you have cmake and ninja installed with homebrew. Then run yarn and prepare to wait about 15-20 minutes. Building hermes-engine from sources for several archs is rather tedious. |
|
Thank you. Some notes regarding your instructions, in case it helps others: Ran into Also, detecting arm64 didn't work in my case because I can only run cocoapods using |
alloy
left a comment
There was a problem hiding this comment.
Awesome, I didn’t know somebody had already done this work! Most importantly we should make sure it still works for macOS too.
| local catalyst="false" | ||
| local platform=$1 | ||
|
|
||
| if [[ $1 == iphoneos || $1 == catalyst ]]; then |
There was a problem hiding this comment.
Perhaps also replace further use of $1 with the $platform alias here?
There was a problem hiding this comment.
I would actually not use $platform here. Further explanation on line 62.
utils/build-apple-framework.sh
Outdated
| else | ||
| build_cli_tools="false" | ||
| fi | ||
| if [[ $1 == catalyst ]]; then |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
utils/build-apple-framework.sh
Outdated
| for platform in "${@:2}"; do | ||
| rm -r "$platform" | ||
| done | ||
| xcodebuild -create-xcframework -framework iphoneos/hermes.framework -framework iphonesimulator/hermes.framework -framework macosx/hermes.framework -output iphoneos/hermes.xcframework |
There was a problem hiding this comment.
The output should not assume the framework is just for iOS here, it should theoretically also be able to contain the macOS slices, no?
There was a problem hiding this comment.
Yes. Also, it should also get the platforms from the platforms, like the lipo did, without hardcoding them. I just think it's nicer and doesn't require manual rm of every folder, like it's currently done on line 112-114.
|
|
||
| for i in "${!platforms[@]}"; do | ||
| platforms[$i]="${platforms[$i]}/hermes.framework/hermes" | ||
| done |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
Thanks for the PR! I left some comments to further optimise the scripts and the way we handle Catalyst, but I'd consider them minor tweaks, since overall, everything seems to be fine. |
|
Thank you for your suggestions! I've pushed some optimizations for the build scripts. I hope that my PR won't delay Hermes 0.8.1 and RN 0.65. |
Building third time in row, over 1 hour each time. not cool :( |
|
@Arkkeeper Any timeline on how soon it can get merged? |
|
cc @grabbou remember to check this one ;) |
grabbou
left a comment
There was a problem hiding this comment.
Thank you for addressing my previous comments. The PR looks really good! Rather than two tiny issues, it is good to go.
I will give it a shot and test it tomorrow, and if everything runs smoothly, I will merge it, reverting the deleted lines on top of your PR.
| # Once all was linked into a single framework, clean destroot | ||
| # from unused frameworks | ||
| for platform in "${@:2}"; do | ||
| rm -r "$platform" |
There was a problem hiding this comment.
Any particular reason why this has been removed? This should be reverted. We need to clean up destroot to only contain the artifacts that are used in production.
This is because CircleCI will package the entire destroot folder into a tarball that is distributed along the npm package. If we don't clean it up, we are going to ship one xcframework and every platform separately as well.
There was a problem hiding this comment.
OK, I've reverted that removal
| args+="-framework ${platforms[$i]}/hermes.framework " | ||
| done | ||
|
|
||
| lipo -info "${platforms[0]}" |
There was a problem hiding this comment.
Any particular reason why this has been removed? I think this is a good add-on for debugging purposes on the CI.
There was a problem hiding this comment.
Because lipo -info fails on xcframework with a fatal error:
can't map input file: iphoneos (Invalid argument)
|
Code wise, it looks good. However, I just noticed that
|
|
@Huxpro has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: Edits build scripts to allow merging architectures into .xcframework instead of using lipo for building fat framework. Adds compatibility with arm64 iOS Simulators on Apple M1 Macs and allows using Hermes with RN apps built for Mac Catalyst. Fixes facebook#460 and facebook#468 Pull Request resolved: facebook#475 Differential Revision: D29465045 Pulled By: Huxpro fbshipit-source-id: 6291aac9ee47db83d6f78822767019ec0277a899
|
I believe we should be closing this one in favor of #546. Thanks for the work so far! |
Summary
Edits build scripts to allow merging architectures into .xcframework instead of using lipo for building fat framework.
Adds compatibility with arm64 iOS Simulators on Apple M1 Macs and allows using Hermes with RN apps built for Mac Catalyst.
Fixes #460 and #468