ios - RELEASE 配置中的 UIStoryboard 'init(name:bundle)' 问题

标签 ios swift3 xcode8

尝试在 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/

相关文章:

arrays - fatal error : Index out of Range Swift 3. 1

swift - Xcode Swift Firebase Auth 使用电话号码和密码

ios - 在 Swift3 IOS 中以印度数字格式显示货币

ios - 命令/bin/sh 失败,退出代码为 133 - CocoaPods 错误 macOS Sierra

ios - 后台播放音乐 : AVAudioSessionInterruptionNotification not fired

ios - 在方向改变之前执行一个函数

ios - View Controller 的最佳组织

ios - Swift - 解析嵌套 JSON 对象中的数组不起作用

ios - Swift:在滚动时更改 TableView 高度

ios - 如何更改 MFMessageComposeViewController 的导航栏颜色?