无法在Swift Playgrounds 4.3.1中导入XCTest。

huangapple go评论76阅读模式
英文:

Cannot import XCTest in Swift Playgrounds 4.3.1

问题

I'm working in Swift Playgrounds for Mac, v4.3.1.

在Swift Playgrounds for Mac,版本4.3.1中工作。

There are a number of tutorials on the web (example) that show using XCTest in XCode Playgrounds. But when I try to import it, I get No such module 'XCTest'. Is there some step I'm missing? Was support discontinued?

网上有很多教程(示例)展示如何在XCode Playgrounds中使用XCTest。但是当我尝试导入它时,我得到了No such module 'XCTest'。我是否漏掉了某个步骤?支持是否已停止?

无法在Swift Playgrounds 4.3.1中导入XCTest。

无法在Swift Playgrounds 4.3.1中导入XCTest。

英文:

I'm working in Swift Playgrounds for Mac, v4.3.1.

There are a number of tutorials on the web (example) that show using XCTest in XCode Playgrounds. But when I try to import it, I get No such module 'XCTest'. Is there some step I'm missing? Was support discontinued?

无法在Swift Playgrounds 4.3.1中导入XCTest。

答案1

得分: 3

截止目前,你不能在Swift Playgrounds中使用XCTest

有两个应用程序可以创建Swift的“Playgrounds”,文章中提到的一个与你正在使用的不同。

  • Xcode可以通过点击文件 -> 新建 -> Playground...来创建“playgrounds”。

    这些playgrounds的文件扩展名是.playground

  • Swift Playgrounds”应用程序(可以从iOS App StoreMac App Store安装)也可以创建“playgrounds”。

    这些playgrounds的文件扩展名是.playgroundbook

这两个应用程序创建的playgrounds非常不同。在“Swift Playgrounds”应用程序创建的playgrounds中,有一些你无法做到的事情,但在Xcode创建的playgrounds中可以。XCTest就是其中之一。

正如你链接的文章所说:

>Playgrounds于2016年9月发布。这是一个在Xcode中集成的强大环境,可以实时使用Swift进行编码。

显然,它指的是使用Xcode创建的playgrounds。而你正在使用的Swift Playgrounds应用程序直到2020年才在Mac App Store上发布。

话虽如此,Xcode的playgrounds在2016年之前就存在。也许文章指的是XCTest何时可用于Xcode Playgrounds。

英文:

As of now, you cannot use XCTest in Swift Playgrounds

There are two applications that create Swift "Playgrounds", and the one mentioned in the article isn't the same one as what you are using.

  • Xcode can create "playgrounds" by clicking File -> New -> Playground...

    These playgrounds have the file extension .playground

  • The "Swift Playgrounds" app (can be installed from the iOS App Store or the Mac App Store) can also create "playgrounds"

    These playgrounds have the file extension .playgroundbook

The playgrounds created by these two apps are very different. There are some things you cannot do in playgrounds created by the "Swift Playgrounds" app, but you can in playgrounds created by Xcode. XCTest is one of them.

As the article you linked says:

> Playgrounds was released in September, 2016. It’s a powerful environment integrated in Xcode to code in real-time in Swift.

Obviously, it is referring to playgrounds created using Xcode. The Swift Playgrounds app, which is what you are using, is not released on the Mac App Store until 2020.

That said, Xcode playgrounds have existed before 2016. Perhaps the article is referring to when XCTest is available to Xcode Playgrounds.

huangapple
  • 本文由 发表于 2023年6月12日 12:06:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76453587.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定