Downloading XCode using wget or curl
Josh thinks too simple-mindedly. The URL to download Xcode is indeed http://developer.apple.com/iphone/download.action?path=%2Fios%2Fios_sdk_4.0.2__final%2Fxcode_3.2.3_and_ios_sdk_4.0.2.dmg
However, you must be authenticated to download the file.
Now both Wget and cURL support cookies, but I've never used cURL for downloads so here's a couple of lines using Wget to first authenticate into the developer site (storing the authentication cookies in a cookies.txt file), then another line to actually grab the download (recalling that same cookies.txt file):
wget --post-data="theAccountName=YOURUSERNAME&theAccountPW=YOURPASSWORD" --cookies=on --load-cookies=cookies.txt --keep-session-cookies --save-cookies=cookies.txt https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/67/wo/99OWdOWyhWA2pMdrPemdSw/0.5.3.1.1.2.1.1.3.1.1
wget --cookies=on --load-cookies=cookies.txt --keep-session-cookies --save-cookies=cookies.txt http://developer.apple.com/iphone/download.action?path=%2Fios%2Fios_sdk_4.0.2__final%2Fxcode_3.2.3_and_ios_sdk_4.0.2.dmg
Be sure to change YOURUSERNAME and YOURPASSWORD to the appropriate values, and change the path to the cookies.txt file if so desired. Also, note the URL of the login form might change, so be sure to check the action attribute of the login form from your browser if this fails to work.
I tested this on my server, and the download took about 40 minutes. It worked a treat!
Single command, using stock Mac OS X 10.6.6 command line tools (bash
, curl
and sqlite3
).
curl -b <(sqlite3 -separator $'\t' ~/Library/Application\ Support/Google/Chrome/Default/Cookies "select host_key, 'TRUE','/', 'FALSE', expires_utc, name, value from cookies where host_key like '%apple.com%'") http://adcdownload.apple.com/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg
Caveats:
This uses a query of Google Chrome's sqlite cookie database.
You need to login via Apple's Xcode developer page with the browser first so that the cookies get set.
Notes:
<() is bash's Process Substitution operator and does away with the instantly-stale temporary cookies file.
If, like me, you are resuming a stalled browser download, and you have the file, use these arguments:
-C - -o unconfirmed\ 21043.crdownload
Now that you have Xcode, you can install Homebrew, and then wget. ;)