-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: automate entitlements setup for development #819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RedThoroughbred
wants to merge
3
commits into
permissionlesstech:main
Choose a base branch
from
RedThoroughbred:automate-entitlements-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| #!/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 contains the generic group identifier | ||
| if grep -q "group.chat.bitchat" "$file" && ! grep -q "group.chat.bitchat.$TEAM_ID" "$file"; then | ||
| # Update the file | ||
| sed -i.tmp "s/group\.chat\.bitchat/group.chat.bitchat.$TEAM_ID/g" "$file" | ||
| rm "$file.tmp" | ||
| echo -e " ${GREEN}✅ Updated group identifier${NC}" | ||
| else | ||
| echo -e " ${YELLOW}⚠️ Already configured or no changes needed${NC}" | ||
| fi | ||
| done | ||
|
|
||
| # Verify the changes | ||
| echo -e "${BLUE}🔍 Verifying changes...${NC}" | ||
| VERIFICATION_FAILED=false | ||
|
|
||
| for file in $ENTITLEMENTS_FILES; do | ||
| filename=$(basename "$file") | ||
| if grep -q "group.chat.bitchat.$TEAM_ID" "$file"; then | ||
| echo -e " ${GREEN}✅ $filename${NC}: group.chat.bitchat.$TEAM_ID" | ||
| else | ||
| echo -e " ${RED}❌ $filename${NC}: Update failed" | ||
| VERIFICATION_FAILED=true | ||
| fi | ||
| done | ||
|
|
||
| if [ "$VERIFICATION_FAILED" = true ]; then | ||
| echo -e "${RED}❌ Some files failed to update${NC}" | ||
| echo "Backups are available in .entitlements-backup/" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "" | ||
| echo -e "${GREEN}🎉 Entitlements setup complete!${NC}" | ||
| echo "" | ||
| echo -e "${BLUE}Next steps:${NC}" | ||
| echo " 1. Review the changes: git diff" | ||
| echo " 2. Test the build: just build" | ||
| echo " 3. If issues occur, restore from backups in .entitlements-backup/" | ||
| echo "" | ||
| echo -e "${YELLOW}Note:${NC} This script updated app group identifiers for your Team ID" | ||
| echo "This ensures your development build won't conflict with other versions" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the script is re-run after the entitlements already contain a previous Team ID, the
sedcommand only replaces thegroup.chat.bitchatprefix, producing values likegroup.chat.bitchat.NEW.OLD. The subsequent verification still passes because it matches thegroup.chat.bitchat.NEWsubstring, yet the entitlements are now invalid and code signing for the new team will fail. Replace the entiregroup.chat.bitchat.*value (or remove the old suffix first) so subsequent runs with a different Team ID produce a clean identifier.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that! 👍
Fixed in 4a4556f - the script now properly replaces the entire
group.chat.bitchat.*pattern, so re-running with a different Team ID will correctly update fromgroup.chat.bitchat.OLDtogroup.chat.bitchat.NEWinstead of creating an invalidgroup.chat.bitchat.OLD.NEW.The fix handles both cases:
group.chat.bitchat→group.chat.bitchat.ABC123group.chat.bitchat.ABC123→group.chat.bitchat.XYZ789