Skip to content

Commit

Permalink
Add support for bazel run for ios_application with tree artifacts
Browse files Browse the repository at this point in the history
- Currently only takes effect when this define is specified but I assume will tbe the default at some point `--define=apple.experimental.tree_artifact_outputs=1`

RELNOTES: Add support for `bazel run` for `ios_application` when using tree artifact outputs

Closes #362.

RELNOTES: None
PiperOrigin-RevId: 239582826
  • Loading branch information
rahul-malik authored and sergiocampama committed Mar 21, 2019
1 parent cb2631b commit a75252a
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions apple/internal/templates/ios_sim.template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ readonly TEMP_DIR=$(mktemp -d "${TMPDIR:-/tmp}/bazel_temp.XXXXXX")

trap 'rm -rf "${TEMP_DIR}"; CleanupSimulator ${TEST_DEVICE_ID}' ERR EXIT

readonly APP_DIR="${TEMP_DIR}/extracted_app"
mkdir "${APP_DIR}"

KillAllDevices

# Get the developer path, like: /Applications/Xcode.app/Contents/Developer
Expand Down Expand Up @@ -149,12 +146,28 @@ touch "${RUN_LOG}"
export SIMCTL_CHILD_GSTDERR="${RUN_LOG}"
export SIMCTL_CHILD_GSTDOUT="${RUN_LOG}"

unzip -qq '%ipa_file%' -d "${APP_DIR}"
readonly APP_PARENT_DIR="${TEMP_DIR}/extracted_app"
mkdir -p "$APP_PARENT_DIR"

if [[ -d '%ipa_file%' ]]; then
# App bundles are directories with the .app extension
# simctl won't install symlinks so rsync to resolve them
rsync -rL '%ipa_file%' "${APP_PARENT_DIR}"
readonly APP_DIR="${APP_PARENT_DIR}/$(basename '%ipa_file%')"
else
# The app bundle is contained within an compressed archive (zip)
# Unpack the archive
# TODO(kaipi): Remove this branch once tree artifacts are the default and only
# option.
unzip -qq '%ipa_file%' -d "${APP_PARENT_DIR}"
# The zip file contains a Payload directory that is the parent of the .app directory.
readonly APP_DIR="${APP_PARENT_DIR}/Payload/%app_name%.app"
fi

xcrun simctl install "$TEST_DEVICE_ID" "${APP_DIR}/Payload/%app_name%.app"
xcrun simctl install "$TEST_DEVICE_ID" "${APP_DIR}"

# Get the bundle ID of the app.
readonly BUNDLE_INFO_PLIST="${APP_DIR}/Payload/%app_name%.app/Info.plist"
readonly BUNDLE_INFO_PLIST="${APP_DIR}/Info.plist"
readonly BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${BUNDLE_INFO_PLIST}")

USER_NAME=${USER:-"$(logname)"}
Expand Down

0 comments on commit a75252a

Please sign in to comment.