-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch-moji.command
More file actions
executable file
·75 lines (66 loc) · 2.3 KB
/
Copy pathlaunch-moji.command
File metadata and controls
executable file
·75 lines (66 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/zsh
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_PATH="$ROOT_DIR/moji/moji.xcodeproj"
SCHEME="moji"
BUILD_DIR="$ROOT_DIR/.build"
APP_PATH="$BUILD_DIR/Build/Products/Release/moji.app"
MOJI_TEAM_ID="${MOJI_DEVELOPMENT_TEAM:-}"
if ! command -v xcodebuild >/dev/null 2>&1; then
echo "xcodebuild was not found. Install Xcode or the Xcode Command Line Tools first."
exit 1
fi
echo "Building Moji..."
SIGNING_ARGUMENTS=()
if [[ -n "$MOJI_TEAM_ID" ]]; then
SIGNING_ARGUMENTS+=(DEVELOPMENT_TEAM="$MOJI_TEAM_ID")
fi
if ! xcodebuild \
-project "$PROJECT_PATH" \
-scheme "$SCHEME" \
-configuration Release \
-derivedDataPath "$BUILD_DIR" \
"${SIGNING_ARGUMENTS[@]}" \
build; then
echo
echo "========================================"
echo " Build failed"
echo "========================================"
echo "Review the xcodebuild error above for the actual cause."
exit 1
fi
if ! codesign --verify --deep --strict "$APP_PATH"; then
echo "The built app does not have a valid code signature."
exit 1
fi
if codesign -dvv "$APP_PATH" 2>&1 | grep -q '^Signature=adhoc$'; then
echo
echo "========================================"
echo " Build failed: signing is not stable"
echo "========================================"
echo "Xcode produced a Sign to Run Locally build."
echo "Select an Apple Development team in Xcode so macOS can retain Moji's permissions."
exit 1
fi
APP_EXECUTABLE="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$APP_PATH/Contents/Info.plist")"
if pgrep -x "$APP_EXECUTABLE" >/dev/null 2>&1; then
echo "Stopping the existing $APP_EXECUTABLE process..."
pkill -x "$APP_EXECUTABLE"
for _ in {1..20}; do
pgrep -x "$APP_EXECUTABLE" >/dev/null 2>&1 || break
sleep 0.1
done
if pgrep -x "$APP_EXECUTABLE" >/dev/null 2>&1; then
echo "Could not stop the existing $APP_EXECUTABLE process."
exit 1
fi
echo "Existing process stopped."
else
echo "No existing $APP_EXECUTABLE process found."
fi
echo
echo "========================================"
echo " Build complete — launching Moji"
echo "========================================"
open "$APP_PATH"
echo "Moji is running. Use its Accessibility button to request the required macOS permission."