简体   繁体   English

何时使用.xcconfig文件

[英]When to use .xcconfig files

I have just set up three different configurations in my project for debug preview and release . 我在项目中设置了三种不同的配置 ,用于debug previewrelease No in Xcode there is an option to specify different .xconfig files per configuration. 在Xcode中没有选项可以为每个配置指定不同的.xconfig文件。 I am now wondering in what circumstances they should/could be used and what their advantages are over just editing the build settings per configuration. 我现在想知道在什么情况下它们应该/可以使用以及它们的优点是仅仅编辑每个配置的build settings

Use xcconfig files if you find yourself changing the same build settings for each project you create. 如果您发现自己为您创建的每个项目更改了相同的构建设置,请使用xcconfig文件。 Place the build settings you're changing in the xcconfig file. 将您正在更改的构建设置放在xcconfig文件中。 By using a xcconfig file you can avoid editing those build settings every time you create a project. 通过使用xcconfig文件,您可以避免在每次创建项目时编辑这些构建设置。

Having the option to use different xcconfig files for each build configuration allows you to place the debug build settings you're constantly changing in one xcconfig file and place the release build settings you're changing in another xcconfig file. 可以选择为每个构建配置使用不同的xcconfig文件,这样您就可以将调试构建设置放在一个xcconfig文件中不断更改,并将要更改的版本构建设置放在另一个xcconfig文件中。 Use multiple xcconfig files if the build settings you're changing have different values for debug and release builds or if you change some build settings only for debug builds and other build settings only for release builds. 如果要更改的构建设置具有不同的调试版本和发布版本值,或者仅针对调试版本更改某些构建设置,并且仅针对版本构建更改其他构建设置,请使用多个xcconfig文件。

It's not me who you asked about an example @Besi but I would like to explain why the BundleId change is useful at least for me. 你问的关于@Besi的例子并不是我,但我想解释为什么BundleId的变化至少对我有用。

When I have different requirements for "Development", "Ad Hoc", "App Store", for example I need to send Push Notifications, so the push certificate will be different depending on the version. 当我对“开发”,“Ad Hoc”,“App Store”有不同的要求时,我需要发送推送通知,因此推送证书将根据版本而有所不同。

In this case I can make 3 different XCode schemes and depending on the chosen scheme, when compiling the bundle identifier will change so a different kind of version will result. 在这种情况下,我可以制作3种不同的XCode方案,并且根据所选择的方案,在编译包标识符时会发生变化,从而产生不同类型的版本。

Add to this the fact you can use you xcconfig to choose the "Code Sign Identity", and practically every build setting you can imagine. 除此之外,您可以使用xcconfig选择“代码签名标识”,以及几乎所有您可以想象的构建设置。 This way is more correct than having different targets for each version and with different plist files and build settings, because you avoid duplication and you can customize the way the settings should override each other. 这种方式比为每个版本和不同的plist文件和构建设置设置不同的目标更正确,因为您可以避免重复,并且可以自定义设置应该相互覆盖的方式。

Sorry if this is very convoluted, I tried responding the original question in the process. 对不起,如果这是非常复杂的,我尝试在此过程中回答原始问题。

One way I've used xcconfig files is to set up different BundleId's for iPhone apps. 我使用xcconfig文件的一种方法是为iPhone应用程序设置不同的BundleId。 That way you can have different apps with different features/servers enabled. 这样,您可以使用启用了不同功能/服务器的不同应用程序。 Very helpful. 很有帮助。 It involves using a variable name for the BundleId. 它涉及为BundleId使用变量名。

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

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