Xcode10対応

はじめに

Xcode10になって対応した内容を簡単にまとめ

エラー1

Multiple commands error when building with Xcode 10
いろいろ解決方法が出ているが(Copy Bundle Resource のinfo.plist削除、Product Module Nameをrenameなど)どれをやっても駄目なのでLegacy Build systemでとりあえず逃げる。(自分の場合はpods関連っぽいのでpodのupdateに期待)
https://stackoverflow.com/questions/50718018/xcode-10-error-multiple-commands-produce

エラー2

2018-09-22 12:34:06.586869+0900 Nekostabe[2645:713106] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to allocate data stores for 2147483647 rows in section 8. Consider using fewer rows'

結構ハマりましたが、enumの値を取得する箇所で、rawValueするべき箇所がなぜかhashValueになっていて正しい数字が返らずエラーになっていた(今まではたまたま動いていた?)。

enum RowIndex {
    case header
    case content
    case footer
    case count
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    //return RowIndex.header.hashValue 今までは大丈夫だったが、今回動かなくなった
    return RowIndex.header.rawValue
}

ついでにswift 4.2から採用されたenumのCaseIterableに変更してみました。
いままでは件数を取るのを以下のようにしていた。※一番最後にcountというのを定義(デフォルトの数値であれば、件数が入る)
enum RowIndex {
    case header
    case content
    case footer
    case count
}

RowIndex.count.rawValue

CaseIterableにすることで、以下のように件数が取得できるようになる。
enum RowIndex: CaseIterable {
    case header
    case content
    case footer
}

RowIndex.allCases.count

参考
http://blog.penginmura.tech/entry/2018/04/14/202031

コメント

このブログの人気の投稿

FunBizのシステム環境

EBに置いたrailsからAmazon Kinesis Data FirehoseでlogをamazonESに投げる

メッセージUIライブラリMessageKitの紹介