1

Xcode 4.4で新しい単体テストを試してみようとしています(以前はOHUnitを使用していたので、とにかく新しいです)。

ターゲットに追加するクラスがいくつかありますが、そのうちの1つはQuartzCoreを参照しています。

明らかに、単体テストターゲットをQuartzCoreフレームワークにリンクしましたが、実行に失敗します。

    Undefined symbols for architecture armv7s:
  "_CGBitmapContextCreateImage", referenced from:
      -[UIImage(Additions) imageWithShadow] in UIImage+Additions.o
  "_CGContextDrawImage", referenced from:
      -[UIImage(Additions) imageWithShadow] in UIImage+Additions.o
  "_CGBitmapContextCreate", referenced from:
      -[UIImage(Additions) imageWithShadow] in UIImage+Additions.o
  "_CGImageGetBitsPerComponent", referenced from:
      -[UIImage(Additions) imageWithShadow] in UIImage+Additions.o
  "_CGImageRelease", referenced from:
      -[UIImage(Additions) imageWithShadow] in UIImage+Additions.o
  "_CGContextSetShadowWithColor", referenced from:
      -[UIImage(Additions) imageWithShadow] in UIImage+Additions.o
  "_CGContextRelease", referenced from:
      -[UIImage(Additions) imageWithShadow] in UIImage+Additions.o
  "_CGRectZero", referenced from:
      -[UIImage(Additions) imageByScalingProportionallyToSize:] in UIImage+Additions.o
  "_CGColorSpaceRelease", referenced from:
      -[UIImage(Additions) imageWithShadow] in UIImage+Additions.o
  "_CGColorSpaceCreateDeviceRGB", referenced from:
      -[UIImage(Additions) imageWithShadow] in UIImage+Additions.o
   ld: symbol(s) not found for architecture armv7s
   clang: error: linker command failed with exit code 1 (use -v to see invocation)

ビルドターゲットは正常にビルドされますが、単体テストターゲットはビルドされません。

空白の新しいプロジェクトを作成して、QuartzCoreを使用するファイルを1つ追加しようとしましたが、同じ問題が発生します。

他の誰かがこれを経験したり、何か有用な提案がありますか?

ありがとう

4

2 に答える 2

1

単体テストの場合は、アプリケーションのロジックをテストし、UI に関係するものや、アプリケーションのコア ロジックに不要な追加のクラス/フレームワークを除外するようにします。これを行うには、一部のロジックを別のファイルに移動する必要がある場合があります。これは、必要最小限のコードのみです。基本的に石英コアをインポートしない/単体テストでは石英コアを使用します。テストしているロジックを別のテスト クラスに移動します。

于 2012-12-03T16:26:00.680 に答える