react-native
react-native copied to clipboard
error unknown option `--config-cmd'
Description
While I have upgraded to react-native 0.75.2 version i am facing issue regariding react-native-xcode.sh file
when i am running the application i get this error
error unknown option `--config-cmd'
my react-native-xcode.sh file below
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# Bundle React Native app's code and image assets.
# This script is supposed to be invoked as part of Xcode build process
# and relies on environment variables (including PWD) set by Xcode
# Print commands before executing them (useful for troubleshooting)
set -x -e
DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH
# Enables iOS devices to get the IP address of the machine running Metro
if [[ ! "$SKIP_BUNDLING_METRO_IP" && "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then
for num in 0 1 2 3 4 5 6 7 8; do
IP=$(ipconfig getifaddr en${num} || echo "")
if [ ! -z "$IP" ]; then
break
fi
done
if [ -z "$IP" ]; then
IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | grep -v ' 169.254.' |cut -d\ -f2 | awk 'NR==1{print $1}')
fi
echo "$IP" > "$DEST/ip.txt"
fi
if [[ "$SKIP_BUNDLING" ]]; then
echo "SKIP_BUNDLING enabled; skipping."
exit 0;
fi
case "$CONFIGURATION" in
*Debug*)
if [[ "$PLATFORM_NAME" == *simulator ]]; then
if [[ "$FORCE_BUNDLING" ]]; then
echo "FORCE_BUNDLING enabled; continuing to bundle."
else
echo "Skipping bundling in Debug for the Simulator (since the packager bundles for you). Use the FORCE_BUNDLING flag to change this behavior."
exit 0;
fi
else
echo "Bundling for physical device. Use the SKIP_BUNDLING flag to change this behavior."
fi
DEV=true
;;
"")
echo "$0 must be invoked by Xcode"
exit 1
;;
*)
DEV=false
;;
esac
# Path to react-native folder inside node_modules
REACT_NATIVE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# Most projects have their project root, one level up from their Xcode project dir (the "ios" directory)
PROJECT_ROOT=${PROJECT_ROOT:-"$PROJECT_DIR/.."}
cd "$PROJECT_ROOT" || exit
# Define entry file
if [[ "$ENTRY_FILE" ]]; then
# Use ENTRY_FILE defined by user
:
elif [[ -s "index.ios.js" ]]; then
ENTRY_FILE=${1:-index.ios.js}
else
ENTRY_FILE=${1:-index.js}
fi
# check and assign NODE_BINARY env
# shellcheck source=/dev/null
source "$REACT_NATIVE_DIR/scripts/node-binary.sh"
HERMES_ENGINE_PATH="$PODS_ROOT/hermes-engine"
[ -z "$HERMES_CLI_PATH" ] && HERMES_CLI_PATH="$HERMES_ENGINE_PATH/destroot/bin/hermesc"
# If hermesc is not available and USE_HERMES is not set to false, show error.
if [[ $USE_HERMES != false && -f "$HERMES_ENGINE_PATH" && ! -f "$HERMES_CLI_PATH" ]]; then
echo "error: Hermes is enabled but the hermesc binary could not be found at ${HERMES_CLI_PATH}." \
"Perhaps you need to run 'bundle exec pod install' or otherwise " \
"point the HERMES_CLI_PATH variable to your custom location." >&2
exit 2
fi
[ -z "$NODE_ARGS" ] && export NODE_ARGS=""
[ -z "$CLI_PATH" ] && CLI_PATH="$REACT_NATIVE_DIR/scripts/bundle.js"
[ -z "$COMPOSE_SOURCEMAP_PATH" ] && COMPOSE_SOURCEMAP_PATH="$REACT_NATIVE_DIR/scripts/compose-source-maps.js"
if [[ -z "$BUNDLE_CONFIG" ]]; then
CONFIG_ARG=""
else
CONFIG_ARG="--config $BUNDLE_CONFIG"
fi
BUNDLE_FILE="$CONFIGURATION_BUILD_DIR/main.jsbundle"
EXTRA_ARGS=()
case "$PLATFORM_NAME" in
"macosx")
BUNDLE_PLATFORM="macos"
;;
*)
BUNDLE_PLATFORM="ios"
;;
esac
if [ "${IS_MACCATALYST}" = "YES" ]; then
BUNDLE_PLATFORM="ios"
fi
EMIT_SOURCEMAP=
if [[ ! -z "$SOURCEMAP_FILE" ]]; then
EMIT_SOURCEMAP=true
fi
PACKAGER_SOURCEMAP_FILE=
if [[ $EMIT_SOURCEMAP == true ]]; then
if [[ $USE_HERMES != false ]]; then
PACKAGER_SOURCEMAP_FILE="$CONFIGURATION_BUILD_DIR/$(basename "$SOURCEMAP_FILE")"
else
PACKAGER_SOURCEMAP_FILE="$SOURCEMAP_FILE"
fi
EXTRA_ARGS+=("--sourcemap-output" "$PACKAGER_SOURCEMAP_FILE")
fi
# Hermes doesn't require JS minification.
if [[ $USE_HERMES != false && $DEV == false ]]; then
EXTRA_ARGS+=("--minify" "false")
fi
# Allow opting out of using npx react-native config
if [[ -n "$CONFIG_JSON" ]]; then
EXTRA_ARGS+=("--load-config" "$CONFIG_JSON")
elif [[ -n "$CONFIG_CMD" ]]; then
EXTRA_ARGS+=("--config-cmd" "$CONFIG_APP")
else
EXTRA_ARGS+=("--config-cmd" "$NODE_BINARY $NODE_ARGS $REACT_NATIVE_DIR/cli.js config")
fi
# shellcheck disable=SC2086
"$NODE_BINARY" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \
$CONFIG_ARG \
--config-cmd "$CONFIG" \
--entry-file "$ENTRY_FILE" \
--platform "$BUNDLE_PLATFORM" \
--dev $DEV \
--reset-cache \
--bundle-output "$BUNDLE_FILE" \
--assets-dest "$DEST" \
"${EXTRA_ARGS[@]}" \
$EXTRA_PACKAGER_ARGS
if [[ $USE_HERMES == false ]]; then
cp "$BUNDLE_FILE" "$DEST/"
BUNDLE_FILE="$DEST/main.jsbundle"
else
EXTRA_COMPILER_ARGS=
if [[ $DEV == true ]]; then
EXTRA_COMPILER_ARGS=-Og
else
EXTRA_COMPILER_ARGS=-O
fi
if [[ $EMIT_SOURCEMAP == true ]]; then
EXTRA_COMPILER_ARGS="$EXTRA_COMPILER_ARGS -output-source-map"
fi
"$HERMES_CLI_PATH" -emit-binary -max-diagnostic-width=80 $EXTRA_COMPILER_ARGS -out "$DEST/main.jsbundle" "$BUNDLE_FILE"
if [[ $EMIT_SOURCEMAP == true ]]; then
HBC_SOURCEMAP_FILE="$DEST/main.jsbundle.map"
"$NODE_BINARY" "$COMPOSE_SOURCEMAP_PATH" "$PACKAGER_SOURCEMAP_FILE" "$HBC_SOURCEMAP_FILE" -o "$SOURCEMAP_FILE"
rm "$HBC_SOURCEMAP_FILE"
rm "$PACKAGER_SOURCEMAP_FILE"
fi
BUNDLE_FILE="$DEST/main.jsbundle"
fi
if [[ $DEV != true && ! -f "$BUNDLE_FILE" ]]; then
echo "error: File $BUNDLE_FILE does not exist. Your environment is misconfigured as Metro was not able to produce the bundle so your release application won't work!" >&2
exit 2
fi
Steps to reproduce
- yarn ios
- after yarn ios i am not able to run it
React Native Version
0.75.2
Affected Platforms
Runtime - iOS
Output of npx react-native info
my react-native info
System:
OS: macOS 14.5
CPU: (8) arm64 Apple M1
Memory: 104.50 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 19.2.0 - ~/.nvm/versions/node/v19.2.0/bin/node
Yarn: 3.6.4 - /opt/homebrew/bin/yarn
npm: 9.6.6 - ~/.nvm/versions/node/v19.2.0/bin/npm
Watchman: 2022.09.19.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.15.2 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, visionOS 1.0, watchOS 10.2
Android SDK: Not Found
IDEs:
Android Studio: 2024.1 AI-241.18034.62.2411.12071903
Xcode: 15.2/15C500b - /usr/bin/xcodebuild
Languages:
Java: 17.0.11 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.3.1 => 18.3.1
react-native: 0.75.2 => 0.75.2
Stacktrace or Logs
error export CLANG_WARN_EMPTY_BODY\=YES
error unknown option `--config-cmd'
error Failed to build ios project.
Reproducer
https://github.com/react-native-community/reproducer-react-native
Screenshots and Videos
| :warning: | Newer Version of React Native is Available! |
|---|---|
| :information_source: | You are on a supported minor version, but it looks like there's a newer patch available - 0.75.3. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |
| :warning: | Missing Reproducible Example |
|---|---|
| :information_source: | We could not detect a reproducible example in your issue report. Please provide either:
|
| :warning: | Newer Version of React Native is Available! |
|---|---|
| :information_source: | You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |
| :warning: | Missing Reproducible Example |
|---|---|
| :information_source: | We could not detect a reproducible example in your issue report. Please provide either:
|
This PR should resolve the issue [#46495] and it is merged. If you want to build urgently, you can just copy the same in your local react-native.
Hopefully, this fix will be present in the next release.
namespace facebook { namespace jsi { namespace detail {
inline Value toValue(Runtime&, std::nullptr_t) {
return Value::null();
}
inline Value toValue(Runtime&, bool b) {
return Value(b);
}
inline Value toValue(Runtime&, double d) {
return Value(d);
}
inline Value toValue(Runtime&, float f) {
return Value(static_cast
inline PropNameID toPropNameID(Runtime& runtime, const char* name) { return PropNameID::forAscii(runtime, name); } inline PropNameID toPropNameID(Runtime& runtime, const std::string& name) { return PropNameID::forUtf8(runtime, name); } inline PropNameID&& toPropNameID(Runtime&, PropNameID&& name) { return std::move(name); }
/// Helper to throw while still compiling with exceptions turned off. template <typename E, typename... Args> [[noreturn]] inline void throwOrDie(Args&&... args) { std::rethrow_exception( std::make_exception_ptr(E{std::forward<Args>(args)...})); }
} // namespace detail
template <typename T> inline T Runtime::make(Runtime::PointerValue* pv) { return T(pv); }
inline Runtime::PointerValue* Runtime::getPointerValue(jsi::Pointer& pointer) { return pointer.ptr_; }
inline const Runtime::PointerValue* Runtime::getPointerValue( const jsi::Pointer& pointer) { return pointer.ptr_; }
inline const Runtime::PointerValue* Runtime::getPointerValue( const jsi::Value& value) { return value.data_.pointer.ptr_; }
inline Value Object::getProperty(Runtime& runtime, const char* name) const { return getProperty(runtime, String::createFromAscii(runtime, name)); }
inline Value Object::getProperty(Runtime& runtime, const String& name) const { return runtime.getProperty(*this, name); }
inline Value Object::getProperty(Runtime& runtime, const PropNameID& name) const { return runtime.getProperty(*this, name); }
inline bool Object::hasProperty(Runtime& runtime, const char* name) const { return hasProperty(runtime, String::createFromAscii(runtime, name)); }
inline bool Object::hasProperty(Runtime& runtime, const String& name) const { return runtime.hasProperty(*this, name); }
inline bool Object::hasProperty(Runtime& runtime, const PropNameID& name) const { return runtime.hasProperty(*this, name); }
template <typename T> void Object::setProperty(Runtime& runtime, const char* name, T&& value) const { setProperty( runtime, String::createFromAscii(runtime, name), std::forward<T>(value)); }
This memory leak is coming in jsi-inl file
Is this related to the unknown option error?
Memory leak is not related to this, also this solution is not there in 0.75.3, it will be there in the next release
i has same problem --config-cmd
solved https://github.com/facebook/react-native/issues/46552#issuecomment-2357631163
I'm also still having this issue even after manually applying the fix. Anyone else still having XCode archive builds fail because of this?
https://github.com/facebook/react-native/issues/46552#issuecomment-2357631163 did not solve it for me
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Same error when i build on physic device, but no problem with simulator. None of these work for me.
Same error when i build on physic device, but no problem with simulator.
Same error when i build on physic device, but no problem with simulator.
I ran into the same error and, I guess, it was caused by having an extra Run Script that re‐invoked the bundler. That duplication doesn’t fail on the Simulator (because it skips bundling there) but breaks on a physical device. Removing the extra Run Script fixed the build in my case.
same issue: 0.80.0 demo project iOS Archive error: unknown option '--config-cmd'
this is what help me after debugging for 3 hours
diff --git a/node_modules/react-native/scripts/react-native-xcode.sh b/node_modules/react-native/scripts/react-native-xcode.sh
index d59caa1..e288e08 100755
--- a/node_modules/react-native/scripts/react-native-xcode.sh
+++ b/node_modules/react-native/scripts/react-native-xcode.sh
@@ -148,7 +148,8 @@ if [[ -n "$CONFIG_JSON" ]]; then
elif [[ -n "$CONFIG_CMD" ]]; then
EXTRA_ARGS+=("--config-cmd" "$CONFIG_CMD")
else
- EXTRA_ARGS+=("--config-cmd" "$NODE_BINARY $NODE_ARGS $REACT_NATIVE_DIR/cli.js config")
+ # EXTRA_ARGS+=("--config-cmd" "$NODE_BINARY $NODE_ARGS $REACT_NATIVE_DIR/cli.js config")
+ EXTRA_ARGS+=("--config" "$PROJECT_ROOT/metro.config.js")
fi
# shellcheck disable=SC2086