Skip to content

Commit 9970480

Browse files
legobeatfacebook-github-bot
authored andcommitted
chore: Increase iOS script portability (facebook#44417)
Summary: `pod install` and CocoaPods are actually not macOS specific. Still, the pod lifecycle scripts of `react-native` depend on macOS-only utilities and will fail on Linux. This is an attempt to make the scripts portable and make the pod install cleanly on Linux as well as macOS. ## Changelog: [INTERNAL] [FIXED] - Skip XCode patching when not run on macOS [INTERNAL] [FIXED] - Fall back to `which gcc`/`which g++` to identify C/C++ compiler when `xcrun` not available [INTERNAL] [FEAT] - Recognize CC and CXX env vars supplied to the script and prefer them over autodetection Pull Request resolved: facebook#44417 Reviewed By: NickGerleman Differential Revision: D57055928 Pulled By: cipolleschi fbshipit-source-id: 1c49f70c52b4667abf0a215cbee52ee6aa6dd052
1 parent 1945939 commit 9970480

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/react-native/scripts/ios-configure-glog.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@ EOF
4242
patch -p1 config.sub fix_glog_0.3.5_apple_silicon.patch
4343
fi
4444

45-
export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
46-
export CXX="$CC"
45+
XCRUN="$(which xcrun)"
46+
if [ -n "$XCRUN" ]; then
47+
export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
48+
export CXX="$CC"
49+
else
50+
export CC="$CC:-$(which gcc)"
51+
export CXX="$CXX:-$(which g++ || true)"
52+
fi
53+
export CXX="$CXX:-$CC"
4754

4855
# Remove automake symlink if it exists
4956
if [ -h "test-driver" ]; then

packages/react-native/scripts/react_native_pods.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ def react_native_post_install(
288288
ReactNativePodsUtils.set_use_hermes_build_setting(installer, hermes_enabled)
289289
ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path)
290290
ReactNativePodsUtils.set_ccache_compiler_and_linker_build_settings(installer, react_native_path, ccache_enabled)
291-
ReactNativePodsUtils.apply_xcode_15_patch(installer)
291+
if Environment.new().ruby_platform().include?('darwin')
292+
ReactNativePodsUtils.apply_xcode_15_patch(installer)
293+
end
292294
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
293295
ReactNativePodsUtils.set_dynamic_frameworks_flags(installer)
294296
ReactNativePodsUtils.add_ndebug_flag_to_pods_in_release(installer)

0 commit comments

Comments
 (0)