swift - 在“命运”类型中找不到枚举案例“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?'
解决方案
好吧,问题是这destinySearch
是一个可选的,所以它实际上是在期待:
case .fromPost?:
代替:
case .fromPost:
或者您可以在之前解包它,或者您可以将其声明destinySearch
为隐式解包值。
关于特拉维斯;可能是因为它使用的是 Xcode 10.3,因为我可以在我自己的 Xcode (11.0) 中成功编译/运行它。
推荐阅读
- javascript - VSCode 调试断点 - nodejs
- python - 有没有办法使用 Python 从 XLSX 文件中获取长公式的计算值
- c - 在linux中用c打印几次
- asp.net - 我如何解析 XML 字符串并检索特定节点?
- angular - 错误:InvalidPipeArgument:'无法将管道'DatePipe'的“27-08-2020”转换为日期'
- sql - 检查 ASP.NET Core 中的 SQL Server 数据库更改以推送通知
- javascript - 如果它是 React 中的最后一项,则隐藏元素
- optaplanner - 是否可以处理具有可控处理时间的任务?
- ansible - 使用 ansible ldap_attrs 启用 openldap memberof 模块
- typescript - 在 Typescript 中使用 Jest + Supertest 进行模拟