Question: I have an existing project that I was working on, and I recently decided to update my iPhone SDK and updated to the latest 3.0 SDK.

I update my SDK and go to open my existing project. Sure enough, there are some problems including some certificate problems and so on. Anyway, google and I were able to solve most of them, but I haven't had any luck on what I hope to be the last of my problems.

When running my program in the simulator, I now get

> 
> dyld: Library not loaded:
>  /System/Library/Frameworks/UIKit.framework/UIKit
>  Referenced from:
>  /Developer/iGameLib/iGameLib/build/Debug-iphonesimulator/iGameLib.app/iGameLib Reason: image not found
> 
> 
> 

Now, I discovered the UIKit has moved to 

> 
> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0sdk/
>  System/Library/FrameWorks/UIKit
> 
> 
> 

and I have updated my target and project settings to point to that new framework location, but still when I build it, no luck.

I have also tried clearing out the simulator's applications and settings, still no luck.

The referencing .app is cleared when I run the "clean" menuitem, I have confirmed this, so clearly something in my project settings are still pointing to use the old UIKit location.

**Where should I be looking?**

I've gone as far as I can to help myself but I'm afraid I'm at a loss here. I don't see it under the target settings, or the project settings, or the plist, or any of the other files within my project.

Answer: 
OK, SO I HAVE THE ANSWER!!!

Quite simply, Xcode is not changing all of the variables correctly in the actual .xcodeproj file. So, here are the steps I took.

Get out of Xcode, you've got to do this job at the terminal. Bring up a terminal and go to where your project is. Find your .xcodeproj and go into it as if it were a directory. It looks like an actual file in finder, but it is one of those package directories. 

Now, I couldn't get textedit to allow me to edit it, but you can go into nano, so like I did

sudo nano project.pbxproj which is under my .xcodeproj file/folder/package/whatever. 

In this file, you need to find where the SDKROOT is set. Chances are there are a few places it is referenced, but you're looking for SDKROOT = iphoneos2.2.1 or something similar. Change ALL OF THESE (there are a few) to SDKROOT = iphoneos3.0

Now, you're half way there. do ctrl x and save the file. Next you're going to do ls and find out what the .pbxuser file is. Mine is myname.pbxuser. run the same command of 

sudo nano myname.pbxuser

In this file, there are a HUGE number of references to the 2.1 iphone sdk directory. Do a search/replace of iPhoneSimulatorOLDVERSION.sdk, in my case it was iPhoneSimulator2.1.sdk
and change the 2.1 to 3.0. Be very careful with this though, I wouldn't want to know what happens when you mess this file up. 

Save it and open xcode. CLEAN the project and build and run. Presto!
I had the same problem using Xcode 3.2.1 but it was solved in an easier manner. I realized I had recently disabled my target's environment variables, specifically ones to do with memory debugging (NSDebugEnabled, NSZombieEnabled, NSAutoreleaseFreedObjectCheckEnabled, MallocStackLogging, MallocStackLoggingNoCompact). The app ran once in the simulator after removing the environment variables but never again after that.

Quitting Xcode, the Simulator, restarting Xcode and doing a complete clean of the target (including it's dependencies off course) brought me back to a good state.