Skip to content

Commit

Permalink
Exclude i386 from valid architectures when building with Hermes on …
Browse files Browse the repository at this point in the history
…iOS (#30592)

Summary:
When building React Native application in Release mode for an iPhone Simulator _and_ targeting `armv7`, Xcode will build all architectures (due to `ONLY_ACTIVE_ARCH` set to `false`, unlike in Debug mode). As a result, Xcode will try building for `i386` (32-bit iPhone Simulator), which fails as we don’t build Hermes binaries for `i386`.

Fix is to disable `i386`, since it is not supported by `Hermes` and certain `Folly` features.

## Changelog

[IOS] [BREAKING] - `i386` architecture will be automatically disabled when Hermes is being used. This might be potentially breaking for your workflow if you target `armv7` devices, as you will no longer be able to test on the simulator.
[IOS] [FEATURE] - Replace `flipper_post_install` with `react_native_post_install` hook. Will automatically detect if Flipper is enabled.

Pull Request resolved: #30592

Test Plan: Run React Native application with Hermes enabled (or Flipper) in Release mode and it should work just fine.

Reviewed By: appden

Differential Revision: D25564738

Pulled By: TheSavior

fbshipit-source-id: e786ab73fb0a77de5869cf9e5999726c7d29f1d4
  • Loading branch information
grabbou committed Dec 16, 2020
1 parent 5c09b3f commit ed237b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
21 changes: 18 additions & 3 deletions scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def use_flipper!(versions = {}, configurations: ['Debug'])
pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configurations => configurations
end

def has_pod(installer, name)
installer.pods_project.pod_group(name) != nil
end

# Post Install processing for Flipper
def flipper_post_install(installer)
installer.pods_project.targets.each do |target|
Expand All @@ -109,23 +113,34 @@ def flipper_post_install(installer)
end
end

def react_native_post_install(installer)
def exclude_architectures(installer)
projects = installer.aggregate_targets
.map{ |t| t.user_project }
.uniq{ |p| p.path }
.push(installer.pods_project)

arm_value = `/usr/sbin/sysctl -n hw.optional.arm64 2>&1`.to_i

# Hermes does not support `i386` architecture
excluded_archs_default = has_pod(installer, 'hermes-engine') ? "i386" : ""

projects.each do |project|
project.build_configurations.each do |config|
if arm_value == 1 then
config.build_settings.delete("EXCLUDED_ARCHS[sdk=iphonesimulator*]")
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = excluded_archs_default
else
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 " + excluded_archs_default
end
end

project.save()
end
end

def react_native_post_install(installer)
if has_pod(installer, 'Flipper')
flipper_post_install(installer)
end

exclude_architectures(installer)
end
5 changes: 0 additions & 5 deletions template/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,5 @@ target 'HelloWorld' do

post_install do |installer|
react_native_post_install(installer)

# Enables Flipper.
#
# Disable the next line if you are not using Flipper.
flipper_post_install(installer)
end
end

0 comments on commit ed237b4

Please sign in to comment.