简体   繁体   English

同一Xcode项目文件中的Cocoa(OSX)和CocoaTouch(iPhone)组件?

[英]Cocoa (OSX) and CocoaTouch (iPhone) components in the same Xcode project file?

Is it possible to have an Xcode project file which contains both the Cocoa (MacOSX) and CocoaTouch (iPhone) versions of a component? 是否有可能同时包含组件的Cocoa(MacOSX)和CocoaTouch(iPhone)版本的Xcode项目文件?

I thought I was getting close until I realized that you need to set "Base SDK for All Configurations" in the Project Settings in order for the cross-compiler to be called (and for any CocoaTouch frameworks to be found and properly handled by Xcode). 我以为我接近了,直到我意识到您需要在项目设置中设置“所有配置的基本SDK”,以便调用交叉编译器(以及Xcode找到并正确处理任何CocoaTouch框架) 。

Since that is a project-wide setting, I don't know how I can have both MacOSX and iPhoneOS targets in the same project file. 由于这是项目范围的设置,因此我不知道如何在同一项目文件中同时拥有MacOSX和iPhoneOS目标。

Specifying: 指定:

SDKROOT = iphoneos3.0

in an xcconfig file (used by iPhone-only targets) did not seem to work. 在xcconfig文件中(仅用于iPhone的目标使用)似乎不起作用。

Yes, you can, but there are some glitches. 是的,可以,但是存在一些故障。

Okay first off, you can override any Base SDK in several ways. 首先,您可以通过多种方式覆盖任何基本SDK。 One is that you can on the gear at the bottom of the inspector and "Add Build Setting Condition" which lets you conditionalize any build settings based on things like the target architecture, etc. 一种是您可以在检查器底部使用“ Add Build Setting Condition”(添加构建设置条件),它可以使您根据目标体系结构等条件对任何构建设置进行条件化。

Second, even if you have a project wide setting, it can been overriden per target. 其次,即使您具有项目范围的设置,也可以按每个目标覆盖它。 So if you have seperate targets you can just add an SDKROOT to the to the various targets with their SDKROOT. 因此,如果您有单独的目标,则只需将SDKROOT添加到带有其SDKROOT的各个目标即可。

Third, the SDK selected in the popup in your Xcode window overrides evertyhing else. 第三,在Xcode窗口的弹出窗口中选择的SDK会覆盖其他所有内容。 So if you have something besides "Base SDK" in that popup it will get used. 因此,如果在该弹出窗口中除了“ Base SDK”之外还有其他东西,它将被使用。 Also, if you do switch that (lets say from "Base SDK" to "iPhone Simulator") and then you switch targets to a target that does not support the currently selected SDK it will appear to deselect, but it doesn't actually correctly autorevert the Base SDK, you need to reselect it in the pop up. 另外,如果您确实进行了切换(例如,从“基本SDK”切换为“ iPhone模拟器”),然后将目标切换为不支持当前选定的SDK的目标,它将似乎被取消选择,但实际上并没有正确自动还原基本SDK,您需要在弹出窗口中重新选择它。

I still can't consistently get multiple archs building together properly as part of an aggregate (for instance, having an OS X target that preprocesses some resource built so that it can be used as a build phase in a later target building an iPhone app). 我仍然无法始终如一地将多个拱形结构正确地作为一个集合体一起构建(例如,拥有一个OS X目标,该目标可以预处理一些构建的资源,以便可以在以后构建iPhone应用程序的目标中用作构建阶段) 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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