报错信息如下:
Showing Recent Messages
Undefined symbol: std::ios_base::Init::Init()
Undefined symbol: std::ios_base::Init::~Init()
Undefined symbol: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
Undefined symbol: std::string::assign(std::string const&)
Undefined symbol: std::basic_fstream<char, std::char_traits<char> >::basic_fstream()
Undefined symbol: std::basic_fstream<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)
Undefined symbol: std::basic_fstream<char, std::char_traits<char> >::close()
Undefined symbol: std::basic_fstream<char, std::char_traits<char> >::~basic_fstream()
Undefined symbol: std::string::_Rep::_S_empty_rep_storage
Undefined symbol: std::string::_Rep::_M_destroy(std::allocator<char> const&)
Undefined symbol: std::ostream::tellp()
Undefined symbol: operator delete[](void*)
Undefined symbol: std::istream::tellg()
Undefined symbol: ___cxa_rethrow
Undefined symbol: std::ostream::write(char const*, long)
Undefined symbol: std::__throw_length_error(char const*)
Undefined symbol: ___cxa_end_catch
Undefined symbol: operator delete(void*)
Undefined symbol: ___cxa_guard_release
Undefined symbol: ___cxa_guard_abort
Undefined symbol: ___cxa_pure_virtual
Undefined symbol: std::istream::read(char*, long)
Undefined symbol: ___gxx_personality_v0
Undefined symbol: operator new[](unsigned long)
Undefined symbol: std::string::compare(std::string const&) const
Undefined symbol: vtable for __cxxabiv1::__si_class_type_info
Undefined symbol: std::istream::seekg(long long, std::_Ios_Seekdir)
Undefined symbol: vtable for __cxxabiv1::__vmi_class_type_info
Undefined symbol: std::__throw_bad_alloc()
Undefined symbol: vtable for __cxxabiv1::__class_type_info
Undefined symbol: operator new(unsigned long)
Undefined symbol: std::basic_filebuf<char, std::char_traits<char> >::is_open() const
Undefined symbol: ___cxa_begin_catch
Undefined symbol: ___cxa_guard_acquire
Undefined symbol: std::terminate()
WX20200610-115338.png
这是因为Xcode10彻底废弃了libstdc++,相关的库文件libstdc++.6.0.9.dylib、libstdc++.6.dylib、libstdc++.dylib、libstdc++.6.0.9.tbd、libstdc++.6.tbd、libstdc++.tbd也从Xcode10中删除了。
最好的解决办法还是尽快转到libc++开发
如果还想要继续在Xcode10上编译依赖libstdc++的项目或库,可以通过把Xcode9中的libstdc++相关库文件复制到Xcode10中即可。
在Xcode9中搜索libstdc++相关的库,可以找到四个相关的文件:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libstdc++.6.0.9.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libstdc++.6.0.9.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libstdc++.6.0.9.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libstdc++.6.0.9.tbd
解决办法
- 1.下载 libstdc文件
-
2.运行对应的 xcode版本的脚本
image.png
注意点: 如果xcode路径不是脚本中的路径,需要自行修改
image.png - 3.打开终端cd到libstdc--master文件夹,执行sudo sh install.sh,没有任何提示即脚本运行成功
-
4.重启Xcode,在TARGETS->Build Phases->Link Binary With Libraries中添加libstdc++相关的库,运行程序,真机和模拟器都能启动。
image.png
网友评论