xcode 在 Info.plist 中指定设备系列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18075311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Specify device family in Info.plist
提问by Cosmin
Is there a way to specify the device family solely based on a key in Info.plist, without changing the build settings? I have read about UIDeviceFamily being added automatically to Info.plist at build time, and the documentation says that I should not add this key manually. Let's say I cannot use Xcode, but I can edit Info.plist, is there a way to specify if the app should be running only on iPhone (or iPad)?
有没有办法仅根据 Info.plist 中的键指定设备系列,而无需更改构建设置?我已经阅读了 UIDeviceFamily 在构建时被自动添加到 Info.plist 的信息,并且文档说我不应该手动添加这个键。假设我不能使用 Xcode,但我可以编辑 Info.plist,有没有办法指定应用程序是否应该只在 iPhone(或 iPad)上运行?
Thank you,
谢谢,
回答by Tony
check out the docs in UIDeviceFamily
查看 UIDeviceFamily 中的文档
if you need to only support ipad, set the DeviceFamily to 2. For iphone set to 1. For universe include both 1 and 2
如果你只需要支持 ipad,设置 DeviceFamily 为 2。对于 iphone 设置为 1。对于 Universe,包括 1 和 2
回答by Wee
As you mentioned, you should not add UIDeviceFamily in Info.plist. However, if you are generating bulid from commandline, you can set TARGETED_DEVICE_FAMILY, "1" for iPhone and "2" for iPad:
正如您所提到的,您不应在 Info.plist 中添加 UIDeviceFamily。但是,如果您从命令行生成 bulid,则可以设置 TARGETED_DEVICE_FAMILY,iPhone 为“1”,iPad 为“2”:
xcodebuild \
-target "${TARGET}" \
-configuration ${CONFIGURATION} \
-sdk iphoneos \
TARGETED_DEVICE_FAMILY="2"