美文网首页iOS学习开发
解决symbol(s) not found for archit

解决symbol(s) not found for archit

作者: jzhang | 来源:发表于2016-07-01 17:06 被阅读51401次

    今天在引入一个第三方的拍照选择照片的库时,编译报错。

    Undefined symbols for architecture x86_64:
      "_ALAssetPropertyAssetURL", referenced from:
          -[TZImageManager getAssetIdentifier:] in TZImageManager.o
      "_ALAssetPropertyDuration", referenced from:
          ___90-[TZImageManager getAssetsFromFetchResult:allowPickingVideo:allowPickingImage:completion:]_block_invoke139 in TZImageManager.o
          ___97-[TZImageManager getAssetFromFetchResult:atIndex:allowPickingVideo:allowPickingImage:completion:]_block_invoke in TZImageManager.o
      "_ALAssetPropertyType", referenced from:
          ___90-[TZImageManager getAssetsFromFetchResult:allowPickingVideo:allowPickingImage:completion:]_block_invoke139 in TZImageManager.o
          ___97-[TZImageManager getAssetFromFetchResult:atIndex:allowPickingVideo:allowPickingImage:completion:]_block_invoke in TZImageManager.o
      "_ALAssetPropertyURLs", referenced from:
          -[TZImageManager getVideoWithAsset:completion:] in TZImageManager.o
          -[TZImageManager isAssetsArray:containAsset:] in TZImageManager.o
      "_ALAssetTypeVideo", referenced from:
          ___90-[TZImageManager getAssetsFromFetchResult:allowPickingVideo:allowPickingImage:completion:]_block_invoke139 in TZImageManager.o
          ___97-[TZImageManager getAssetFromFetchResult:atIndex:allowPickingVideo:allowPickingImage:completion:]_block_invoke in TZImageManager.o
      "_ALAssetsGroupPropertyName", referenced from:
          ___66-[TZImageManager getCameraRollAlbum:allowPickingImage:completion:]_block_invoke in TZImageManager.o
          ___60-[TZImageManager getAllAlbums:allowPickingImage:completion:]_block_invoke in TZImageManager.o
      "_OBJC_CLASS_$_ALAsset", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_ALAssetsFilter", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_ALAssetsGroup", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_ALAssetsLibrary", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHAsset", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHAssetCollection", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHAssetCreationRequest", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHAssetResourceCreationOptions", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHCachingImageManager", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHFetchOptions", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHFetchResult", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHImageManager", referenced from:
          objc-class-ref in TZAssetCell.o
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHImageRequestOptions", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHPhotoLibrary", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHVideoRequestOptions", referenced from:
          objc-class-ref in TZImageManager.o
      "_PHImageCancelledKey", referenced from:
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke in TZImageManager.o
          ___55-[TZImageManager getOriginalPhotoWithAsset:completion:]_block_invoke in TZImageManager.o
      "_PHImageErrorKey", referenced from:
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke in TZImageManager.o
          ___55-[TZImageManager getOriginalPhotoWithAsset:completion:]_block_invoke in TZImageManager.o
      "_PHImageManagerMaximumSize", referenced from:
          -[TZImageManager getOriginalPhotoWithAsset:completion:] in TZImageManager.o
      "_PHImageResultIsDegradedKey", referenced from:
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke in TZImageManager.o
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke_2 in TZImageManager.o
      "_PHImageResultIsInCloudKey", referenced from:
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke in TZImageManager.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    经过几个小时的查资料,和尝试,基本上确定了是由于部分依赖的框架没有导入(天知道为什么会没有导入,我在另一个项目里面直接拖进去就可以编译的,坑爹的xcode)。
    于是我仔细看了下报错的内容,都是指向TZImageManager,于是我到对应的.m文件里面,发现它引用了系统的AssetsLibrary框架:

    屏幕快照 2016-07-01 16.41.07.png

    我尝试手动导入这个框架:

    屏幕快照 2016-07-01 16.45.05.png

    编译一下,原来报27个错,现在只有17个了,看来有效果。于是我继续找还缺少了什么框架。现在的报错如下:

    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_PHAsset", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHAssetCollection", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHAssetCreationRequest", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHAssetResourceCreationOptions", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHCachingImageManager", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHFetchOptions", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHFetchResult", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHImageManager", referenced from:
          objc-class-ref in TZAssetCell.o
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHImageRequestOptions", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHPhotoLibrary", referenced from:
          objc-class-ref in TZImageManager.o
      "_OBJC_CLASS_$_PHVideoRequestOptions", referenced from:
          objc-class-ref in TZImageManager.o
      "_PHImageCancelledKey", referenced from:
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke in TZImageManager.o
          ___55-[TZImageManager getOriginalPhotoWithAsset:completion:]_block_invoke in TZImageManager.o
      "_PHImageErrorKey", referenced from:
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke in TZImageManager.o
          ___55-[TZImageManager getOriginalPhotoWithAsset:completion:]_block_invoke in TZImageManager.o
      "_PHImageManagerMaximumSize", referenced from:
          -[TZImageManager getOriginalPhotoWithAsset:completion:] in TZImageManager.o
      "_PHImageResultIsDegradedKey", referenced from:
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke in TZImageManager.o
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke_2 in TZImageManager.o
      "_PHImageResultIsInCloudKey", referenced from:
          ___58-[TZImageManager getPhotoWithAsset:photoWidth:completion:]_block_invoke in TZImageManager.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    当时在看这个报错的时候,一头雾水,PHxxx的库根本找不到,于是在.m里面找,半天之后猜是不是Photos框架,导入了之后编译成功!
    猜得很艰辛啊。
    现在写这个文章的时候,突然发现对应的TZImageManager.h文件里果然导入了Photos框架……

    屏幕快照 2016-07-01 16.53.18.png
    猜得那么辛苦,原来.h里面就有答案,醉了。
    解决这个问题花了一个下午的时间,写一篇文章做个备份,免得下次又被坑。

    这里有更详细的解决办法:
    解决symbol(s) not found for architecture arm64报错(2)

    相关文章

      网友评论

        本文标题:解决symbol(s) not found for archit

        本文链接:https://www.haomeiwen.com/subject/ipafjttx.html