ios Xcode:什么是简单语言的目标和方案?

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

Xcode: What is a target and scheme in plain language?

iosxcode

提问by MichiZH

Yeah the title says it :-) What do they mean in plain English language? I really don't understand the explanation on Apple's website and I need to rename my target and I'm afraid that nothing works after that..

是的,标题说明了:-) 它们在简单的英语中是什么意思?我真的不明白苹果网站上的解释,我需要重命名我的目标,恐怕在那之后没有任何作用..

回答by James Webster

I've added in Workspace and Project too!

我也添加了工作区和项目!

  • Workspace- Contains one or more projects. These projects usually relate to one another
  • Project- Contains code and resources, etc. (You'll be used to these!)
  • Target- Each project has one or more targets.
    • Each target defines a list of build settings for that project
    • Each target also defines a list of classes, resources, custom scripts etc to include/ use when building.
    • Targets are usually used for different distributions of the same project.
      • For example, my project has two targets, a "normal" build and an "office" build that has extra testing features and may contain several background music tracks and a button to change the track (as it currently does).
      • You'll be used to adding classes and resources to your default target as you add them.
      • You can pick and choose which classes / resources are added to which target.
        • In my example, I have a "DebugHandler" class that is added to my office build
      • If you add tests, this also adds a new target.
  • Scheme- A scheme defines what happens when you press "Build", "Test", "Profile", etc.
    • Usually, each target has at least one scheme
    • You can autocreate schemes for your targets by going to Scheme > Manage Schemes and pressing "Autocreate Schemes Now"
  • 工作区——包含一个或多个项目。这些项目通常相互关联
  • 项目- 包含代码和资源等(你会习惯这些的!)
  • 目标- 每个项目都有一个或多个目标。
    • 每个目标定义了该项目的构建设置列表
    • 每个目标还定义了在构建时包含/使用的类、资源、自定义脚本等的列表。
    • 目标通常用于同一项目的不同分布。
      • 例如,我的项目有两个目标,一个“普通”构建和一个“办公室”构建,它具有额外的测试功能,可能包含多个背景音乐曲目和一个用于更改曲目的按钮(就像目前那样)。
      • 您将习惯于在添加类和资源时将它们添加到默认目标。
      • 您可以选择将哪些类/资源添加到哪个目标。
        • 在我的示例中,我将一个“DebugHandler”类添加到我的办公版本中
      • 如果您添加测试,这也会添加一个新目标。
  • 方案- 方案定义了当您按“构建”、“测试”、“配置文件”等时会发生什么。
    • 通常,每个目标至少有一个方案
    • 您可以通过转到“方案”>“管理方案”并按“立即自动创建方案”来为您的目标自动创建方案

回答by BJ Homer

A targetis an end product created by running "build" in Xcode. It might be an app, or a framework, or static library, or a unit test bundle. Whatever it is, it generally corresponds to a single item in the "built products" folder.

一个目标是在Xcode运行“构建”创造的最终产品。它可能是一个应用程序、一个框架、一个静态库或一个单元测试包。不管是什么,它通常对应于“built products”文件夹中的单个项目。

A schemerepresents a collection of targets that you work with together. It defines which targets are used when you choose various actions in Xcode (Run, Test, Profile, etc.) Often, you will have just one scheme, which uses the main app target for the Run, Archive, and Profile actions, and a unit test target for the Test action. If you were building two related apps, you might have two schemes that used the same unit test bundle but different app targets.

一个方案代表目标的集合,与你一起工作。它定义了当您在 Xcode 中选择各种操作(运行、测试、配置文件等)时使用哪些目标。通常,您只有一个方案,它使用主应用程序目标来执行运行、存档和配置文件操作,以及一个测试操作的单元测试目标。如果您正在构建两个相关的应用程序,您可能有两个使用相同单元测试包但应用程序目标不同的方案。

The main benefit of schemes (introduced in Xcode 4) is that they allow you to switch between running your app and your unit tests without needing to toggle the selected target.

方案(在 Xcode 4 中引入)的主要好处是它们允许您在运行应用程序和单元测试之间切换,而无需切换所选目标。

回答by Abhinav Singh

I am a visual person, hence to explain the concept I will be using a diagram.

我是一个视觉人士,因此我将使用图表来解释这个概念。

When you have multiple targetsthey can be one-to-one matched with Xcode's Run,Test,Profile actions, this concept defines a scheme

当你有多个目标时,它们可以与 Xcode 的 Run,Test,Profile 动作一对一匹配,这个概念定义了一个方案

enter image description here

在此处输入图片说明

A targetis a version of your Project,i.e targets differ slightly in classes & resources to use during built time. A project can have multiple built time setting for separate distribution requirements.

一个目标是你的一个版本工程,即目标略有类和资源,在建的时间有差异。一个项目可以有多个构建时间设置,以满足不同的分发要求。

回答by yoAlex5

Workspace(.xcworkspace) - is a container of multiple projects. It was created as a next step of cross-project references[About]

Workspace( .xcworkspace) - 是多个projects. 它是作为[关于]的下一步创建的cross-project references

  • Workspacecontains all schemesfrom included projects
  • Workspacehandles all implicit dependencies[About]
  • Workspace包含所有schemes来自包含projects
  • Workspace处理所有implicit dependencies[关于]

Observations:

观察:

  • It is safe to work with different projects inside the same workspaceand do not catch Couldn't load Project.xcodeproj because it is already opened from another project or workspace
  • Cocoapods[About]working with workspacewhere creates Podsproject
  • 在同一个项目中处理不同的项目是安全的,workspace不会被抓住Couldn't load Project.xcodeproj because it is already opened from another project or workspace
  • Cocoapods[关于]使用workspacewhere 创建 Pods项目

Project(.xcodeproj) - It is a container for targetsand scheme. It defines code files, resources...

Project.xcodeproj) -这是一种用于容器targetsscheme。它定义了代码文件、资源...

Target- PBXNativeTargetsection. Defines a specific set of build settings that generate:

Target-PBXNativeTarget部分。定义一组特定的生成设置,生成:

  • Application target
  • Library and framework targets
  • Test
  • Aggregate[About]. E.g. it is used to create a Universal frameworkor Umbrella framework
  • Application target
  • Library and framework targets
  • Test
  • Aggregate[关于]。例如,它用于创建一个Universal frameworkUmbrella framework

Scheme- a Project'sconfiguration for action in Xcode: run, test, profile, analyzeand archive. Schemacan be sharedwhich helps you in CI, Carthage... and located:

Scheme- Project'sXcode 中的操作配置:runtestprofileanalyzearchiveSchema可以共享,这有助于您在 CI 中,Carthage...并位于:

<project_path>/<project_name>.xcodeproj/xcshareddata/xcschemes

Dependency- Targetscan have dependencies. Dependency is a source link against. These dependencies can be linked statically or dynamically[About]There are two types of them:

Dependency-Targets可以有dependencies。依赖是针对源链接的。这些依赖可以静态或动态链接[关于]它们有两种类型:

  • Explicit Dependency[About]- Source code of the dependency that is located in the same projector nested project
  • Implicit Dependency[About]- Source/closed code of the dependency that is located in the project that is a part of the same workspace.
  • Explicit Dependency[关于]- 位于同一个项目嵌套项目中的依赖的源代码
  • Implicit Dependency[关于]- 位于作为同一工作区一部分的项目中的依赖项的源代码/关闭代码。

[Vocabulary]

[词汇]