-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
62 lines (51 loc) · 2.77 KB
/
setup.sh
File metadata and controls
62 lines (51 loc) · 2.77 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
#!/bin/bash
# A script to automate the setup process for the macOS-Chrome-Native-Messaging-Chat project.
# It builds the app, finds the executable, and installs the native messaging manifest.
# Exit immediately if a command exits with a non-zero status.
set -e
echo "Starting setup for macOS-Chrome-Native-Messaging-Chat..."
# --- 1. Build the Xcode project ---
echo -e "\n[1/4] Building the native macOS application (this may take a moment)..."
xcodebuild -project native-macos-app-one/native-macos-app-one.xcodeproj \
-scheme native-macos-app-one \
-configuration Debug \
-quiet \
clean build
echo "Build complete."
# --- 2. Find the executable path ---
echo -e "\n[2/4] Finding the application executable..."
# Find the most recent build directory for this project to avoid issues with old builds.
BUILD_DIR=$(find ~/Library/Developer/Xcode/DerivedData -name "native-macos-app-one-*" -type d -d 1 | sort -n | tail -1)
EXECUTABLE_PATH="$BUILD_DIR/Build/Products/Debug/native-macos-app-one.app/Contents/MacOS/native-macos-app-one"
if [ ! -f "$EXECUTABLE_PATH" ]; then
echo "Error: Could not find the executable. Please make sure the Xcode build was successful by running it once in Xcode."
exit 1
fi
echo "Found executable."
# --- 3. Configure and Install the Native Messaging Host Manifest ---
echo -e "\n[3/4] Configuring and installing the native messaging manifest..."
HOSTS_DIR="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts"
MANIFEST_NAME="com.example.native_app.json"
MANIFEST_SOURCE_PATH="chrome-extension/$MANIFEST_NAME"
MANIFEST_DEST_PATH="$HOSTS_DIR/$MANIFEST_NAME"
# Create the target directory if it doesn't exist
mkdir -p "$HOSTS_DIR"
# Create a temporary manifest with the correct executable path
# Using a different sed delimiter (#) because the path contains slashes (/)
sed "s#/ABSOLUTE/PATH/TO/YOUR/NATIVE/APP/EXECUTABLE#$EXECUTABLE_PATH#" "$MANIFEST_SOURCE_PATH" > "$MANIFEST_DEST_PATH"
echo "Manifest installed at $MANIFEST_DEST_PATH"
# --- 4. Final Instructions ---
echo -e "\n[4/4] Almost done! Please complete the following manual steps:"
echo ""
echo "1. Open Chrome and navigate to chrome://extensions"
echo "2. If it's not already on, enable 'Developer mode' in the top-right corner."
echo "3. Click 'Load unpacked' and select the 'chrome-extension' directory from this project."
echo "4. The 'Native App Communicator' will appear. Copy its Extension ID."
echo ""
echo "5. Open the installed manifest file. You can run this command in a new terminal:"
echo " open \"$MANIFEST_DEST_PATH\""
echo ""
echo "6. In the file, replace 'YOUR_CHROME_EXTENSION_ID' with the ID you just copied."
echo "7. Save the file."
echo ""
echo "All set! Run the app from Xcode (Cmd+R), click the extension icon in Chrome, and start chatting."