XcodeでiOSアプリをコンパイル後にライブラリをリンクする際、必要な framework が足りないと、以下のようなエラー(Undefined symbols for architecture arm64)が発生します。
以下は GoogleMobileAds をリンクする際に発生するエラーの例です。
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_GLKView", referenced from:
objc-class-ref in GoogleMobileAds(flat-arm64)
"_CVOpenGLESTextureCacheCreateTextureFromImage", referenced from:
l2673 in GoogleMobileAds(flat-arm64)
"_CVOpenGLESTextureGetName", referenced from:
l2673 in GoogleMobileAds(flat-arm64)
"_kUTTagClassMIMEType", referenced from:
l2987 in GoogleMobileAds(flat-arm64)
"_CVOpenGLESTextureCacheCreate", referenced from:
l2672 in GoogleMobileAds(flat-arm64)
"_CVPixelBufferGetHeight", referenced from:
l2670 in GoogleMobileAds(flat-arm64)
"_CVOpenGLESTextureCacheFlush", referenced from:
l2671 in GoogleMobileAds(flat-arm64)
"_CVBufferGetAttachment", referenced from:
l2670 in GoogleMobileAds(flat-arm64)
"_UTTypeCreatePreferredIdentifierForTag", referenced from:
l2987 in GoogleMobileAds(flat-arm64)
"_CVPixelBufferGetWidth", referenced from:
l2670 in GoogleMobileAds(flat-arm64)
"_kCVImageBufferYCbCrMatrixKey", referenced from:
l2670 in GoogleMobileAds(flat-arm64)
"_CVOpenGLESTextureGetTarget", referenced from:
l2673 in GoogleMobileAds(flat-arm64)
"_kCVPixelBufferPixelFormatTypeKey", referenced from:
l090 in GoogleMobileAds(flat-arm64)
"_kCVImageBufferYCbCrMatrix_ITU_R_601_4", referenced from:
l2670 in GoogleMobileAds(flat-arm64)
"_GLKMatrix4Identity", referenced from:
l2664 in GoogleMobileAds(flat-arm64)
l2675 in GoogleMobileAds(flat-arm64)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
呼び出そうとしている関数が見つからないというエラーが発生しています。
リンクエラーとframeworkの対応表
どの framework がどんな関数を含んでいるか(どんなエラー対応しているのか)を下表にまとめます。判明次第順次追加していきます。
「”○○”, referenced from:」と表示される場合、その関数(○○)を含んでいるライブラリを追加することで解決できます。
| framework名 | 定義されている関数など |
|---|---|
| AppTrackingTransparency.framework | _OBJC_CLASS_$_ATTrackingManager |
| GLKit.framework | _OBJC_CLASS_$_GLKView |
| _GLKMatrix4Identity | |
| MobileCoreServices.framework | _kUTTagClassMIMEType |
| _UTTypeCreatePreferredIdentifierForTag | |
| CoreVideo.framework | _CVOpenGLESTextureCacheCreateTextureFromImage |
| _CVOpenGLESTextureGetName | |
| _CVOpenGLESTextureCacheCreate | |
| _CVOpenGLESTextureCacheFlush | |
| _CVPixelBufferGetWidth | |
| _CVOpenGLESTextureGetTarget | |
| _kCVPixelBufferPixelFormatTypeKey | |
| _kCVImageBufferYCbCrMatrix_ITU_R_601_4 | |
| _CVPixelBufferGetHeight | |
| _CVBufferGetAttachment | |
| _kCVImageBufferYCbCrMatrixKey | |
| StoreKit.framework | _OBJC_CLASS_$_SKProductsRequest |
| _OBJC_CLASS_$_SKMutablePayment | |
| _OBJC_CLASS_$_SKPaymentQueue | |
| _OBJC_CLASS_$_SKStoreProductViewController | |
| _SKStoreProductParameterITunesItemIdentifier | |
| MediaPlayer.framework | _MPMoviePlayerPlaybackDidFinishNotification |
| _MPMoviePlayerPlaybackStateDidChangeNotification | |
| _OBJC_CLASS_$_MPMoviePlayerController | |
| _OBJC_CLASS_$_MPVolumeView | |
| SafariServices.framework | _OBJC_CLASS_$_SFSafariViewController |
| AdSupport.framework | _OBJC_CLASS_$_ASIdentifierManager |
| CoreMotion.framework | _OBJC_CLASS_$_CMMotionManager |
| CoreTelephony.framework | _CTRadioAccessTechnologyDidChangeNotification |
| _OBJC_CLASS_$_CTTelephonyNetworkInfo | |
| MessageUI.framework | _OBJC_CLASS_$_MFMailComposeViewController |
| _OBJC_CLASS_$_MFMessageComposeViewController | |
| CoreText.framework | _CTFramesetterCreateWithAttributedString |
| _CTFramesetterSuggestFrameSizeWithConstraints | |
| GameKit.framework | _OBJC_CLASS_$_GKAchievement |
| _OBJC_CLASS_$_GKScore | |
| _OBJC_CLASS_$_GKGameCenterViewController | |
| _OBJC_CLASS_$_GKLocalPlayer | |
| SystemConfiguration.framework | _SCNetworkReachabilityCreateWithAddress |
| _SCNetworkReachabilityGetFlags | |
| _SCNetworkReachabilityCreateWithName | |
| _SCNetworkReachabilitySetDispatchQueue | |
| _SCNetworkReachabilitySetCallback | |
| Security.framework | _SecCertificateCreateWithData |
| _SecTrustCopyExceptions | |
| _SecTrustEvaluate | |
| _SecTrustSetAnchorCertificates | |
| _SecTrustSetExceptions | |
| CoreMedia.framework | _CMTimeGetSeconds |
| _CMTimeMakeWithSeconds | |
| _CMTimeMake | |
| _kCMTimeZero | |
| OpenGLES.framework | _OBJC_CLASS_$_EAGLContext |
| _glActiveTexture | |
| CFNetwork.framework | _CFHostCreateWithName |
| _CFHostStartInfoResolution | |
| _CFHostGetAddressing | |
| Social.framework | _SLServiceTypeTwitter |
| _OBJC_CLASS_$_SLComposeViewController | |
| libiconv.tbd | _iconv |
| _iconv_open | |
| _iconv_close |
SKProductsRequest や GKAchievement など、名前から推測しやすいものもありますが、わかりにくいフレームワークも多いです。


ピンバック: 【admob】admobのバナーをiOSで実装してみた。【cocos2d-x】 | TRISTORE
ピンバック: Xcode9.0でAdMobのフレームワークを入れ替えたらarm64のエラー | techno monkey
この記事で問題が解決しました!ありがとうございます!