2017-08-15 20 views
0

嘗試在RELEASE配置中構建應用程序時出現以下錯誤。當我在DEBUG模式下構建相同的應用程序時,似乎所有工作都正常。RELEASE配置中的UIStoryboard'init(name:bundle)'問題

UIStoryboard 'init(name:bundle)' is unavailable: Use object construction' UIStoryboard(name:bundle)' 'init(name:bundle)' has been explicitly marked unavailable here.

我確定在RELEASE配置中,相同的代碼幾天後運行良好(沒有任何錯誤)。

這裏是拋出錯誤的行:我在Xcode版本8.3.3 (8E3004b)編寫本

let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)

謝謝。

回答

0

這似乎是一些Xcode或Swift編譯器的bug。 有(僅在RELEASE配置)項目中的另一個錯誤

filteredFavoriteList = searchText.isEmpty ? [] : favoriteList.filter({(report: AnyObject) -> Bool in 
    return report.reportTitle.localizedCaseInsensitiveContains(searchText) 
}) 

由於類型AnyObject的「報告」沒有任何財產「reportTitle」,這段代碼在relese配置被扔的​​錯誤(這是儘管在調試配置工作)。

我把下面的修復此如下:

filteredFavoriteList = searchText.isEmpty ? [] : favoriteList.filter({(report: AnyObject) -> Bool in 
    if let report = report as? MyClass{ 
     return report.reportTitle.localizedCaseInsensitiveContains(searchText) 
    }else{ 
     return false 
    } 
}) 

,現在沒有更多的UIStoryboard錯誤,我能夠建立版本配置的應用程序。

所以這條線沒有錯誤,但由於其他一些原因/錯誤導致錯誤。奇怪但是TRUE。

let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main) 

謝謝。

+0

這裏AnyObject的整個使用是可疑的。誠然,錯誤是令人困惑的,但你永遠不應該這樣做,你仍然不應該這樣做。 – matt