LoginSignup
5
5

More than 5 years have passed since last update.

CocoaPodsで入れたAFNetworkingが使えない

Last updated at Posted at 2014-06-05

現象

GHUnitのテストコードとProductionのコードのビルドフェーズを分けており、GHUnit内で下記のコードを実行した場合は問題ないものの、Productionでビルドした場合だけ実行できないということが起こりました。

下記コードを実行したところ、

obj-c
#import <UIKit+AFNetworking.h>
// 途中省略
UIImageView *test = [[UIImageView alloc] init];
[test setImageWithURL:[NSURL URLWithString:@"http://hoge.jp"]];

ビルド成功した後、シミュレータが起動したところで下記のエラーとともに落ちる。

[UIImageView setImageWithURL:]: unrecognized selector sent to instance

対応と原因

ビルドのセッティングを変更

  1. アプリのBuild Settings → Linkng → Other Linker Flags
  2. アプリの部分が空になっていたら、$(inherited)を入力
  3. 再ビルド、実行

原因

コンパイル時のリンカ設定によるもののようです。他の人の環境で実行できて、自分だけ実行できないという場合は
ビルドの設定周りが怪しいので疑ってみると良いかもしれません。コンパイラ周りも勉強しないとな。。

キーワード

build setting other linker flags

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5