So, Safari’s resume facility is just awful — it’ll randomly restart downloads from the beginning, clobbering anything that’s already been downloaded, and the resume button will frequently disappear entirely and mysteriously from the downloads window. And if the session has expired, it’ll cause all kinds of havoc.
Anyone downloading the gazillion-gb iOS/Mac SDK + XCode on a slow and/or expensive connection will know the sheer fisticuffs-inspiring irritation this creates — speaking personally, living on a mobile broadband connection that’s usually changed at £3 per gig and often runs about as fast as I could send the data via carrier pigeon, this usually makes me want to storm Cupertino with a pitchfork.
Okay, so I could probably use Firefox or something else, but instead I figured I’d whip up* a shell script that lets me use my favoured long-haul download tool – curl. And in case there were any other sufferers of insanely-priced broadband and Safari’s antisocial behaviour, I thought I’d share it.
It’ll ask for your Apple ID and password, and store it in the keychain for you, and it’ll resume from the current working directory.
Chuck it somewhere like /usr/local/bin
, make sure it’s executable (chmod +x /usr/local/bin/adc_download.sh
) and call it from Terminal like:
adc_download.sh https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4_gm_seed/xcode_4_gm_seed_.dmg
If you’ve already started the download in Safari, just grab the partially-downloaded file from within the .download package Safari creates.
Here ’tis:
ADC Download Script (on Github)
P.S. I’d be interested to see how incremental updates fare when transferred from an intermediate server with rsync. It’s rather bizarre that Apple reissue the whole 3.x gb SDK with each update, rather than offering a ‘patch’ (I guess Apple lives blithely in the world of cheap bandwidth!), and it makes me wonder whether there’d be sufficient correlation between versions to save some bandwidth by avoiding transferring the similarities…
* read: spend hours on, as is my way.
Safari resumed my Xcode4GM download just fine when I saw my download speed had dropped to almost nothing. Restarting resumed from the right place but with a different server so my speed was better.
Yes, it does resume fine from time to time, especially if you restart immediately. I suspect the failure’s related to session expiry, and possibly quitting Safari.
Thank you for the script. It is also really useful for cheap broadband connection that are really instable (such as my connection that I have to restart every hour or so).
No worries! I’m glad to hear it’s of use to someone else too!
Thanks Michael, awesome script! The really cool part was I didn’t need to do anything besides downloading and running the script.
My download always ended up dying in Chrome.
Has anyone used this script to download XCode 4..2 and SDK 4.3? I cannot for the life of me get it to work. I keep getting an “Access Denied” message returned.
I have double-checked my Apple ID and password, removed the “daw…” entries from Keychain, removed the adccookies.txt and tried every combination I can think of and no dice.
Here’s the URL i’m trying to use– is it wrong?
http://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.3__final/x code_4.0.2_and_ios_sdk_4.3_final.dmg
This appears to be either the wrong URL, or an issue with ADC – I’m getting the same “Access Denied” message even when I try to access the URL with Chrome.
To fix this:
Proceed with download.
Hmm… not sure where I got that URL from. Logged in again and got this URL, appears to be working:
https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/x code_4.0.2_and_ios_sdk_4.3/xcode_4.0.2_and_ios_sdk_4.3.dmg
Thanks Mike, after wasting one full day on firefox and finally getting checksum error with the dmg ,I have switched to your script..hope it will run good tomorrow when its over !
Great script, but doesn’t work for me as I get a web page asking which of the multiple teams I want the download for :-(
Dude, sweet. This is just awesome. Many thanks.
For a while, this was working for me, even though I’m on multiple teams, but now I’m seeing the same issue as Sam Joseph: it only serializes out the team picker page. Darn.
Bugger. I’ll take a peek next time!
I took a bit more of a look at their form: it looks like the intermediate form they toss up wants a simple POST to http://developer.apple.com/devcenter/saveTeamSelection.action with a teams selection. I haven’t quite been able to suss out how to get curl to send this POST across the wire, though. Let me know if you need anything in the way of saved pages from the login process.
Woo, got it working. Check out https://gist.github.com/66e72a517408d962d999 (I’ll send you an email with the gist link too)
Oh, lovely work, Christopher. I’ll work this into the script.
Life saver.. Thanks for the work.
Works great here.
Glen.
adc_download.sh: line 86: syntax error near unexpected token
fi' adc_download.sh: line 86:
fi’Snow Leopard 10.6.2
Oh, my – dunno how that happened, but an invalid character crept in there, perhaps when someone added a feature to it. I just fixed it; try again.
I’m creating a Mountain Lion bootstrap script and this is a life saver!
Just wondering if you have this script in a vcs somewhere? I see you have a GitHub account, but could not find it there. This would make it easier to link to a specific version so my script does not stop working if adc_downloader.sh is changed in a non-backwards compatible way.
Hey Stig – there is now.
Thank you, now I can update my link :-)
One more modification needed: Change the team login URL to https.
teamloginURL=”https://developer.apple.com/devcenter/saveTeamSelection.action”
Hi , I’m new to mac terminal . in recent days I’ve tried to download xcode 4.6 and everytime it finishes download the dmg file change to an 8kb file name login.html! I wanted to use your script to dowload it . I copied your script to my /usr/bin and ran it in terminal like this :
adc_download.sh http://adcdownload.apple.com/Developer_Tools/xcode_4.6/xcode460417218a.dmg
but every time I get this error : “0Warning: Failed to create the file xcode460417218a.dmg:permission denied” and “curl:(23) Failed writing body(0!=1130)”
I’ll appreciate if you can help me with this . thanks
I put the script in my admin user directory ( not usr/bin) and it worked but after downloading 1.7GB dmg of xcode , I get the error that the image data is corrupted! :(
hey, michael I really have no idea how to do this. my problem is I can’t resume the download of a certain movie (1.1gb out of 1.8gb already). how do I use the script. I really can’t understand. sorry. if you could please explain in english ’cause I’m a noob T ^ T
Awesome script!