flipper
flipper copied to clipboard
Question: Does current ReactNativeFlipperExample app runs on simulator on M1 macs?
Been banging my head after getting M1 machine. My goal is have a working setup with flipper running on simulator outside of Rosetta on my main project. No success so far, (made it run on device with no changes), but having issues with simulator, so I decided to check against a simpler project.
So my current steps so far were:
- Clone the react-native/ReactNativeFlipperExample app
- yarn install && cd ios && pod install
- Attempt to debug build to iPhone 13 simulator.
Currently on my machine it fails with
I'm not sure how it's even supposed to work with excluded architectures, since project.pbxproj file excludes arm64 configuration on main, which gets overridden by react_native_pods postinstall ~~hacks~~ workarounds.
Adding bridging header (how I deduced, mainly for ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES) does not help a bit. Then it goes into territory on more attempts to make stuff run, overriding excluded archs again, which kinda ruins the point in trying to run an example project.
I'm interested in is that some problems in my configuration, or I should stop trying and it's not running on M1 machines in current state?
xed version 13.1
Thank you for you time!
@lblasa have you tried to build one of our Sample apps on M1?
@aigoncharov unfortunately not, don't have an M1 available to me.
@Pyroboomka I am sure we'll address it eventually, but I cannot promise any dates now or provide any direct guidance. If you find a workaround, we'd be beyond happy to hear back from you with the steps or a PR.
Well, can you at least tell me, does it fail with similar errors for you (if you tried to spin it up)? Unfortunately, my colleagues don't have M1 either, so if it breaks with the same errors that would be a good starting point for me. I'll spend some time this week trying to make it work, but I don't have native iOS development experience, so it's gonna be fun :)
Well, it was kinda easy. Dug through some discussions on react-native repo about M1 issues and referencing this PR https://github.com/facebook/react-native/pull/32284/files which I guess is gonna land somewhere in 0.67 if I understand releases correctly, I just deleted the faulty path in LIBRARY_SEARCH_PATHS and it built successfully.
No point in fixing this I guess, gonna work out of the box in new release (after upgrading to new version correctly)
@Pyroboomka Where is LIBRARY_SEARCH_PATHS you're modifying? The key is not defined (i.e. default) for me in my XCode build settings
Nevermind, applied your fix by going into react_native_pods.rb and manually adding the fixer function from https://github.com/facebook/react-native/pull/32284/files
For other readers, you can apply this fix by going into node_modules/react-native/scripts/react_native_pods.rb
and adding this function above the line def react_native_post_install(installer)
:
def fix_library_search_paths(installer)
def fix_config(config)
lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
if lib_search_paths
if lib_search_paths.include?("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)") || lib_search_paths.include?("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
# $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
# since the libraries there are only built for x86_64 and i386.
lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
lib_search_paths.delete("\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"")
if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?("\"$(SDKROOT)/usr/lib/swift\""))
# however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
end
end
end
end
projects = installer.aggregate_targets
.map{ |t| t.user_project }
.uniq{ |p| p.path }
.push(installer.pods_project)
projects.each do |project|
project.build_configurations.each do |config|
fix_config(config)
end
project.native_targets.each do |target|
target.build_configurations.each do |config|
fix_config(config)
end
end
project.save()
end
end
And then call the function, so your updated react_native_post_install
looks like this:
def react_native_post_install(installer)
if has_pod(installer, 'Flipper')
flipper_post_install(installer)
end
exclude_architectures(installer)
fix_library_search_paths(installer)
end