Xcode7+iOS9+objective-cで発生するエラーの対処

iOS9の公開に先立ち、Xcode7のGM seedを導入しました。

今回は、xcode7移行時に出てきたエラーとその対処方法をざっくりと書き出していきます。

(1)
アクションシートがキーボードで隠れてしまう現象の対応

UIActionSheet *actionSheet;

〜(割愛)

[actionSheet showInView:self.view];
↓対応
UIActionSheet *actionSheet;

〜(割愛)

[_textView resignFirstResponder];
[actionSheet showInView:self.view];

推奨されている、UIAlertControllerでも上記と同様の現象が発生します。

(2)コントローラー(ToolBar)の配置場所が変わってしまった問題の対応

//  ipadの場合
    if([CommonFunc isIpad]){
        toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - TOOLBAR_SIZE - 5, self.view.bounds.size.width, TOOLBAR_SIZE + 5)];
    } else {
        toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - TOOLBAR_SIZE - 4, self.view.bounds.size.width, TOOLBAR_SIZE + 4)];
    }
↓対応

  float removalViewSize = [[UIScreen mainScreen] applicationFrame].size.height - self.navigationController.navigationBar.bounds.size.height;

    //  ipadの場合
    if([CommonFunc isIpad]){
        toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, removalViewSize - TOOLBAR_SIZE - 5, self.view.bounds.size.width, TOOLBAR_SIZE + 5)];
    } else {
        toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, removalViewSize - TOOLBAR_SIZE - 4, self.view.bounds.size.width, TOOLBAR_SIZE + 4)];
    }

(3)関数呼び出し時の警告対応
[self setToolBar:_textView.text];
↓対応
[self setToolBarTitle:_textView.text];

(4)nendアダプターの対応
ld: '/Users/takashiishigaki/Desktop/project/ビジネス/strCntMemo/libNendAd.a(NADIconView.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
↓対応
nendにエラーの内容を報告・アダプターの修正待ち

Bitcodeとは

WWDC - App Thinning メモ - Qiita
 Apple がアプリのコンパイルを代行して自動最適化してくれる仕組み。アプリを中間表現である Bitcode を含めた形式で iTunes Connect に提出しておけば、将来的に CPU アーキテクチャが変わった際に Apple がよろしくやってくれるみたいです。Bitcode を採用する場合には、そのアプリに含めるすべてのバイナリ(フレームワーク、ライブラリ)も同様に Bitcode を含める必要がある。
 なお watchOS では Bitcode が必須の模様。
ENABLE_BITCODEをNOにする

自分のアプリではBitcodeは不要なのでNOにする。

参考リンク
http://qiita.com/gabu/items/023b2a3ea669c795ec9b

(5)Locallzationsの変更
iOS9ではjapaneseがJapanese(japan)のようになる。
stringsファイルはjapaneseだけでなく、Japanese(japan)も追加する。
コード内では以下のように変更する

if ([[[NSLocale preferredLanguages] objectAtIndex:0] isEqualToString:@"ja"]){
↓対応
NSString * strLocale = [[NSLocale preferredLanguages] objectAtIndex:0];

// 日本
if ([strLocale isEqualToString:@"ja"] || [strLocale isEqualToString:@"ja-JP"]){

(6)ITMS-90474エラー
Info.plistで「UIRequiresFullScreen」をYESにする

参考リンク
http://nsblogger.hatenablog.com/entry/2015/09/01/ios9_optimization

(7)httpリンクが弾かれる

Info.plistに以下のコードを追加する。

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

(8)キーボード上にAddしたUIToolbarが画面遷移時に黒く濁る
UIToolbar* customSimple

↓ 対処
UIToolbar* customSimple

customSimple.translucent = NO;

今後も定期的にブログを更新していきたいと思います。

日々、プログラムを書いたり・Twitterで出来事を発信したりしています。

Twitterのフォロワーも募集中です。


 今後ともよろしくお願いします。