@@ -12,6 +12,7 @@ DEFAULT_TEAM_ID="AKK7J2GV64"
1212if [ -f " $TEAM_ID_FILE " ]; then
1313 rm " $TEAM_ID_FILE "
1414fi
15+ mkdir -p " $( dirname " $TEAM_ID_FILE " ) "
1516echo " // This file was automatically generated, do not edit directly." > " $TEAM_ID_FILE "
1617echo " " >> " $TEAM_ID_FILE "
1718echo " DEVELOPMENT_TEAM=$DEFAULT_TEAM_ID " >> " $TEAM_ID_FILE "
@@ -27,9 +28,8 @@ TEAM_INFO_RESULT=""
2728
2829function get_team_info_array() {
2930 local XCODEPREFS=" $HOME /Library/Preferences/com.apple.dt.Xcode.plist"
30- local team_info
3131
32- # Get all team infos and format as key-value pairs
32+ # Get all team infos from IDEProvisioningTeamByIdentifier, for Xcode versions after 16.0
3333 local all_keys=($( /usr/libexec/PlistBuddy -c " Print :IDEProvisioningTeamByIdentifier" " $XCODEPREFS " | grep ' = Array' | awk ' {print $1}' ) )
3434 local result=" "
3535 for key in " ${all_keys[@]} " ; do
@@ -44,9 +44,15 @@ function get_team_info_array() {
4444 return 0
4545 fi
4646
47- # Fallback to old method: IDEProvisioningTeams
47+ # Get all team infos from IDEProvisioningTeams, for Xcode versions prior to 16.0
48+ # More info: https://support.apple.com/en-us/121239#:~:text=CVE%2D2024%2D40862:%20Guilherme%20Rambo%20of%20Best%20Buddy%20Apps%20(rambo.codes)
4849 local found=false
49- TEAM_KEYS=(` /usr/libexec/PlistBuddy -c " Print :IDEProvisioningTeams" " $XCODEPREFS " | perl -lne ' print $1 if /^ (\S*) =/' ` )
50+ # Check if IDEProvisioningTeams exists before trying to read it
51+ if /usr/libexec/PlistBuddy -c " Print :IDEProvisioningTeams" " $XCODEPREFS " > /dev/null 2>&1 ; then
52+ TEAM_KEYS=(` /usr/libexec/PlistBuddy -c " Print :IDEProvisioningTeams" " $XCODEPREFS " | perl -lne ' print $1 if /^ (\S*) =/' ` )
53+ else
54+ TEAM_KEYS=()
55+ fi
5056 for KEY in ${TEAM_KEYS[@]} ; do
5157 i=0
5258 while true ; do
0 commit comments