Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix iOS build error when en0 is not available #41873

Closed
wants to merge 1 commit into from

Conversation

mrousavy
Copy link
Contributor

@mrousavy mrousavy commented Dec 9, 2023

Summary:

Fixes a build error that happens when trying to find the host IP address.

The react-native-xcode.sh script tries to find the host machines IP address by looping through all network interfaces:

for num in 0 1 2 3 4 5 6 7 8; do
  IP=$(ipconfig getifaddr en${num})
  if [ ! -z "$IP" ]; then
    break
  fi
done

This works when the network interface is on en0, but when en0 is empty, it will immediately cause the build to fail, even though it would've worked on the next iteration (en1).

This is due to the fact that the script runs with set -e, meaning any error exit code will cause the entire script to fail - and ipconfig will return an exit code of 1 when the network interface en0 can't be found.

This fixes that error by ignoring the error codes of ipconfig, which is what the script was intended to do anyways (it loops over all 9 different interfaces), by adding a || true clause.

Before:

Screenshot 2023-12-09 at 13 33 21

After:

Screenshot 2023-12-09 at 13 33 11

Changelog:

[IOS] [FIXED] - Fix 0.73 build error when ipconfig fails to find the IP address

Test Plan:

  1. Run a build on a machine where ipconfig getifaddr en0 returns nothing.

Fixes a build error that happens when trying to find the host IP address.

e.g. when `ipconfig getifaddr en0` fails, it fails the build, even though `en1` would've worked successfully.
@facebook-github-bot facebook-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 Dec 9, 2023
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 16,513,059 -4,095
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 19,891,835 -1
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: a9dd43c
Branch: main

Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Q: @mrousavy how comes this is starting to happen with 0.73?

@facebook-github-bot
Copy link
Contributor

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

@mrousavy
Copy link
Contributor Author

Honestly not sure, I didn't check the git blame - has this script been the same as with RN 0.72?

Maybe it was a caching issue?

I def. only saw this issue once I upgraded to RN 0.73.

@cortinico
Copy link
Contributor

Closing as:

Effectively already implemented this

@cortinico cortinico closed this Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants