Xcode 在启用模块稳定性时跳过测试 [英] Xcode skips tests when module stability is enabled

查看:27
本文介绍了Xcode 在启用模块稳定性时跳过测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个动态库,该库为模块稳定性打开了 BUILD_LIBRARY_FOR_DISTRIBUTION.我有一个类,它是一个使用公共泛型的基本属性包装器.当我将此类添加到测试类并运行测试时,引用此类的 XCTestCase 类不会运行(所有其他类都会运行).我可以通过从测试用例旁边的菱形触发它来运行测试.

I'm building a dynamic library that has BUILD_LIBRARY_FOR_DISTRIBUTION turned on for module stability. I have a class which is a basic property wrapper that uses generics that is public. When I add this class to a test class and run the tests the XCTestCase class that refers to this class doesn't run (all others do). I'm able to run the test by triggering it from the diamond shape next to the test case.

  • 当我将结构更改为内部结构时,测试使用 cmd+u 正常运行.

  • When I change the struct to be internal the tests run normally with cmd+u.

设置 BUILD_LIBRARY_FOR_DISTRIBUTION = NO 也可以让测试正常运行.

Setting BUILD_LIBRARY_FOR_DISTRIBUTION = NO also lets the tests run normally.

从测试中删除对结构的引用也会让它们运行.

Removing reference to the struct from the test also get them running.

我使用 iOS 10 作为最低部署目标并将其设置为 iOS 13(用于测试)也以某种方式让测试运行.

I'm using iOS 10 as minimum deployment target and setting this to be iOS 13 (for the tests) also somehow gets the tests running.

你们有没有人在 Xcode 中遇到过这个奇怪的错误并且知道任何其他解决方案?我已经在 11.5 和 11.3.1 上对此进行了测试,行为是相同的.

Have any of you encountered this weird bug with Xcode and know of any other solution? I've tested this on 11.5 as well as 11.3.1 and the behaviour is the same.

@propertyWrapper
public struct Wrapper<T: Codable> {
    ...

    public var wrappedValue: T? {
        get {...}
        set {...}
    }
}

推荐答案

该问题是由在 BUILD_LIBRARY_FOR_DISTRIBUTION = YES 时使用泛型的公共结构引起的.将结构标记为@frozen 或将其更改为类类型都可以解决问题.

The issue was caused by public structs that use generics while BUILD_LIBRARY_FOR_DISTRIBUTION = YES. Either marking the struct as @frozen or changing it to a class type solves the issue.

这篇关于Xcode 在启用模块稳定性时跳过测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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