转发一篇文章
So, you’ve upgraded from Snow Leopard to Lion, and you’re ready to jump back into development. Watch out! MacPorts and XCode need to be updated! Apple doesn’t include XCode in the system updates, so you have to do it manually. If you installed XCode on Snow Leopard, you’re probably running XCode 3 (unless of course you bought XCode 4). The latest that ships for Lion is 4.1 and is free. Here’s how to upgrade your development environment:
Step 1: Install XCode 4.1
From the App store, find and download XCode. This will put an installer in your Applications folder. Run the installer. As of right now, there isn’t an alternative download method from Apple. If you don’t want to deal with the App store, you’ll probably have to hit the warez sites.
Step 2: Uninstall XCode 3
Installing the new XCode doesn’t replace your old one, it just moves it to a backup directory. Fire up your terminal:
sudo /Developer-old/Library/uninstall-devtools –mode=all
Remove the leftover XCode folder:
sudo rm -rf /Developer-old
At this point I needed to run the XCode 4.1 installer again because the XCode 3 uninstall removed some of the shared command line utilities.
Step 3: Remove installed ports
Make a list of your installed ports in your home folder:
port -qv installed > ~/myports.txt
Uninstall all ports
sudo port -f uninstall –follow-dependents installed
Remove any partially installed ports and archives
sudo port clean –work –archive all
Step 4: Update MacPorts
MacPorts recommends that you reinstall the base package, but as of right now there isn’t a Lion-specific installer. You should download and run the Snow Leopard installer again though.
After that, make sure you’re updated and rsynched with the MacPorts server:
sudo port -v selfupdate
sudo port upgrade obsolete
Step 5: Reinstall the ports you need
Read through the text file we created, and reinstall only the ports you need. Don’t worry about all the dependencies, they’ll be added as necessary. Make sure that if you used specific variants (the package name is followed with a +) that you install those variants. For example, I didn’t install git-core, I installed git-core +svn, so I need to now run:
sudo port install git-core +svn
Yes, even though Git and SVN are both included in XCode 4.1, I am reinstalling git. The build of Git that Apple included is quite limited, and I needed a specific extension git-svn so that I can migrate my projects from SVN to Git.
That should be it! Enjoy developing on OSX Lion!