From 217521624e3f54d935651544e3a22a61a9c1216e Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Wed, 29 Sep 2021 11:12:54 -0300 Subject: [PATCH] Detect Rosetta2 and warn if x86_64 is used on arm64 Running `pod install` from inside Rosetta2 can lead to problems, try to avoid doing that by hinting users from use_react_native!() function. $ arch -x86_64 pod install Building RNTester with Fabric enabled. Building RNTester with Fabric enabled. Building RNTester with Fabric enabled. Analyzing dependencies Downloading dependencies Generating Pods project Integrating client project Pod installation complete! There are 63 dependencies from the Podfile and 50 total pods installed. [!] Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64). [!] - Emulated x86_64 is slower than native arm64 [!] - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter) [!] Run "env /usr/bin/arch -arm64 /bin/bash --login" then try again. --- scripts/react_native_pods.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 4386c9c970451c..3c6a21eacc81de 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -16,6 +16,13 @@ def use_react_native! (options={}) # Include Hermes dependencies hermes_enabled = options[:hermes_enabled] ||= false + if `/usr/sbin/sysctl -n hw.optional.arm64 2>&1`.to_i == 1 && !RUBY_PLATFORM.start_with?('arm64') + Pod::UI.warn 'Do not use "pod install" from inside Rosetta2 (x86_64 emulation on arm64).' + Pod::UI.warn ' - Emulated x86_64 is slower than native arm64' + Pod::UI.warn ' - May result in mixed architectures in rubygems (eg: ffi_c.bundle files may be x86_64 with an arm64 interpreter)' + Pod::UI.warn 'Run "env /usr/bin/arch -arm64 /bin/bash --login" then try again.' + end + # The Pods which should be included in all projects pod 'FBLazyVector', :path => "#{prefix}/Libraries/FBLazyVector" pod 'FBReactNativeSpec', :path => "#{prefix}/React/FBReactNativeSpec"