Xcode编译报错整理

2016.7.15

1.Undefined symbols for architecture armv7:之类的错误

image

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

折腾了好久,证书什么的都没出错.

解决方案:

找到工程的本地目录


image

右键显示包内容


image

然后从服务器端更新一下,重新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
  • _EASession、_EAAccessoryManager
  • $_MPMusicPlayerController
截图
2017.11.27.png
原因

缺少对应的framework
分别是ExternalAccessory.framework->(对应EASession和EAAccessoryManager)、MediaPlayer.framework->(对应MPMusicPlayerController)
添加之后报错消除


2017.11.17_2.png

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)
截图
20190920_1.png
借鉴

大神的该文章---Xcode 10和iOS 12适配

步骤

1.全局搜索“.6.0.9”


20180920_2.png

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)


    2019-01-15-1.png

    与之前刚升级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中下载该文件

    2019-01-16-1.png

  • 步骤2:
    在本地找到下载的内容,并打开脚本文件,确保脚本中的路径和自己本地Xcode中的路径保持一致,作者的路径对应的是Xcode,自己本地对应的名字是Xcode 10.1,


    2019-01-16-2.png

    2019-01-16-3.png
  • 步骤3:
    打开终端cd到libstdc--master文件夹,执行sudo sh install.sh,没有任何提示即脚本运行成功

  • 步骤4:
    重启Xcode,在TARGETS->Build Phases->Link Binary With Libraries中添加libstdc++相关的库,运行程序,真机和模拟器都能启动。


    2019-01-16-4.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,456评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,370评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,337评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,583评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,596评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,572评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,936评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,595评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,850评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,601评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,685评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,371评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,951评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,934评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,167评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,636评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,411评论 2 342

推荐阅读更多精彩内容