diff --git a/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj b/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj index 293ccc788..5b7cb340a 100644 --- a/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj +++ b/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj @@ -179,7 +179,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -e\nif [[ -f \"$PODS_ROOT/../.xcode.env\" ]]; then\nsource \"$PODS_ROOT/../.xcode.env\"\nfi\nif [[ -f \"$PODS_ROOT/../.xcode.env.local\" ]]; then\nsource \"$PODS_ROOT/../.xcode.env.local\"\nfi\nexport CONFIG_CMD=\"dummy-workaround-value\"\nexport CLI_PATH=\"$(\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('@rnef/cli/package.json')) + '/dist/src/bin.js'\")\"\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; + shellScript = "bash -l -c \"${PROJECT_DIR}/react-native-xcode.sh\"\n"; }; 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; diff --git a/packages/platform-ios/template/ios/react-native-xcode.sh b/packages/platform-ios/template/ios/react-native-xcode.sh new file mode 100644 index 000000000..5ac43846d --- /dev/null +++ b/packages/platform-ios/template/ios/react-native-xcode.sh @@ -0,0 +1,8 @@ +set -e + +source "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh" + +export CONFIG_CMD="dummy-workaround-value" +export CLI_PATH="$("$NODE_BINARY" --print "require('path').dirname(require.resolve('@rnef/cli/package.json')) + '/dist/src/bin.js'")" + +source "$REACT_NATIVE_PATH/scripts/react-native-xcode.sh" diff --git a/website/docs/docs/getting-started/migrating-from-community-cli.mdx b/website/docs/docs/getting-started/migrating-from-community-cli.mdx index d0faa85ff..97953f07a 100644 --- a/website/docs/docs/getting-started/migrating-from-community-cli.mdx +++ b/website/docs/docs/getting-started/migrating-from-community-cli.mdx @@ -86,21 +86,15 @@ import { PackageManagerTabs } from 'rspress/theme'; config = use_native_modules!(['npx', 'rnef', 'config', '-p', 'ios']) ``` - In "Bundle React Native code and images" Build Phase in Xcode add: - - ```shell title="Bundle React Native code and images build phase" {2-9} - set -e - if [[ -f "$PODS_ROOT/../.xcode.env" ]]; then - source "$PODS_ROOT/../.xcode.env" - fi - if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then - source "$PODS_ROOT/../.xcode.env.local" - fi - export CONFIG_CMD="dummy-workaround-value" - export CLI_PATH="$("$NODE_BINARY" --print "require('path').dirname(require.resolve('@rnef/cli/package.json')) + '/dist/src/bin.js'")" - WITH_ENVIRONMENT="$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh" + In `ios/.xcodeproj/project.pbxproj` update the shellScript: + + ```ruby title="Bundle React Native code and images" + # shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; + shellScript = "bash -l -c \"${PROJECT_DIR}/react-native-xcode.sh\"\n"; ``` + Next, create `ios/react-native-xcode.sh` based on [this template](https://github.com/callstack/rnef/blob/main/packages/platform-ios/template/ios/react-native-xcode.sh). You can move there any custom code you previously had as part of the "Bundle React Native code and images" Build Phase in Xcode. + 1. Cleanup native files: ```sh