Swift Package not available during testing

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

Swift Package not available during testing

问题

似乎是一个非常新手的问题,但是我无论如何都找不到答案。

我刚开始使用SwiftUI,并将我的第一个Swift包依赖项(GoogleSignIn)添加到我的项目中。应用程序可以正常构建和运行。

但是当我尝试运行我的测试时,我会收到以下错误消息:

找不到模块 'GoogleSignIn'

所以在正常的目标中它可以正常工作。但对于我的XCTestCase,它甚至不能再次构建。我通过转到我的项目 > 包依赖项 > +,然后只需粘贴URL https://github.com/google/GoogleSignIn-iOS 来添加该包。

如何使该包在我的测试中可用?

英文:

Seems like a really newbie issue but I cannot for my life find an answer to this.

I just got started with SwiftUI and added my first Swift Package Dependency (GoogleSignIn) to my project. The app builds and runs fine.

But when I try to run my tests I get the following:

No such module 'GoogleSignIn'

So it works fine in normal target. But for my XCTestCases it doesn't even build anymore. I added the package by going to my project > Package Dependencies > + and then just pasting in the URL https://github.com/google/GoogleSignIn-iOS.

How do I make the package available to my tests?

答案1

得分: 0

我终于找到了答案。

我打开了 MyApp.xcodeproj/project.pbxproj 并手动编辑了它。

具体来说,我编辑了名为 Begin PBXFrameworksBuildPhase section 的部分,那里有3个部分,并确保了所有三个部分的 files 看起来都一样。

然后我对名为 Begin PBXNativeTarget section 的部分和列表 packageProductDependencies 做了同样的操作。

之后,测试就可以正常工作了。

英文:

I finally found the answer.

I opened up MyApp.xcodeproj/project.pbxproj and edited it by hand.

Specifically I edited the section named Begin PBXFrameworksBuildPhase section where there are 3 sections, and made sure that files looked the same for all three sections.

Then I repeated this for the section named Begin PBXNativeTarget section and the list packageProductDependencies.

After this the tests worked.

huangapple
  • 本文由 发表于 2023年6月29日 03:16:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76576112.html
匿名

发表评论

匿名网友

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

确定