Skip to content

iOS: don't override EXCLUDED_ARCHS when installing Hermes - #39060

Closed
jpdriver wants to merge 4 commits into
react:mainfrom
jpdriver:preserve-excluded-archs
Closed

iOS: don't override EXCLUDED_ARCHS when installing Hermes#39060
jpdriver wants to merge 4 commits into
react:mainfrom
jpdriver:preserve-excluded-archs

Conversation

@jpdriver

Copy link
Copy Markdown
Contributor

Summary:

  • if an existing iOS project specifies EXCLUDED_ARCHS, these settings are overwritten by the react_native_post_install step as part of the Cocoapods install
  • this can break the build of existing iOS apps that want to include React Native
  • a previous PR (iOS: only exclude i386 while using hermes #38132) updated the Cocoapods utils to that we only update EXCLUDED_ARCHS when using Hermes
  • this worked around the issue for apps that opted to use JSC
  • however if you do want to use Hermes (the default) this problem persists

Existing Behaviour

 def self.exclude_i386_architecture_while_using_hermes(installer)
projects = self.extract_projects(installer)
# Hermes does not support `i386` architecture
excluded_archs_default = self.has_pod(installer, 'hermes-engine') ? "i386" : ""
projects.each do |project|
project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = excluded_archs_default
end
project.save()
end
end

🐛 However 🐛

  • this means existing projects that have EXCLUDED_ARCHS set, the existing value will be overwritten either to "i386" or a blank string

Changed Behaviour

  • appends "i386" to existing string if set, or just sets the value to "i386" if there is no existing value

Changelog:

[IOS] [FIXED] don't override EXCLUDED_ARCHS when installing Hermes

Test Plan:

@facebook-github-botfacebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Aug 17, 2023
@analysis-bot

analysis-bot commented Aug 17, 2023

Copy link
Copy Markdown
PlatformEngineArchSize (bytes)Diff
androidhermesarm64-v8a8,948,041-15,919
androidhermesarmeabi-v7an/a--
androidhermesx86n/a--
androidhermesx86_64n/a--
androidjscarm64-v8a9,541,703-12,604
androidjscarmeabi-v7an/a--
androidjscx86n/a--
androidjscx86_64n/a--

Base commit: 10a076f
Branch: main

@cipolleschicipolleschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jpdriver! Thank you so much for this update. I think that is very good.

However, there are a couple of tests that are failing and need to be updated:

Can you take care of it?

@cipolleschicipolleschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing job, thank you so much for adding some tests on top of these changes.
I left some suggestions to improve maintainability and readibility.

Comment threadpackages/react-native/scripts/cocoapods/utils.rb Outdated
Comment threadpackages/react-native/scripts/cocoapods/utils.rb Outdated
Comment threadpackages/react-native/scripts/cocoapods/utils.rb Outdated
@jpdriver

Copy link
Copy Markdown
ContributorAuthor

@cipolleschi changed as requested 🙇🏻‍♂️

note that with the early returns in place these changes mean we will not set EXCLUDED_ARCHS at all if you are not using Hermes.

existing behaviour is we align all projects to use a blank string. (see changes to tests for more detail)

- assert_equal(config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"], "")
+ assert_equal(config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"], nil)

so not sure if this now constitutes a "breaking" change or not? 😅

@cipolleschi

Copy link
Copy Markdown
Contributor

I think it is better this way, honestly.
I don't like that we manipulate the settings when it is not needed and I guess that empty string or nil are treated the same way by xcodebuild

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-botfacebook-github-bot added the Merged This PR has been merged. label Aug 29, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@cipolleschi merged this pull request in f2447e6.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.MergedThis PR has been merged.Shared with MetaApplied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@jpdriver@analysis-bot@cipolleschi@facebook-github-bot