如何使 Objective-C 仅目标构建模块? [英] How to make an Objective-C only target build a module?

查看:30
本文介绍了如何使 Objective-C 仅目标构建模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Swift 单元测试添加到所有基于 Objective-C 的项目中.如果我尝试测试代码,构建将失败并显示以下错误:

I'm trying to add Swift unit tests to an all Objective-C based project. If I attempt to test the code the build will fail with the following error:

 @testable import Foo   // No such module 'Foo'

但是,如果我向 Foo 目标添加一个 Swift 文件,单元测试将正确构建和运行,因此 Xcode 似乎只会在其中包含 Swift 文件的情况下生成 Foo 模块.当它不包含 Swift 文件时,如何强制 Xcode 创建一个模块?(如果可能,我想避免使用不必要的 Swift 文件.)

However, if I add a Swift file to the Foo target, the unit tests will build and run correctly, so it seems Xcode will only generate the Foo module if there is a Swift file in it. How can I force Xcode to create a module when it doesn't include a Swift file? (I'd like to avoid having the unnecessary Swift file if possible.)

推荐答案

看来问题出在使用@testable import Foo.只需删除该行即可构建和运行单元测试.

It appears that the problem is using the @testable import Foo. Simply removing the line allows the unit tests to build and run.

这篇关于如何使 Objective-C 仅目标构建模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆