joltup / react-native-threads

Create new JS processes for CPU intensive work
MIT License
756 stars 142 forks source link

Release mode build phase Xcode #142

Closed mfbx9da4 closed 2 years ago

mfbx9da4 commented 2 years ago

Hi thanks for the library.

I'm trying to add a build phase to Xcode so that the bundle is automatically released. Do you have any guidance for this?

This is my current attempt. Presumably I need to add output files?

image
mfbx9da4 commented 2 years ago

I managed to get this to work

  1. Ensure the step is before the step "Copy bundle and resources"

    image
  2. Here is my code for the actual shell script

set -e

export NODE_BINARY=node

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

REACT_NATIVE_DIR=../node_modules/react-native

# Find path to Node
# shellcheck source=/dev/null
source "$REACT_NATIVE_DIR/scripts/find-node.sh"

# check and assign NODE_BINARY env
# shellcheck source=/dev/null
source "$REACT_NATIVE_DIR/scripts/node-binary.sh"

node ../node_modules/react-native/local-cli/cli.js bundle --dev false --minify false --assets-dest ./ --entry-file ./index.worker.js --platform ios --bundle-output ./index.worker.jsbundle
image

I was inspired by how react native do this internally