尝试在 RELEASE
配置中构建应用程序时,我看到以下错误。当我在 DEBUG
模式下构建相同的应用程序时,它似乎一切正常。
UIStoryboard 'init(name:bundle)' is unavailable: Use object construction' UIStoryboard(name:bundle)' 'init(name:bundle)' has been explicitly marked unavailable here.
我确定几天前相同的代码在 RELEASE 配置中运行良好(没有任何错误)。
这是抛出错误的行:
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
我在 Xcode 版本 8.3.3 (8E3004b) 中编译它。
谢谢。
最佳答案
似乎是一些 Xcode 或 Swift 编译器错误。 项目中还有另一个错误(仅在 RELEASE 配置中)
filteredFavoriteList = searchText.isEmpty ? [] : favoriteList.filter({(report: AnyObject) -> Bool in
return report.reportTitle.localizedCaseInsensitiveContains(searchText)
})
由于 AnyObject 类型的“报告”没有任何属性“reportTitle”,这段代码在发布配置中抛出错误(尽管它在调试配置中工作)。
我为此做了以下修复:
filteredFavoriteList = searchText.isEmpty ? [] : favoriteList.filter({(report: AnyObject) -> Bool in
if let report = report as? MyClass{
return report.reportTitle.localizedCaseInsensitiveContains(searchText)
}else{
return false
}
})
现在没有更多的 UIStoryboard 错误,我可以在发布配置中构建应用程序。
所以这一行没有错误,但由于其他一些原因/错误,它在这里抛出错误。奇怪但真实。
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
谢谢。
关于ios - RELEASE 配置中的 UIStoryboard 'init(name:bundle)' 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45684818/