在iPhone SDK 4中定位多个平台 [英] Targeting multiple platforms in iPhone SDK 4

查看:83
本文介绍了在iPhone SDK 4中定位多个平台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iPhone SDK项目,该项目应该为模拟器和ARM处理器构建一个静态库,然后将两者合并为一个通用库.

I have an iPhone SDK project that is supposed to build a static library for both the simulator and the ARM processor and then combine the two into a universal library.

在此之前,我使用的是iPhone SDK 3+,并为每个模拟器,一个模拟器和一个ARM创建了一个单独的目标,然后使用shell脚本创建了将它们结合在一起的第三个目标.每个组成目标的部署目标/构建设置均设置为其各自的体系结构等.此外,iPhone SDK 3+允许我从XCode主窗口左上角的下拉菜单中选择"Base SDK"窗口.

Heretofore, I was using iPhone SDK 3+ and accomplished this by creating a separate target for each, one simulator and one ARM, and then making a third target that combines them using a shell script. The deployment targets/build settings for each of the constituent targets are set to their respective architectures, etc. Also, iPhone SDK 3+ allowed me to select "Base SDK" from the drop down menu in the upper-left corner of the main XCode window.

一切都很出色-然后我升级到SDK 4.

Everything worked famously--then I upgraded to SDK 4.

现在,左上角的下拉菜单中没有"Base SDK"列表.另外,编译器似乎完全忽略了目标部署设置.即使将一个目标设置为"iPhone设备",将另一个目标设置为"iPhone Simulator",它们仍然按照下拉菜单中的设置进行构建.

Now, there is no "Base SDK" listing in the drop down menu in the upper-left. Also, the compiler seems to ignore the target deployment settings entirely. Even though one of the targets is set to "iPhone Device" and the other is set to "iPhone Simulator", they still build as whatever is set in the drop down menu.

如果我不太清楚,这是我们都知道并喜欢的进攻令人反感的上述菜单:

In case I've not been clear enough, here is the offensive offending aforementioned menu we all know and love:

再一次,在SDK 3中,一切运行正常.现在在SDK 4中,如果将其设置为"Device",我将为ARM构建两个库.如果将其设置为模拟器,则会为该模拟器建立两个库.

Once again, in SDK 3 everything worked perfectly. Now in SDK 4, if it's set to "Device" I get two libraries built for ARM. If it's set to simulator, I get two libraries built for the simulator.

有人知道这种Bullhonkey的解决方法吗?

Anybody know of a workaround for this bullhonkey?

非常感谢.

更新:"xcodebuild"命令行工具仍然有效,也就是说它将根据每个目标的部署参数构建正确的体系结构.

UPDATE: the "xcodebuild" command line tool still works, that is to say it will build the correct architecture according to each target's deployment parameters.

因此,我可以使用像这样调用xcodebuild的shell脚本,而不是使用XCode的GUI进行构建:

Thus, rather than using XCode's GUI to build, I can use a shell script that calls xcodebuild like so:


xcodebuild -target device-target -configuration Debug
xcodebuild -target sim-target -configuration Debug

找到一个真正的解决方案仍然很不错,但是现在可以完成工作.

It'd still be nice to find a real solution, but this will get the job done for now.

推荐答案

是的,Apple似乎正在使所有XCode控件和选项处于混乱状态.如果我接近完成一个应用程序,那么我根本不会安装Beta SDK,也不会安装GM/public SDK.我知道升级会破坏某些东西.

Yeah, Apple seems to be frobbing all the XCode controls and options. It's gotten to the point that I don't install Beta SDKs at all or GM/public SDKs if I'm close to finishing an app. I know the upgrade will break something.

无论如何,您应该能够创建一个外部目标或Shell脚本目标,以构建每个目标并将这些库链接在一起.我的bag-o-tricks库有一个类似的shell脚本.在XCode Project设置中,我已将BaseSDK设置为iPhone Device 4.0 SDK.构建脚本大致如下:

Anyway, you should be able to create an External Target or Shell Script Target that builds each and links the libs together. I have a similar shell script for my bag-o-tricks library. In the XCode Project settings, I have set the BaseSDK to the iPhone Device 4.0 SDK. The build script looks roughly like:

xcodebuild -parallelizeTargets -configuration Debug -sdk iphoneos4.0 -target StaticLibs
xcodebuild -parallelizeTargets -configuration Debug -sdk iphonesimulator4.0 -target StaticLibs
xcodebuild -parallelizeTargets -configuration Release -sdk iphoneos4.0 -target StaticLibs
xcodebuild -parallelizeTargets -configuration Release -sdk iphonesimulator4.0 -target StaticLibs
mkdir -p build/Debug-dist build/Release-dist
lipo build/Debug-iphoneos/libfoo.a build/Debug-iphonesimulator/libfoo.a -create -output build/Debug-dist/libfoo.a
lipo build/Release-iphoneos/libfoo.a build/Release-iphonesimulator/libfoo.a -create -output build/Release-dist/libfoo.a

好的,我承认,这是一个展开的版本.我的 actual 脚本具有一堆for thing in ${LIST_OF_STUFF}; do ...循环,以更好地自动化构建,复制所有包含文件并汇总整个SDK.

OK, I confess, this is an unrolled version. My actual script has a bunch of for thing in ${LIST_OF_STUFF}; do ... loops to better automated the builds, copy all the include files, and roll up a whole SDK.

我提交了核心版补丁为他们自动创建一个SDK.如果您将此修补程序用作参考,请从SDKSettings.plist中删除GCC_VERSION键/值对,否则基于它构建的应用程序将失败.

I submitted a patch to Core-Plot to automate the creation of an SDK for them. If you use this patch as a reference, remove the GCC_VERSION key/value pair from the SDKSettings.plist or apps building against it will fail.

这篇关于在iPhone SDK 4中定位多个平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆