Xcode 4 - 专用配置设置:构建设置和方案定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7299202/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:52:26  来源:igfitidea点击:

Xcode 4 - Dedicated configuration settings : build settings and schemes definition

iosxcodeconfigurationbuildsettings

提问by Oliver

I'm totally lost with Xcode 4 build settings and schemes.

我完全迷失了 Xcode 4 构建设置和方案。

In Xcode 4, you have those items :

在 Xcode 4 中,你有这些项目:

A popup menuin the main project window that allow you to choose the "target" you will run/test/analyse/...

主项目窗口中的弹出菜单允许您选择将运行/测试/分析/...的“目标”

enter image description here

在此处输入图片说明

Some build settings :

一些构建设置:

enter image description here

在此处输入图片说明

The Scheme manager :

计划经理:

enter image description here

在此处输入图片说明

The scheme editor :

方案编辑器:

enter image description here

在此处输入图片说明

Using those interfaces, How may I define many schemes that have their own build settings for the project.
I mean, today, whatever I do, when I change a build setting when on a scheme, let's say "Debug for me", and select another scheme let's say "Release", the build setting is the one I've changed.

使用这些接口,我如何定义许多具有自己的项目构建设置的方案。
我的意思是,今天,无论我做什么,当我在某个方案上更改构建设置时,让我们说“为我调试”,然后选择另一个方案,让我们说“发布”,构建设置就是我更改的那个。

For example, talking about the "RUN" action, how can I have different build settings for "Release on the AppStore", some others for "release on my iPhone", and other ones for "Debug on debug team's iPhone".

例如,谈到“运行”操作,我如何为“在 AppStore 上发布”、“在我的 iPhone 上发布”以及“在调试团队的 iPhone 上调试”设置不同的构建设置。

Let's say I want to change beetween those profiles the provisionning profile, add / remove some user-defined build settings, change the iOS target, and some other stuff like this ?

假设我想在这些配置文件之间更改配置文件,添加/删除一些用户定义的构建设置,更改 iOS 目标,以及其他一些类似的东西?

All those settings would apply to all targets.
Or specific targets if I want...

所有这些设置都适用于所有目标。
或者我想要的特定目标...

How does this can be done ?

这是怎么做到的?

采纳答案by xuzhe

You don't have to make so many schemes. Even one is enough.

你不必制定那么多计划。一个就够了。

As you can see, there are "Build, Run, Test, Profile, Analyze, Archive" in scheme editor, these settings are for their actions in "Product" menu.

如您所见,方案编辑器中有“构建、运行、测试、配置文件、分析、存档”,这些设置用于“产品”菜单中的操作。

It means, when you clicked "Run" in "Product" menu, Xcode will use your "Run" settings in your scheme.

这意味着,当您在“产品”菜单中单击“运行”时,Xcode 将使用您方案中的“运行”设置。

So, as your settings in your screenshot, when you directly "Run" your App, no matter on iOS Devices or on iOS Simulator, it's always debugging.

因此,作为您在屏幕截图中的设置,当您直接“运行”您的应用程序时,无论是在 iOS 设备上还是在 iOS 模拟器上,它始终是在调试。

Also, when you choose the same scheme and clicked "Archive" in "Product" menu, Xcode will automatically use your "Archive" settings in the scheme, it would be: Release.

此外,当您选择相同的方案并单击“产品”菜单中的“存档”时,Xcode 将自动使用您在方案中的“存档”设置,即:发布。

Finally, about the "DEBUG TEAM" thing, I am not sure what do your mean, but it looks like some special code sign provisioning file for your test team?

最后,关于“调试团队”的事情,我不确定您的意思,但它看起来像是您的测试团队的一些特殊代码标志配置文件?

In this situation, you can either change your target's provisioning file setting before building or make a new target using the team provisioning file.

在这种情况下,您可以在构建之前更改目标的配置文件设置,也可以使用团队配置文件创建新目标。

If debug is not required, just "Archive" your App and choose your team provisioning file to sign your App when sharing your App using "Organizer" would be very easy.

如果不需要调试,只需“存档”您的应用程序并在使用“组织者”共享您的应用程序时选择您的团队配置文件来签署您的应用程序将非常容易。

Edited: Add some screenshot for helpIf you want have different settings for same Action "Run" as you said, you need different scheme as well.

编辑:添加一些屏幕截图以获取帮助如果您想为相同的“运行”操作设置不同的设置,那么您还需要不同的方案。

Since Xcode allow you to add different Build Configurations, there is no need to create multiple targets. Just "Add" a new Build Configuration as "Pic1" shown, "TeamDebug" for example. Edit your target to set a new provisioning file for the build configuration or what ever you want to set.

由于 Xcode 允许您添加不同的构建配置,因此无需创建多个目标。只需“添加”一个新的构建配置,如“Pic1”所示,例如“TeamDebug”。编辑您的目标,为构建配置或您想要设置的任何内容设置新的配置文件。

Pic1

图1

Then create a new scheme and edit your "Run" settings, choose the Build Configuration you've created before.

然后创建一个新方案并编辑您的“运行”设置,选择您之前创建的构建配置。

Pic2

图2

And you are ready to go.

你准备好了。

P.S. In Xcode 4, use "Archive" to build, find the App just builded in "Organizer", choose "Submit" to submit is a better way to release your App to App Store. Or you can also choose "Share" to share your App to the test team.

PS 在 Xcode 4 中,使用“Archive”构建,在“Organizer”中找到刚刚构建的 App,选择“Submit”提交是将您的 App 发布到 App Store 的更好方式。或者您也可以选择“分享”将您的 App 分享给测试团队。

Hope this Answer can help you out, If it dose, a vote up or choose it as the correct answer would be very appreciated.

希望这个答案可以帮助你,如果它剂量,投票或选择它作为正确答案将不胜感激。

回答by keno

If you want to have different build settings for different scenarios, what you want is different targets.

如果你想针对不同的场景有不同的构建设置,你想要的是不同的目标。

Create a target that defines the various settings for your build. After you create the target, you then create a scheme that uses that target.

创建一个定义构建的各种设置的目标。创建目标后,然后创建使用该目标的方案。

Have a read of Xcode Conceptsas well.

也请阅读Xcode 概念