views:

389

answers:

3

I have a framework of code I maintain. It's got mac and iphone objective-c code. And some of it is shared. I'm not having any problems with code. It's a problem with Xcode.

Let's just call my framework "AwesomeKit" for this problem.

The first thing I did was create an xcode Framework project called "AwesomeKit". Add source files to it, link against the common mac frameworks: foundation, cocoa, carbon, etc. It compiles fine.

Then, add a new "static library" target, let's call it "AwesomeKit-iPhone" and set the base SDK in the build settings to iphone device 3.1.3.

The problem comes when I try to add "Existing Frameworks" to the AweseomKit-iPhone target.

  • First change the current build target to AwesomeKit-iPhone.
  • Right click on any group and select "Add > Existing Frameworks..."
  • Choose UIKit.framework

UIKit will immediately be highlighted red, as if it's missing. It is indeed missing because Xcode uses the "Relative SDK" setting from the "Mac OS 10.6" SDK. When it should be using it relative to the current target's base sdk iphone device 3.1.3.

What the heck? Has anyone experienced this? This is really annoying.

A: 

I think I've seen your problem. I'm still new myself to this, but what I've found when universal static libraries for both simulators and devices is that it's best to keep the Xcode Active SDK set to "Base SDK" rather that selecting an SDK. IN that mode, the current SDK is the SDK of the currently selected target.

Active SDK is rather like overriding the sdk on the command line. If yoy set it, SDK settings on targets will be overridden.

So im my case I wanted two targets to be run at the same time, one using the simulator sdk which compiles for i386 architecture and the other pointing at the device sdk which builds a universal lib for armv6/armv7 architectures.

I have seen the red not found stuff and I seem to remember that doing this, made it go away. I also had the project SDK set to a device rather than Mac. Remember that targets override this so it's a good way to ensure that Xcode is pointing at the right sdk without effecting the settings on targets and the ultimate build.

Derek Clarkson
Thanks for the response Derek, I gave your suggestion a shot. no luck. Here's some screenshots of my setup..http://i.imgur.com/ZFRAa.png - default xcode window<br/>http://i.imgur.com/BQGOJ.png - UIKit (get info) window with paths<br/>http://i.imgur.com/yFZf6.png - current configuration drop down settings<br/>http://i.imgur.com/ZWmty.png - iPhone static lib target build settings<br/>Can you make any sense of it? It seems like there's something else in xcode that remembers that the initial project was created as a Framework project, and is always using the mac sdk as the base for paths.
bl4th3rsk1t3
looks fine to me. But check the project and target library search path settings. They can get polluted. Something is obviously still pointing at the mac sdk which is why it cant find the framework.
Derek Clarkson
A: 

I'm in the same boat right now, XCode keep tacking the wrong SDK in front of the frameworks. This is project with both OSX and iOS targets. But there's seems to be something really wrong with my Project Build settings. Your screenshots don't show them, but you may want to check them. In my case, many entries are duplicates. So I have two categories "Architectures", totally identical. If I change one, the other changes along with it. This could be related to the problem with the wrong SDK being chosen. I think the project file is corrupted, and I'm now trying to figure out if I can fix it manually.

zmippie
An update to the latest XCode fixed the problem for me. Apparantly, there was something buggy in there, and they fixed it...
zmippie
+1  A: 

I found the solution to this. You have to edit the project.pbxproj file inside of the project.xcodeproj directory. Find any entries like "SDKROOT = XXX" and change it to you real base root. It's probably best to look another project.pbxproj file that has it correctly set. I've used this on multiple occasions now and works like a charm. Usually there's 2 or more of the SDKROOT entries in project.pbxproj.

Aaron Smith