投稿

2013の投稿を表示しています

Undefined symbols for architecture arm64

イメージ
cocoapodsを久しぶりに使用したら以下のエラーが出た。 Undefined symbols for architecture arm64:   "_OBJC_CLASS_$_AFHTTPResponseSerializer", referenced from:       objc-class-ref in xxxxxxxxxxx.o うーん。 どうやらPodsで作成されたライブラリ(.a)とアプリとで、『Architecture』違うぞって言われてる模様。 試行錯誤した結果、BuildSetting -> Architecture の『Standard architectures ( including 64-bit) (armv7,armv7s,arm64)』を『Standard architectures (armv7,armv7s)』に変更するするとビルドエラーを回避できました。 ※ 上記では、アプリ側のArchitectureを変更していますが、逆にPodsプロジェクトのArchitectureにarm64を追加することでもビルドエラーを回避することができます。

【Xcode5】 run script の追加方法

イメージ
Xcode5から『Run Script』の追加方法が変更になったようです。 個人的に少しテンパったので手順を残しておきます。 ① まず、『Add Target...』を選択します。 ② 『Aggregate』を選択し、Target名を指定します。 ③ 『Build Phases』タグを選択します。 ④ メニューのEditaor > Add Build Phase > Add Run Scropt Build Phaseを選択します。 ⑤ Run Scriptが作成されます。

appledocの導入方法

イメージ
 何度か使用しているappledocなのですが、毎回導入手順等の記録を疎かにしてしまうので、ここらで私なりの手順まとめてみようと思います。  1.そもそもappledocって何?  appledocを使用すると、ソースコードのコメントからAPIドキュメントを自動生成することができます。Apple社のリファレンスに似せたドキュメントが生成されるため、iOS等の技術者に取っ付きやすいフォーマットで出力されます。JavadocのObjective-c版という感じでしょうか。   2.導入手順  2-1.appledocのインストール  いろいろ手順はあるのですが、今回はGithubからソース取得&コンパイルしてみます。 ソースのダウンロード  git clone git://github.com/tomaz/appledoc.git ダウンロードできたらコンパイルします。  shdo sh install-appledoc.sh これでappledocコマンドが実行出来ます。  2-2.Xcodeからappledocを使用する  ターミナルからもappledocを使用できるのですが、コードを修正する度(APIリファレンスを作成する度)にコマンドを叩くのは若干手間がかかります。ですので、Xcodeから実行出来るようにしてみます。  まず、プロジェクトを選択し、画面下のAddTargetを選択してAggregateを作成します。すると作成したTarget(Scheme)が追加されます。  追加したTargetを選択し、画面右下の『Add Build Phase』の『Add Run Script』を選択します。 Run Scriptに以下のScriptを入力します。(Ctr+zの戻るコマンドは使えないので注意!!) appledoc --project-name [プロジェクト名] --project-company [会社名] --company-id [会社のID] --create-html --no-create-docset --output  [アウトプット先]  [ソースコード場所] 以上で、HtmlやXc

クラッシュ時のスタックトレース取得方法

iOS開発において、クラッシュした場所の検討がつかない場合がありました。 いろいろ調べてみると、NSSetUncaughtExceptionHandlerにハンドラ関数のポインタを渡すと、クラッシュ時のスタックトレースが取得できるようです。 以下のコードはその実装例。 @implementation AppDelegate void exceptionHandler(NSException *exception) { NSLog(@"Exception: %@", exception); NSLog(@"Stack Trace: %@", [exception callStackSymbols]); } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSSetUncaughtExceptionHandler(&exceptionHandler); return YES; } @end 以下のコードで無理やりExceptionを発生してみました。 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSSetUncaughtExceptionHandler(&exceptionHandler); //無理やりEcxeptionを発生させる。 NSArray *array = [NSArray array]; [array objectAtIndex:1]; return YES; } 出力結果は以下。 2013-07-15 19:21:45.415 ExceptionSample[27437:c07] Exception: *** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds for empty array

UITableViewCell の アニメーション

イメージ
どうやら、UITableViewCellを追加、削除、refreshするときのアニメーションがデフォルトで用意されている模様。 指定出来るアニメーションは以下の通り。 typedef NS_ENUM(NSInteger, UITableViewRowAnimation) { UITableViewRowAnimationFade, UITableViewRowAnimationRight, UITableViewRowAnimationLeft, UITableViewRowAnimationTop, UITableViewRowAnimationBottom, UITableViewRowAnimationNone, UITableViewRowAnimationMiddle, UITableViewRowAnimationAutomatic = 100 }; (例) リロードする場合は、UITableViewControllerのサブクラス内で、 - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation; を以下の様に使用すればOK。 [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic]; 復習も兼ねて、全てのAnimationを確認するためのサンプルコードを作成した。 サンプルコード https://github.com/AlginPlus/TableCellAnimationSample

UITableViewCellの背景色を変更する

UITableViewの背景色を変更しようと以下のDataSourceでcellの背景色を変更しても上手くいかなかった。 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; cell.backgroundColor = [UIColor hogeColor]; return cell; } 背景色を変更するためには以下のDelegate内で指定すると上手くいくらしい… - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor hogeColor]; } とりあえず、よく間違えるのでメモ…