Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions packages/thinking-orbs/ports/ios/ThinkingOrbsDemo/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,26 @@ cd "$(dirname "$0")"

DEVICE="${1:-booted}"

# The three-argument form of awk's match() is a GNU extension, and macOS
# ships BSD awk -- which is every machine this script runs on, so the old
# inline awk printed nothing and xcodebuild got an empty destination id.
device_udid() {
uuid='[0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}'
if [ "$1" = "booted" ]; then
xcrun simctl list devices | grep '(Booted)' | grep -Eo "$uuid" | head -1
else
xcrun simctl list devices | grep "$1" | grep -Eo "$uuid" | head -1
fi
}

echo "==> generating project"
xcodegen generate >/dev/null

echo "==> building"
xcodebuild -project ThinkingOrbsDemo.xcodeproj \
-scheme ThinkingOrbsDemo \
-sdk iphonesimulator \
-destination "id=$(xcrun simctl list devices | awk -v d="$DEVICE" '
d=="booted" && /\(Booted\)/ {match($0,/\(([0-9A-F-]{36})\)/,m); print m[1]; exit}
d!="booted" && $0 ~ d {match($0,/\(([0-9A-F-]{36})\)/,m); print m[1]; exit}')" \
-destination "id=$(device_udid "$DEVICE")" \
-derivedDataPath ./build build | grep -E "error:|BUILD" || true

APP="./build/Build/Products/Debug-iphonesimulator/ThinkingOrbsDemo.app"
Expand Down