简体   繁体   中英

Build error using Xcode project with OS X framework target and iOS static library target

I'm writing a library of reusable code intended for both OS X and iOS. I created an Xcode project with 2 targets. One target is a framework for OS X. The other is a static library for iOS.

I discovered that builds of the OS X framework target are trying to use the iOS headers. I know this because TARGET_OS_IPHONE is defined causing the build to attempt to find UIKit.h, etc. This of course causes builds for the framework target to fail since the OS X framework target does not link to iOS frameworks.

I checked the build settings for the OS X framework target for goofiness but found nothing. The base SDK is set as "Mac OS X 10.6". Note when I created the Xcode project, I used the Cocoa Framework template then later added the iOS static library target.

What else could cause the OS X framework target to use the wrong SDK?

Thanks, -KIRBY

Your issue is that Xcode's gotten confused. Option click on the Overview popup and reset your Active SDK to Base SDK. You'll probably find that the Mac target is set to one of the iOS targets, which ends up causing all sorts of hilarity as you've seen

I am doing something very similar to what you describe. I have several private frameworks that are shared between our iOS app and our OS-X app. Each such framework resides in its own project, with two targets. A Mac-OS dynamic frameworks, and a special iOS "static framework" using a special template we added to Xcode - it's an open source project Karl Stenerud's iOS universal iOS framework Now I never experienced the goofiness you describe, and I'm sure it's just something you mistakenly deleted (or added) in the project/target settings.

What I'll recommend as a "debugging method" for the project settings is this.

Have a nice text editor open for you. Go to the build-settings of the iOS static lib for instance. Choose the "All" and "Combined" buttons. Now select all the lines and Copy (command-C). Go to the text editor, and paste. You'll have a nice text description of all the settings.

Now create a new template project in Xcode, and do the same into another text file. Now compare these files, for discrepancies.

Do this on all 3 levels. 1. Project level settings 2. iOS static lib settings 3. OS-C framework.

I've had some goofy issues putting both a Mac and iPhone target in the same Xcode project file, much like what you describe in your question and accompanying comment. My solution is to have a separate Xcode project file for Mac and iOS. You can still share files between the projects, although you have to keep each one individually updated, but it results in less glitchy behavior.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM