2016.7.15
1.Undefined symbols for architecture armv7:之类的错误
OBJC_CLASS$_后面的QHDeviceInfo是定义在另一个类中的一个类(好绕口),因为只在.h中写了其定义interface,没有在.m中写其实现implementation ,所以导致报错。
2016.11.15
真机测试的时候报The entitlements specified in your application’s Code Signing Entitlements file do not match those specified
in your provisioning profile.(0xE8008016).
或 A valid provisioning profile for this executable was not found
折腾了好久,证书什么的都没出错.
解决方案:
找到工程的本地目录
右键显示包内容
然后从服务器端更新一下,重新build工程。
应该是临时文件中的什么东西导致的报错,在这个方法之前还做的操作:删除钥匙串中的证书,重新安装;卸载Xcode,重新安装,不知道这些操作是不是无用的。
2017.11.16
ld: entry point (_main) undefined. for architecture arm64
采用该回答
如果是OC工程则导入main.m,如果是Swift工程则添加AppDelegate.swift
2017.11.27
关键词
- Undefined symbols for architecture arm64:
- objc-class-ref
- _EAAccessoryManager
- $_MPMusicPlayerController
截图
原因
缺少对应的framework
分别是ExternalAccessory.framework->(对应EASession和EAAccessoryManager)、MediaPlayer.framework->(对应MPMusicPlayerController)
添加之后报错消除
2018.9.20
iOS 12正式版发布了,同时升级了iOS、Mac OX和Xcode,编译时候就报错了。
关键词
- Xcode 10 编译旧项目
- Library not found for -lstdc++.6.0.9
- Linker command failed with exit code 1 (use -v to see invocation)
截图
借鉴
大神的该文章---Xcode 10和iOS 12适配
步骤
1.全局搜索“.6.0.9”
2.删除所有的-l"stdc++.6.0.9"
3.重新编译,报错消失,如果未消失而是产生了新的报错,可以参考上面的文章继续探索,自己还没碰到产生新报错。
2019.1.15
使用Xcode 10.1 运行一份第三方的旧代码,报错
-
ld: library not found for -lstdc++.6.0.9
clang: error: linker command failed with exit code 1 (use -v to see invocation)
与之前刚升级Xcode 10时报的错误相似
全局搜-lstdc++.6.0.9没有搜到,然后在Frameworks中找到个文件缺失标红的libstdc++.6.0.9.tbd,尝试删除并替换为libsc++,后续又报了几个其他的错误。
- 临时方案
为了不影响进度,采取了临时方案,将Xcode 9.4中的libstdc++.6.0.9.tbd 拷出来拖进项目中,编译通过,在真机上可以运行。
下午想在模拟器上运行的时候就报错了:
ld: warning: ignoring file /Users/0dodo/Desktop/苹果20170802/libstdc++.6.0.9.tbd, missing required architecture x86_64 in file /Users/0dodo/Desktop/苹果20170802/libstdc++.6.0.9.tbd (3 slices)
Undefined symbols for architecture x86_64:
"std::ios_base::Init::~Init()", referenced from:
__GLOBAL__sub_I_BVMDOfflineMapMerge.cpp in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::string::assign(std::string const&)", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::string::_Rep::_S_empty_rep_storage", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)", referenced from:
_baidu_framework::CBVDCVersion::Save() in BaiduMapAPI_Map(BVDEDataCfg.o)
"std::string::_Rep::_M_destroy(std::allocator<char> const&)", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::basic_fstream<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"VTT for std::basic_fstream<char, std::char_traits<char> >", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::basic_fstream<char, std::char_traits<char> >::~basic_fstream()", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::ios_base::~ios_base()", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::strstream::strstream()", referenced from:
_baidu_framework::CBVDCVersion::Save() in BaiduMapAPI_Map(BVDEDataCfg.o)
"std::ostream::tellp()", referenced from:
_baidu_framework::MergeDataPart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, _baidu_framework::tagVectorMapFile&, int) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::basic_fstream<char, std::char_traits<char> >::basic_fstream()", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::istream::tellg()", referenced from:
_baidu_framework::MergeNamePart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, int) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::MergeIndexPart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::MergeDataPart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, _baidu_framework::tagVectorMapFile&, int) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::CheckPatchMd5(std::basic_fstream<char, std::char_traits<char> >&) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::basic_filebuf<char, std::char_traits<char> >::is_open() const", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::ostream::operator<<(int)", referenced from:
_baidu_framework::CBVDCVersion::Save() in BaiduMapAPI_Map(BVDEDataCfg.o)
"std::istream::seekg(long long, std::_Ios_Seekdir)", referenced from:
_baidu_framework::MergeIndexPart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::MergeDataPart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, _baidu_framework::tagVectorMapFile&, int) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::CheckPatchMd5(std::basic_fstream<char, std::char_traits<char> >&) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::__throw_length_error(char const*)", referenced from:
std::vector<_baidu_vi::vi_map::CBGLProgram*, std::allocator<_baidu_vi::vi_map::CBGLProgram*> >::reserve(unsigned long) in BaiduMapAPI_Base(BGLProgramCache.o)
std::vector<_baidu_vi::CVPtrRef<_baidu_framework::CTextureData>, std::allocator<_baidu_vi::CVPtrRef<_baidu_framework::CTextureData> > >::_M_fill_insert(__gnu_cxx::__normal_iterator<_baidu_vi::CVPtrRef<_baidu_framework::CTextureData>*, std::vector<_baidu_vi::CVPtrRef<_baidu_framework::CTextureData>, std::allocator<_baidu_vi::CVPtrRef<_baidu_framework::CTextureData> > > >, unsigned long, _baidu_vi::CVPtrRef<_baidu_framework::CTextureData> const&) in BaiduMapAPI_Map(TextureDataLoader.o)
"std::ostream::write(char const*, long)", referenced from:
_baidu_framework::MergeNamePart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, int) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::MergeIndexPart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::MergeDataPart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, _baidu_framework::tagVectorMapFile&, int) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::ios_base::Init::Init()", referenced from:
__GLOBAL__sub_I_BVMDOfflineMapMerge.cpp in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::strstream::str()", referenced from:
_baidu_framework::CBVDCVersion::Save() in BaiduMapAPI_Map(BVDEDataCfg.o)
"std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)", referenced from:
_baidu_framework::CBVDCVersion::Save() in BaiduMapAPI_Map(BVDEDataCfg.o)
"std::basic_fstream<char, std::char_traits<char> >::close()", referenced from:
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
"std::strstream::pcount() const", referenced from:
_baidu_framework::CBVDCVersion::Save() in BaiduMapAPI_Map(BVDEDataCfg.o)
"std::strstream::~strstream()", referenced from:
_baidu_framework::CBVDCVersion::Save() in BaiduMapAPI_Map(BVDEDataCfg.o)
"std::istream::read(char*, long)", referenced from:
_baidu_framework::MergeNamePart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, int) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::MergeIndexPart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::MergeDataPart(std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, std::basic_fstream<char, std::char_traits<char> >&, _baidu_framework::tagVectorMapFile&, int) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::CheckPatchMd5(std::basic_fstream<char, std::char_traits<char> >&) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
_baidu_framework::HandleBasemapMerge(_baidu_vi::CVString const&, _baidu_vi::CVString const&, _baidu_vi::CVString const&, char const*) in BaiduMapAPI_Map(BVMDOfflineMapMerge.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
还是libstdc++.6.0.9.tbd的问题,尝试了删除原来对libstdc++相关的依赖,都是牵一发动全身,所以采取临时方案,给Xcode 10.1添加库。参考了该篇文章解决Xcode10 library not found for -lstdc++ 找不到问题,使用一个脚本文件在Xcode 10.1中添加已经被Apple删除的库
-
步骤1:
到Github中下载该文件
-
步骤2:
在本地找到下载的内容,并打开脚本文件,确保脚本中的路径和自己本地Xcode中的路径保持一致,作者的路径对应的是Xcode,自己本地对应的名字是Xcode 10.1,
步骤3:
打开终端cd到libstdc--master文件夹,执行sudo sh install.sh,没有任何提示即脚本运行成功-
步骤4:
重启Xcode,在TARGETS->Build Phases->Link Binary With Libraries中添加libstdc++相关的库,运行程序,真机和模拟器都能启动。