I am trying to download Xcode from the Apple Developer site using just wget or curl. I think I am successfully storing the cookie I need to download the .dmg file, but I am
For Chrome,
From the cookies.txt download directory, load cookies into wget and start resumable download. For example, to download Xcode_7.dmg, you would run:
wget --load-cookies=cookies.txt -c http://adcdownload.apple.com/Developer_Tools/Xcode_7/Xcode_7.dmg
The answer by @petert used to work for me in the past, but now it shows the error 403 (Forbidden).
I ended up using the app Downloader-for-Apple-Developers, which is open source and has a graphic interface, to login to the Apple's developer website and download the Xcode .xip file.
This is how the graphical interface looks like: The lates version can be downloaded from here: https://github.com/vineetchoudhary/Downloader-for-Apple-Developers/releases
Here is a script that uses curl instead of wget, so it will work on a stock Mac. All you need to set is the path to the xcode DMG file. The script will ask you for your username and password and it will figure out the ACTION and WOSID values for you.
#!/bin/sh # Change this line to the URI path of the xcode DMG file. XCODE_PATH="/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg" echo "Enter your Apple Dev Center username." read -p "> " USERNAME echo "Enter your Apple Dev Center password." read -p "> " PASSWORD curl \ -L -s -k \ --cookie-jar cookies \ -A "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5" \ https://developer.apple.com/devcenter/ios/login.action \ -o login.html ACTION=$(sed -n 's/.*action="\(.*\)".*/\1/p' login.html) WOSID=$(sed -n 's/.*wosid" value="\(.*\)".*/\1/p' login.html) echo "action=${ACTION}" echo "wosid=${WOSID}" curl \ -s -k --cookie-jar cookies --cookie cookies \ -A "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5" \ -e ";auto" "https://daw.apple.com${ACTION}?theAccountName=${USERNAME}&theAccountPW=${PASSWORD}&theAuxValue=&wosid=${WOSID}&1.Continue.x=0&1.Continue.y=0" \ > /dev/null curl \ -L --cookie-jar cookies --cookie cookies \ -A "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5" \ -O https://developer.apple.com/ios/download.action?path=${XCODE_PATH} rm login.html rm cookies
I've just been down the same road after failing repeatedly to download the latest version of Xcode directly to my Mac dev machine. I also couldn't get Daniel's approach to work exactly as written.
This is what did work for me:
Used Firefox to log in to the iOS dev center
Used Cookie Exporter 1.5 to save the cookies to a text file, say "cookies.txt"
FTP'd cookies.txt to a staging server of mine that has a nice fat pipe onto the Internet
Used wget from the staging server to download the file (about 5 minutes)
Used FTP to transfer the DMG file back to my dev machine (about 2 hours)
Here is the wget command line:
wget --cookies=on --load-cookies=cookies.txt --keep-session-cookies --save-cookies=cookies.txt http://adcdownload.apple.com/ios/ios_sdk_4.1__final/xcode_3.2.4_and_ios_sdk_4.1.dmg
The trick here is to NOT use the download link from the page, but rather to start the download then use the context menu in the download list to "Copy Download Link".
Here's a little bash script to wget Xcode :
#!/bin/bash
export ID=YourAppleID
export PW=YourPW
[ -f cookies ] && rm cookies && touch cookies
2>Header \
wget \
-S \
-O R1 \
http://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2__final/xcode_3.2.5_and_ios_sdk_4.2_final.dmg
tac Header | grep Location
LOCATION=$(grep Location Header | sed -E 's/^ *Location: ([^/]+:\/\/[^/]+)\/.*$/\1/')
[ -z "$LOCATION" ] && { echo "Bad day for LOCATION...";exit;} || echo "LOCATION=$LOCATION"
rm Header
ACTION=$(grep action R1 | sed 's/^.*action="//;s/".*$//')
[ -z "$ACTION" ] && { echo "Bad day for ACTION...";exit;} || echo "ACTION=$ACTION"
POST=$( grep input R1 | sed 's/<input/\
<input/g' | grep input | sed 's/^.*name="//' | sed 's/".*value="/=/;s/".*$//' | sed '/=/!s/$/=/' | sed '/theAccountName/s/$/'$ID'/;/theAccountPW/s/$/'$PW'/' | sed '/=$/d' | sed -n '1h;1!H;${x;s/[[:space:]]/\&/g;p;}' | sed 's/$/\&1.Continue.x=0\&1.Continue.y=0/')
[ -z "$POST" ] && { echo "Bad day for POST...";exit;} || echo "POST=$POST"
2>Header \
wget \
-S \
--save-cookies cookies \
--keep-session-cookies \
-O R2 \
--post-data="$POST" \
$LOCATION/$ACTION
URL=$( grep -i REFRESH R2 | sed 's/^.*URL=//;s/".*$//' )
[ -z "$URL" ] && { echo "Bad day for URL...";exit;} || echo "URL=$URL"
wget \
-S \
--load-cookies cookies \
$URL &
sleep 1; rm R1 R2 Header cookies
Comments are the same as for joe's Solution - Thnx Joe ;o) The good idea is to start the traffic analysis from the download url of Xcode.
Maybe this is the easiest way to use curl:
Google Chrome.app
;developer.apple.com
;CMD
+SHIFT
+J
or click top-right Menu
icon -> Tools
-> Developer Tools
;Network
panel;Xcode
download link at apple.com;Network
panel;Copy as cURL
;Now, you got the curl command for this download link with cookies and other http-requeset-fields, just paste to your terminal and add -o xxx.dmg
at the end.