From cb231f53008184a7d7009d2db7df4aeaa7034a0c Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Fri, 25 Apr 2025 13:07:39 +0200 Subject: [PATCH 1/6] chore: extract bundle react native code and images to a standalone script --- .../ios/HelloWorld.xcodeproj/project.pbxproj | 2 +- .../ios/bundle-react-native-code-and-images.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 packages/platform-ios/template/ios/bundle-react-native-code-and-images.sh diff --git a/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj b/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj index 293ccc788..3808700e6 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}/bundle-react-native-code-and-images.sh\"\n"; }; 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; diff --git a/packages/platform-ios/template/ios/bundle-react-native-code-and-images.sh b/packages/platform-ios/template/ios/bundle-react-native-code-and-images.sh new file mode 100644 index 000000000..a1f3f0f00 --- /dev/null +++ b/packages/platform-ios/template/ios/bundle-react-native-code-and-images.sh @@ -0,0 +1,16 @@ +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" +REACT_NATIVE_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh" +/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE" From 85da27d64894225b3035628202aab496f66dcab6 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Mon, 28 Apr 2025 16:06:53 +0200 Subject: [PATCH 2/6] chore: apply review comments to simplify the script --- .../ios/HelloWorld.xcodeproj/project.pbxproj | 2 +- .../ios/bundle-react-native-code-and-images.sh | 16 ---------------- .../template/ios/react-native-xcode.sh | 6 ++++++ 3 files changed, 7 insertions(+), 17 deletions(-) delete mode 100644 packages/platform-ios/template/ios/bundle-react-native-code-and-images.sh create mode 100644 packages/platform-ios/template/ios/react-native-xcode.sh diff --git a/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj b/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj index 3808700e6..45d87a436 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 = "bash -l -c \"${PROJECT_DIR}/bundle-react-native-code-and-images.sh\"\n"; + shellScript = "bash -l -c \"${REACT_NATIVE_PATH}/scripts/xcode/with-environment.sh\" \"${PROJECT_DIR}/react-native-xcode.sh\"\n"; }; 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; diff --git a/packages/platform-ios/template/ios/bundle-react-native-code-and-images.sh b/packages/platform-ios/template/ios/bundle-react-native-code-and-images.sh deleted file mode 100644 index a1f3f0f00..000000000 --- a/packages/platform-ios/template/ios/bundle-react-native-code-and-images.sh +++ /dev/null @@ -1,16 +0,0 @@ -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" -REACT_NATIVE_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh" -/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE" 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..bddc799f2 --- /dev/null +++ b/packages/platform-ios/template/ios/react-native-xcode.sh @@ -0,0 +1,6 @@ +set -e + +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'")" + +. "$REACT_NATIVE_PATH/scripts/react-native-xcode.sh" From 3bc8a46144dc375605941d3dca14e80182030648 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Fri, 9 May 2025 11:30:21 +0200 Subject: [PATCH 3/6] chore: move with-environment to the newly extracted script --- .../template/ios/HelloWorld.xcodeproj/project.pbxproj | 2 +- packages/platform-ios/template/ios/react-native-xcode.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj b/packages/platform-ios/template/ios/HelloWorld.xcodeproj/project.pbxproj index 45d87a436..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 = "bash -l -c \"${REACT_NATIVE_PATH}/scripts/xcode/with-environment.sh\" \"${PROJECT_DIR}/react-native-xcode.sh\"\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 index bddc799f2..10636b47f 100644 --- a/packages/platform-ios/template/ios/react-native-xcode.sh +++ b/packages/platform-ios/template/ios/react-native-xcode.sh @@ -1,5 +1,7 @@ set -e +. "$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'")" From 110c4ebf871dd11f9cc283651233012702c490c8 Mon Sep 17 00:00:00 2001 From: Adam Horodyski <42047036+adhorodyski@users.noreply.github.com> Date: Mon, 26 May 2025 15:10:47 +0200 Subject: [PATCH 4/6] docs: update migrating-from-community-cli.mdx --- .../migrating-from-community-cli.mdx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) 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 e9cc99783..d995409cf 100644 --- a/website/docs/docs/getting-started/migrating-from-community-cli.mdx +++ b/website/docs/docs/getting-started/migrating-from-community-cli.mdx @@ -86,19 +86,24 @@ 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: + In `ios/.xcodeproj/project.pbxproj` update the shellScript: - ```shell title="Bundle React Native code and images build phase" {2-9} + ```ruby title="" + # 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` with the below content. You can move there any custom code you previously had as part of the "Bundle React Native code and images" Build Phase in Xcode: + + ```shell title="ios/react-native-xcode.sh" 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 + + . "$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'")" - WITH_ENVIRONMENT="$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh" + + . "$REACT_NATIVE_PATH/scripts/react-native-xcode.sh" ``` 1. Cleanup native files: From 5a77bc03801f72cdd6b2dd370e4a1d8f123493d9 Mon Sep 17 00:00:00 2001 From: Adam Horodyski <42047036+adhorodyski@users.noreply.github.com> Date: Mon, 26 May 2025 16:16:07 +0200 Subject: [PATCH 5/6] Update react-native-xcode.sh --- packages/platform-ios/template/ios/react-native-xcode.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/platform-ios/template/ios/react-native-xcode.sh b/packages/platform-ios/template/ios/react-native-xcode.sh index 10636b47f..5ac43846d 100644 --- a/packages/platform-ios/template/ios/react-native-xcode.sh +++ b/packages/platform-ios/template/ios/react-native-xcode.sh @@ -1,8 +1,8 @@ set -e -. "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh" +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'")" -. "$REACT_NATIVE_PATH/scripts/react-native-xcode.sh" +source "$REACT_NATIVE_PATH/scripts/react-native-xcode.sh" From d3742c318ae4f259b45b6327be8cbac2eb0ff3ed Mon Sep 17 00:00:00 2001 From: Adam Horodyski <42047036+adhorodyski@users.noreply.github.com> Date: Mon, 26 May 2025 16:53:19 +0200 Subject: [PATCH 6/6] Update migrating-from-community-cli.mdx --- .../migrating-from-community-cli.mdx | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) 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 d995409cf..617f1713e 100644 --- a/website/docs/docs/getting-started/migrating-from-community-cli.mdx +++ b/website/docs/docs/getting-started/migrating-from-community-cli.mdx @@ -88,23 +88,12 @@ import { PackageManagerTabs } from 'rspress/theme'; In `ios/.xcodeproj/project.pbxproj` update the shellScript: - ```ruby title="" + ```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` with the below content. You can move there any custom code you previously had as part of the "Bundle React Native code and images" Build Phase in Xcode: - - ```shell title="ios/react-native-xcode.sh" - set -e - - . "$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'")" - - . "$REACT_NATIVE_PATH/scripts/react-native-xcode.sh" - ``` + 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: