diff --git a/Justfile b/Justfile index 88cb3895d..27aec3f27 100644 --- a/Justfile +++ b/Justfile @@ -4,10 +4,12 @@ # Default recipe - shows available commands default: @echo "BitChat macOS Build Commands:" + @echo " just setup - Complete setup (check + configure entitlements)" @echo " just run - Build and run the macOS app" @echo " just build - Build the macOS app only" @echo " just clean - Clean build artifacts and restore original files" @echo " just check - Check prerequisites" + @echo " just setup-entitlements - Configure entitlements for your Team ID" @echo "" @echo "Original files are preserved - modifications are temporary for builds only" @@ -21,6 +23,15 @@ check: @security find-identity -v -p codesigning | grep -q "Apple Development\|Developer ID" || (echo "⚠️ No Developer ID found - code signing may fail" && exit 0) @echo "✅ All prerequisites met" +# Configure entitlements for your Team ID +setup-entitlements: + @echo "Configuring entitlements for your Team ID..." + @./scripts/setup-entitlements.sh + +# Complete setup process +setup: check setup-entitlements + @echo "🎉 Setup complete! Ready to build BitChat" + # Backup original files backup: @echo "Backing up original project configuration..." diff --git a/README.md b/README.md index 4e1056c91..de00db23a 100644 --- a/README.md +++ b/README.md @@ -105,17 +105,28 @@ For detailed protocol documentation, see the [Technical Whitepaper](WHITEPAPER.m - Clone the local configs: `cp Configs/Local.xcconfig.example Configs/Local.xcconfig` - Add your Developer Team ID into the newly created `Configs/Local.xcconfig` - Bundle ID would be set to `chat.bitchat.` (unless you set to something else) - - Entitlements need to be updated manually (TODO: Automate): - - Search and replace `group.chat.bitchat` with `group.` (e.g. `group.chat.bitchat.ABC123`) + - Configure entitlements: `just setup-entitlements` (automatically updates group identifiers) -### Option 2: Using `just` +### Option 2: Using `just` (Recommended for macOS) ```bash brew install just ``` -Want to try this on macos: `just run` will set it up and run from source. -Run `just clean` afterwards to restore things to original state for mobile app building and development. + Quick setup for macOS development: + ```bash + # Copy and configure your Team ID + cp Configs/Local.xcconfig.example Configs/Local.xcconfig + # Edit Local.xcconfig to add your DEVELOPMENT_TEAM ID + + # Automated setup (checks prerequisites + configures entitlements) + just setup + + # Build and run + just run + ``` + + Run `just clean` afterwards to restore things to original state for mobile app building and development. ## Localization diff --git a/scripts/setup-entitlements.sh b/scripts/setup-entitlements.sh new file mode 100755 index 000000000..7f17679db --- /dev/null +++ b/scripts/setup-entitlements.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +# BitChat Entitlements Setup Script +# Automatically configures entitlements with the correct bundle ID + +set -e # Exit on any error + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" +LOCAL_CONFIG="$PROJECT_ROOT/Configs/Local.xcconfig" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +echo -e "${BLUE}🔧 BitChat Entitlements Setup${NC}" +echo "==================================" + +# Check if Local.xcconfig exists +if [ ! -f "$LOCAL_CONFIG" ]; then + echo -e "${RED}❌ Local.xcconfig not found${NC}" + echo "Please copy Configs/Local.xcconfig.example to Configs/Local.xcconfig first" + echo "and add your DEVELOPMENT_TEAM ID" + exit 1 +fi + +# Extract the team ID from Local.xcconfig +TEAM_ID=$(grep "DEVELOPMENT_TEAM" "$LOCAL_CONFIG" | cut -d'=' -f2 | sed 's/[[:space:]]//g' | sed 's/\$(.*)//' | head -1) + +if [ -z "$TEAM_ID" ] || [ "$TEAM_ID" = "ABC123" ]; then + echo -e "${RED}❌ DEVELOPMENT_TEAM not configured${NC}" + echo "Please edit Configs/Local.xcconfig and set your Apple Developer Team ID" + echo "" + echo "Find your Team ID at:" + echo " Xcode → Preferences → Accounts → Apple ID → Team ID" + echo "" + echo "Then update Local.xcconfig:" + echo " DEVELOPMENT_TEAM = YOUR_TEAM_ID_HERE" + exit 1 +fi + +echo -e "${GREEN}✅ Found Team ID: $TEAM_ID${NC}" + +# Find all entitlements files +ENTITLEMENTS_FILES=$(find "$PROJECT_ROOT" -name "*.entitlements" -type f) + +if [ -z "$ENTITLEMENTS_FILES" ]; then + echo -e "${RED}❌ No entitlements files found${NC}" + exit 1 +fi + +echo -e "${BLUE}📝 Found entitlements files:${NC}" +for file in $ENTITLEMENTS_FILES; do + echo " $(basename "$file")" +done + +# Create backup directory if it doesn't exist +BACKUP_DIR="$PROJECT_ROOT/.entitlements-backup" +mkdir -p "$BACKUP_DIR" + +# Update each entitlements file +echo -e "${BLUE}🔄 Updating entitlements...${NC}" + +for file in $ENTITLEMENTS_FILES; do + filename=$(basename "$file") + echo -e " Processing ${YELLOW}$filename${NC}..." + + # Create backup + cp "$file" "$BACKUP_DIR/$filename.backup" + + # Check if file needs updating + if grep -q "group.chat.bitchat.$TEAM_ID" "$file"; then + echo -e " ${YELLOW}⚠️ Already configured for Team ID: $TEAM_ID${NC}" + elif grep -q "group.chat.bitchat" "$file"; then + # Replace the entire group.chat.bitchat.* pattern (handles re-runs with different Team IDs) + sed -i.tmp "s/group\.chat\.bitchat\.[^<]*/group.chat.bitchat.$TEAM_ID/g" "$file" + # Also handle the base case without any Team ID suffix + sed -i.tmp "s/group\.chat\.bitchat