Xcode编译出现Test Target源文件报错
博客专区 > yoyoso 的博客 > 博客详情
Xcode编译出现Test Target源文件报错
yoyoso 发表于3年前
Xcode编译出现Test Target源文件报错
  • 发表于 3年前
  • 阅读 2495
  • 收藏 0
  • 点赞 0
  • 评论 2

标题:腾讯云 新注册用户域名抢购1元起>>>   

有几次遇到从网上下载到的iOS开源代码编译报错,报错位置为Test Target的源文件,我就挺奇怪我又没做测试为啥会编译Test Target的源文件,之前的暴力解决方法是把Test Target直接删掉。

未免太暴力了点,删除了还不好恢复,我想换一个方法来解决。首先就是要弄明白为啥会编译Test Target源文件。摸索了一下,找到了原因:选择Xcode左上角Simulator/Device左侧的Scheme名,在下拉列表里选择Edit Scheme,随后选择Build选项,可以看到里面有Test Target,并且勾选了对应的Run选项。取消勾选Test Target的Run选项,再重新Build,就不会报错了。

至于Test Target源文件中的代码问题,以后再解决了。

关于Scheme、Target、Workspace的一些信息如下:

------------------Scheme------------------

An Xcode scheme defines a collection of targets to build, a configuration to use when building, and a collection of tests to execute.
You can have as many schemes as you want, but only one can be active at a time. You can specify whether a scheme should be stored in a project—in which case it’s available in every workspace that includes that project, or in the workspace—in which case it’s available only in that workspace. When you select an active scheme, you also select a run destination (that is, the architecture of the hardware for which the products are built)

可以看出Scheme和Targets可以是一对一,也可以是一对多的关系。同一时间只能有一个scheme是激活的。

------------------Target------------------

A target specifies a product to build and contains the instructions for building the product from a set of files in a project or workspace. A target defines a single product; it organizes the inputs into the build system—the source files and instructions for processing those source files—required to build that product. Projects can contain one or more targets, each of which produces one product.

------------------Workspace------------------

A workspace is an Xcode document that groups projects and other documents so you can work on them together. A workspace can contain any number of Xcode projects, plus any other files you want to include. In addition to organizing all the files in each Xcode project, a workspace provides implicit and explicit relationships among the included projects and their targets.

可以看出一个workspace里可以包含多个Xcode project。

使用Workspace的好处有:
1),扩展项目的可视域,即可以在多个项目之间跳转,重构,一个项目可以使用另一个项目的输 出。Workspace会负责各个Project之间提供各种相互依赖的关系;
2),多个项目之间共享Build目录。

参考:

Xcode Concepts

iOS:Xcode一些概念Target|Project|Build Setting|Workspace|Scheme[译]Xcode Concepts
猿题库iOS客户端的技术细节(一):使用多target来构建大量相似App

workspace & subProject & target

Xcode Multi-Target 管理多版本开发

共有 人打赏支持
粉丝 46
博文 117
码字总数 42530
评论 (2)
mr_shawn
不错,解决了我的问题
芜阳湖
楼上正解
×
yoyoso
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: