首页 > 解决方案 > 在“命运”类型中找不到枚举案例“fromPost”?在 Travis 中,但类型在 File 中声明

问题描述

我声明枚举类型

public enum Destiny {
    case fromTrail
    case fromPost
}

并在另一部分代码中使用,如下所示:

 convenience init(withDestinySearch from: Destiny) {
        self.init(collectionViewLayout: UICollectionViewFlowLayout())
        destinySearch = from
    }

但是这个错误出现在 Travis 的构建中,并且只是在 Travis CI 中:Sigma/Sigma/App/Features/Search/Controller/SearchController.swift:92:15: enum case 'fromPost' not found in type 'Destiny?'

这是构建:https ://travis-ci.org/ViniciusDeep/Sigma/builds/604199159?utm_source=github_status&utm_medium=notification

标签: swiftxcodetravis-cifastlanepbxproj

解决方案


好吧,问题是这destinySearch是一个可选的,所以它实际上是在期待:

case .fromPost?:

代替:

case .fromPost:

或者您可以在之前解包它,或者您可以将其声明destinySearch为隐式解包值。

关于特拉维斯;可能是因为它使用的是 Xcode 10.3,因为我可以在我自己的 Xcode (11.0) 中成功编译/运行它。


推荐阅读