开发者

"Relative to Current SDK" doesn't work mixing Mac Framework and iPhone static library

开发者 https://www.devze.com 2022-12-28 16:46 出处:网络
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.

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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消