Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c393b59

Browse files
feat: add expo sourcemap support
1 parent f9d8aed commit c393b59

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/default/ios/InstabugExample.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@
430430
name = "[CP-User] [instabug-reactnative] Upload Sourcemap";
431431
runOnlyForDeploymentPostprocessing = 0;
432432
shellPath = /bin/sh;
433-
shellScript = "#!/bin/sh\n\nmain() {\n # Read environment variables from ios/.xcode.env if it exists\n env_path=\"$PODS_ROOT/../.xcode.env\"\n if [ -f \"$env_path\" ]; then\n source \"$env_path\"\n fi\n\n # Read environment variables from ios/.xcode.env.local if it exists\n local_env_path=\"${ENV_PATH}.local\"\n if [ -f \"$local_env_path\" ]; then\n source \"$local_env_path\"\n fi\n\n if [[ \"$INSTABUG_SOURCEMAPS_UPLOAD_DISABLE\" = true ]]; then\n echo \"[Info] \\`INSTABUG_SOURCEMAPS_UPLOAD_DISABLE\\` was set to true, skipping sourcemaps upload...\"\n exit 0\n fi\n\n if [[ \"$CONFIGURATION\" = \"Debug\" ]]; then\n echo \"[Info] Building in debug mode, skipping sourcemaps upload...\"\n exit 0\n fi\n\n if [[ -z \"$INFOPLIST_FILE\" ]] || [[ -z \"$PROJECT_DIR\" ]]; then\n echo \"[Error] Instabug sourcemaps script must be invoked by Xcode\"\n exit 0\n fi\n\n local source_map_file=$(generate_sourcemaps | tail -n 1)\n\n local js_project_dir=\"$PROJECT_DIR/..\"\n local instabug_dir=$(dirname $(node -p \"require.resolve('instabug-reactnative/package.json')\"))\n local inferred_token=$(cd $js_project_dir && source $instabug_dir/scripts/find-token.sh)\n local app_token=$(resolve_var \"App Token\" \"INSTABUG_APP_TOKEN\" \"$inferred_token\" | tail -n 1)\n\n local inferred_name=$(/usr/libexec/PlistBuddy -c 'print CFBundleShortVersionString' \"$PROJECT_DIR/$INFOPLIST_FILE\")\n local version_name=$(resolve_var \"Version Name\" \"INSTABUG_APP_VERSION_NAME\" \"$inferred_name\" | tail -n 1)\n\n local inferred_code=$(/usr/libexec/PlistBuddy -c 'print CFBundleVersion' \"$PROJECT_DIR/$INFOPLIST_FILE\")\n local version_code=$(resolve_var \"Version Code\" \"INSTABUG_APP_VERSION_CODE\" \"$inferred_code\" | tail -n 1)\n\n node $instabug_dir/bin/index.js upload-sourcemaps \\\n --platform ios \\\n --file $source_map_file \\\n --token $app_token \\\n --name $version_name \\\n --code $version_code\n}\n\ngenerate_sourcemaps() {\n local react_native_dir=$(dirname $(node -p \"require.resolve('react-native/package.json')\"))\n\n # Fixes an issue with react-native prior to v0.67.0\n # For more info: https://github.com/facebook/react-native/issues/32168\n export RN_DIR=$react_native_dir\n\n # Used withing `react-native-xcode.sh` to generate sourcemap file\n export SOURCEMAP_FILE=\"$(pwd)/main.jsbundle.map\";\n\n source \"$react_native_dir/scripts/react-native-xcode.sh\"\n\n if [[ ! -f \"$SOURCEMAP_FILE\" ]]; then\n echo \"[Error] Unable to find source map file at: $SOURCEMAP_FILE\"\n exit 0\n fi\n\n echo $SOURCEMAP_FILE\n}\n\nresolve_var() {\n local name=$1\n local env_key=$2\n local default_value=$3\n\n local env_value=\"${!env_key}\"\n\n if [[ -n \"$env_value\" ]] && [[ -n \"$default_value\" ]] && [[ \"$env_value\" != default_value ]]; then\n echo \"[Warning] Environment variable \\`$env_key\\` might have incorrect value, make sure this was intentional:\"\n echo \" Environment Value: $env_value\"\n echo \" Default Value: $default_value\"\n fi\n\n local value=\"${env_value:-$default_value}\"\n\n if [[ -z \"$value\" ]]; then\n echo \"[Error] Unable to find $name! Set the environment variable \\`$env_key\\` and try again.\"\n exit 0\n fi\n\n echo $value\n}\n\nmain \"$@\"; exit\n";
433+
shellScript = "#!/bin/bash\n\nset -x -e\n\nexport SOURCEMAP_FILE=\"$DERIVED_FILE_DIR/main.jsbundle.map\"\n\nmain() {\n local env_path=\"$PODS_ROOT/../.xcode.env\"\n local local_env_path=\"${env_path}.local\"\n\n # Load environment variables if available\n [ -f \"$env_path\" ] && source \"$env_path\"\n [ -f \"$local_env_path\" ] && source \"$local_env_path\"\n\n if [[ \"${INSTABUG_SOURCEMAPS_UPLOAD_DISABLE:-false}\" == \"true\" ]]; then\n echo \"[Info] INSTABUG_SOURCEMAPS_UPLOAD_DISABLE is true, skipping sourcemaps upload...\" >&2\n exit 0\n fi\n\n if [[ \"${CONFIGURATION:-}\" == \"Debug\" ]]; then\n echo \"[Info] Debug build detected, skipping sourcemaps upload...\" >&2\n exit 0\n fi\n\n if [[ -z \"${INFOPLIST_FILE:-}\" || -z \"${PROJECT_DIR:-}\" ]]; then\n echo \"[Error] This script must be run from within Xcode\" >&2\n exit 1\n fi\n\n local js_project_dir=\"$PROJECT_DIR/..\"\n local sourcemap_file=\"\"\n\n # Use existing sourcemap if available\n if [[ -f \"$SOURCEMAP_FILE\" ]]; then\n sourcemap_file=\"$SOURCEMAP_FILE\"\n else\n if node -p \"require.resolve('expo/package.json')\" >/dev/null 2>&1; then\n echo \"[Info] Detected Expo project\" >&2\n sourcemap_file=$(generate_sourcemaps \"$(dirname \"$(node -p \"require.resolve('expo/package.json')\")\")\")\n else\n echo \"[Info] Detected standard React Native project\" >&2\n sourcemap_file=$(generate_sourcemaps \"$(dirname \"$(node -p \"require.resolve('react-native/package.json')\")\")\")\n fi\n fi\n\n if [[ ! -f \"$sourcemap_file\" ]]; then\n echo \"[Error] Source map file not found at: $sourcemap_file\" >&2\n exit 1\n fi\n\n echo \"[Info] Using sourcemap: $sourcemap_file\"\n\n local instabug_dir=$(dirname \"$(node -p \"require.resolve('instabug-reactnative/package.json')\")\")\n\nfind_token_script=\"$instabug_dir/scripts/find-token.sh\"\nif [ ! -x \"$find_token_script\" ]; then\n echo \"[Info] Making find-token.sh executable\"\n chmod u+x \"$find_token_script\" || {\n echo \"[Error] Failed to chmod find-token.sh\" >&2\n exit 1\n }\nfi\n\n local inferred_token=$(cd \"$js_project_dir\" && source $instabug_dir/scripts/find-token.sh)\n\n local app_token=$(resolve_var \"App Token\" \"INSTABUG_APP_TOKEN\" \"$inferred_token\" | tail -n 1)\n\n local inferred_name=$(/usr/libexec/PlistBuddy -c 'print CFBundleShortVersionString' \"$PROJECT_DIR/$INFOPLIST_FILE\")\n local version_name=$(resolve_var \"Version Name\" \"INSTABUG_APP_VERSION_NAME\" \"$inferred_name\")\n\n local inferred_code=$(/usr/libexec/PlistBuddy -c 'print CFBundleVersion' \"$PROJECT_DIR/$INFOPLIST_FILE\")\n local version_code=$(resolve_var \"Version Code\" \"INSTABUG_APP_VERSION_CODE\" \"$inferred_code\")\n\n echo \"[Info] Uploading sourcemap to Instabug...\" >&2\n node \"$instabug_dir/bin/index.js\" upload-sourcemaps \\\n --platform ios \\\n --file \"$sourcemap_file\" \\\n --token \"$app_token\" \\\n --name \"$version_name\" \\\n --code \"$version_code\"\n}\n\ngenerate_sourcemaps() {\n local base_dir=\"$1\"\n\n export RN_DIR=\"$base_dir\"\n export SOURCEMAP_FILE=\"$(pwd)/main.jsbundle.map\"\n\n source \"$base_dir/scripts/react-native-xcode.sh\"\n\n if [[ ! -f \"$SOURCEMAP_FILE\" ]]; then\n echo \"[Error] Failed to generate sourcemap at: $SOURCEMAP_FILE\" >&2\n exit 1\n fi\n\n echo \"$SOURCEMAP_FILE\"\n}\n\nresolve_var() {\n local name=\"$1\"\n local env_key=\"$2\"\n local default_value=\"$3\"\n\n local value=\"${!env_key:-$default_value}\"\n\n if [[ -n \"${!env_key:-}\" && \"${!env_key}\" != \"$default_value\" ]]; then\n echo \"[Warning] $env_key may be misconfigured. Check values below:\" >&2\n echo \" Env: ${!env_key}\" >&2\n echo \" Fallback: $default_value\" >&2\n fi\n\n if [[ -z \"$value\" ]]; then\n echo \"[Error] Could not resolve $name. Set \\`$env_key\\` in your environment.\" >&2\n exit 1\n fi\n\n echo \"$value\"\n}\n\nmain \"$@\"\n";
434434
};
435435
B77A7BA143DBD17E8AAFD0B4 /* [CP] Embed Pods Frameworks */ = {
436436
isa = PBXShellScriptBuildPhase;

0 commit comments

Comments
 (0)