xcpretty / xcode-install

🔽 Install and update your Xcodes
https://fastlane.tools
MIT License
2.59k stars 243 forks source link

Use built-in way to accept Xcode license on Xcode 7.3+ #277

Closed milch closed 6 years ago

milch commented 6 years ago

I have some automation scripts which install Xcode, and for some reason accepting the license was not working there the way this is currently implemented. Luckily Xcode has a built-in way to do this via sudo xcodebuild -license accept.

I confirmed that this is working at least all the way back to Xcode 7.3:

$ sudo /Applications/Xcode-9.3.app/Contents/Developer/usr/bin/xcodebuild -license accept
$ cat /Library/Preferences/com.apple.dt.Xcode.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>IDELastGMLicenseAgreedTo</key>
        <string>EA1478</string>
        <key>IDEXcodeVersionForAgreedToGMLicense</key>
        <string>9.3</string>
</dict>
</plist>
$ sudo /Applications/Xcode-9.2.app/Contents/Developer/usr/bin/xcodebuild -license
 accept
$ cat /Library/Preferences/com.apple.dt.Xcode.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>IDELastGMLicenseAgreedTo</key>
        <string>EA1478</string>
        <key>IDEXcodeVersionForAgreedToGMLicense</key>
        <string>9.2</string>
</dict>
</plist>
$ sudo /Applications/Xcode-8.3.3.app/Contents/Developer/usr/bin/xcodebuild -licen
se accept
$ cat /Library/Preferences/com.apple.dt.Xcode.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>IDELastGMLicenseAgreedTo</key>
        <string>EA1421</string>
        <key>IDEXcodeVersionForAgreedToGMLicense</key>
        <string>8.3.3</string>
</dict>
</plist>
$ sudo /Applications/Xcode-7.3.1.app/Contents/Developer/usr/bin/xcodebuild -license accept
$ cat /Library/Preferences/com.apple.dt.Xcode.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>IDELastGMLicenseAgreedTo</key>
        <string>EA1327</string>
        <key>IDEXcodeVersionForAgreedToGMLicense</key>
        <string>7.3.1</string>
</dict>
</plist>

And then installing the latest Xcode 9.4 beta 2 using these changes:

$ be xcversion install "9.4 beta 2"
######################################################################## 100.0%
Please authenticate for Xcode installation.
Password:
/Applications/Xcode-9.4.app: accepted
source=Apple System

Xcode 9.4
Build version 9Q1019a
$ cat /Library/Preferences/com.apple.dt.Xcode.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>IDELastBetaLicenseAgreedTo</key>
        <string>EA1478</string>
        <key>IDELastGMLicenseAgreedTo</key>
        <string>EA1478</string>
        <key>IDEXcodeVersionForAgreedToBetaLicense</key>
        <string>9.4</string>
        <key>IDEXcodeVersionForAgreedToGMLicense</key>
        <string></string>
</dict>
</plist>