software-mansion / radon-ide

VSCode/Cursor extension that turns your editor into a full featured IDE for React Native and Expo.
https://ide.swmansion.com
Other
1.05k stars 37 forks source link

Can't build iOS due to -arch arm64 flag if xcode project has EXCLUDED_ARCHS = "arm64" #811

Open LMakshow opened 1 day ago

LMakshow commented 1 day ago

Description The app build fails on iOS if it has the EXCLUDED_ARCHS = "arm64" setting in Xcode. It builds Android normally, the app also builds okay in the simulator from the react-native run-ios command.

Logs The build logs show a multitude of errors for every CocoaPod used, an example:

2024-12-03 02:15:35.035 [info] warning: None of the architectures in ARCHS (arm64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, i386, x86_64) which is not in EXCLUDED_ARCHS (arm64). (in target 'glog' from project 'Pods')
2024-12-03 02:15:35.035 [info] warning: None of the architectures in ARCHS (arm64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, i386, x86_64) which is not in EXCLUDED_ARCHS (arm64). (in target 'Base64' from project 'Pods')

Our Podfile includes the lines:

installer.pods_project.build_configurations.each do |config|
  config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end

Thus the arm64 is the excluded arch. This setting is quite common in React Native projects with legacy code.

But the command line invocation of the Radon IDE for xcodebuild has -arch arm64 flag which conflicts with the setting and causes the build to fail:

2024-12-03 02:02:47.134 [info] Command line invocation:
2024-12-03 02:02:47.134 [info]     /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace /Users/.../example.xcworkspace -configuration Debug -scheme Staging -arch arm64 -sdk iphonesimulator -showBuildTimingSummary -destination-timeout 0 build

A suggestion would be to allow setting custom command line invocation parameters.

Environment

LMakshow commented 1 day ago

Update: while I wrote the issue, I restarted the build without EXCLUDED_ARCHS both in the Podfile and XCode settings. The build succeeded.

I guess we no longer have the legacy code that required that EXCLUDED_ARCHS setting. Still, the issue might be relevant for other developers.

kmagiera commented 1 day ago

Thanks for reporting and for investing time to troubleshot. I'd assume that in such setting you also need to use rosetta for running simulator on arm-based macs?

Do you have some example repositories with this configuration that we could try? I wonder what expo/rn cli could do differently here to allow this. Building for all possible architecture doesn't seem like a sensible choice as this makes the whole build twice as slow. Therefore I'm surprised these tools don't rely on some configuration options for this to work

LMakshow commented 1 day ago

Yes, this, old cocoapods which aren't updated to use arm, by excluding arm64 from arch are forced to build and run through rosetta. I looked through the pods we use, it's only Flipper that is not updated and thus the app won't build without that EXCLUDED_ARCHS in the Podfile.

Also, I found that the EXCLUDED_ARCHS setting makes the iOS 18 simulator behave unstable and hangs up the app on any modal window (iOS 17.5 works fine, it's XCode 16 introduced this bug). So guess, in the future no one will use it, and we simply should get rid of Flipper.

So it's not a high-priority bug for you to fix. I still can make a sample repository for you to try if you would like to. :)

LMakshow commented 1 day ago

Building for all possible architecture doesn't seem like a sensible choice as this makes the whole build twice as slow.

No, the build won't run for all possible architectures as most XCode projects have ONLY_ACTIVE_ARCH set to YES. That's probably why there's no need for this configuration option in expo/rn cli.