iOS报错:linker command failed with exit code 1 (use -v to see invocation)寻找答案之旅

iOS报错:linker command failed with exit code 1 (use -v to see invocation

错误出现

Android开发程序员,接手了公司的iOS项目,接入了微信登录,本来运行的好好的,后来检查的时候看到微信接入官网说要注意是不是微信的最新版本,不是的话要更新,就使用cocodpod更新了一下,然后就再也编译不了了。。。。在此记录一下,错误如下:

Undefined symbols for architecture arm64:
    "operator delete[](void*)", referenced from:
    +[WeChatApiUtil EncodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
    +[WeChatApiUtil NsDataEncodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
    +[WeChatApiUtil DecodeWithBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
    +[WeChatApiUtil DecodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
    "operator new[](unsigned long)", referenced from:
    +[WeChatApiUtil EncodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
    +[WeChatApiUtil NsDataEncodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
    +[WeChatApiUtil DecodeWithBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
    +[WeChatApiUtil DecodeBase64:] in libWeChatSDK.a(WeChatApiUtil.o)
    "___gxx_personality_v0", referenced from:
    Dwarf Exception Unwind Info (__eh_frame) in AppDelegate.o
    Dwarf Exception Unwind Info (__eh_frame) in main.o
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation) 

问题分析

linker command failed with exit code 1 (use -v to see invocation) 出现的原因可能较多,根据提示往上查找原因: symbol(s) not found for architecture arm64,即静态库不支持arm64格式。
解决问题步骤:

  1. 检查出问题的静态库是否支持arm64格式,比如例子中的 是微信SDK,进入微信SDK静态库目录,在终端执行命令
    lipo -info 出现的结果包含arm64即是支持,因此不是静态库的原因。

  2. 查看项目配置:
    1).查看项目的构建是否包含arm64
    build setting的Architecture中配置如下:
    在这里插入图片描述
    2)、链接flag
    在这里插入图片描述

  3. 另一种网上的解决方法说是与缓存的库冲突了,删除缓存的库就行,根据错误提示取到缓存的文件夹:
    /Users/XXX/Library/Developer/Xcode/DerivedData 把这个路径下的文件夹都删除了,重新build ,还是不行。。。。
    5.尝试了以上方法都不可以,最后网上查找提示说是链接不到静态库,那重新pop一下总可以了吧,关闭项目,删除原来的微信SDK,重新执行pod install,重新build,抱歉还是不可以。。。

最终解决方案

buid phases下link binary with libraries添加 libc++.tbd,重新执行build。
成功了!!!

参考:
[1]: http://www.111cn.net/sj/ios8/88348.htm
[2]: https://stackoverflow.com/questions/19213782/undefined-symbols-for-architecture-arm64?rq=13
[3]: http://www.cocoachina.com/ios/20170221/18737.html
[4]:https://blog.csdn.net/cheenbee/article/details/65437958 http://adrai.github.io/flowchart.js/

猜你喜欢

转载自blog.csdn.net/MarinaTsang/article/details/83790962