14 回答
libstdc++ 在 5 年前被弃用。Apple 最新的平台(tvOS 和 watchOS)不支持它。
从 iOS 12.0 模拟器运行时中删除了支持,但它仍保留在 iOS 12.0(设备)运行时中,以实现与发布应用程序的二进制兼容性。
您应该通过将 CLANG_CXX_LIBRARY 构建设置(“C++ 标准库”)设置为 libc++ 来更新您的项目以使用 libc++ 而不是 libstdc++。
如果您有任何依赖于 libstdc++.tbd 的静态库,您现在可以通过从 Xcode 9.4(以及 iOS 模拟器运行时中的 libstdc++.*.dylib)中的 SDK 复制文件来解决它,但这不是长期的解决方案。您应该联系这些库的提供者并请求使用 libc++ 构建的版本。
你可以从旧的 Xcode(9.4) 复制它。它应该工作。
cp /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libstdc++.* /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/
cp /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libstdc++.* /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
libstdc++
在 iOS 12 中被移除。
我希望我有比 Twitter 上的 Apple 工程师更好的消息来源,但这就是我所拥有的。
@jeremyhu PSA:libstdc++ 已从 iOS 12.0 SDK 中消失(它存在于运行时以实现二进制兼容性)。它的日子在 macOS 上也有编号。如果您还没有迁移到 libc++。#WWDC2018 #cplusplus
编辑:这是一个更好的来源,Xcode 10 补丁说明
使用 libstdc++ 构建已在 Xcode 8 中弃用,并且在针对 iOS 时在 Xcode 10 中不受支持。C++ 项目现在必须迁移到 libc++,建议设置 iOS 7 或更高版本的部署目标。除了更改 C++ 标准库构建设置外,开发人员还应审核硬编码的链接器标志和目标依赖项以删除对 libstdc++ 的引用(包括 -lstdc++、-lstdc++.6.0.9、libstdc++.6.0.9.tbd 和 libstdc++.6.0。 9.dylib)。项目依赖项(例如针对 libstdc++ 构建的静态档案)也需要针对 libc++ 重新构建。(40885260)
Xcode 10 取消了内置 lib 的 libstdc++ 库,所以我们应该手动将文件复制到 lib。
将文件: (libstdc++.6.0.9.tbd) 和 (libstdc++.6.tbd) 复制到:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib
和
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib
(请注意区分“iPhoneOS”和“iPhoneSimulator”)
清理xcode并重建它。
这是文件。
取自Xcode 10 Beta 2 发行说明,适用于 Xcode 的所有未来版本:
使用 libstdc++ 构建已在 Xcode 8 中弃用,并且在针对 iOS 时在 Xcode 10 中不受支持。C++ 项目现在必须迁移到 libc++,建议设置 iOS 7 或更高版本的部署目标。除了更改 C++ 标准库构建设置外,开发人员还应审核硬编码的链接器标志和目标依赖项以删除对 libstdc++ 的引用(包括 -lstdc++、-lstdc++.6.0.9、libstdc++.6.0.9.tbd 和 libstdc++.6.0。 9.dylib)。项目依赖项(例如针对 libstdc++ 构建的静态档案)也需要针对 libc++ 重新构建。(40885260)
Apple 不太可能再次支持 libstdc++。
更新到 xcode 10 后我也遇到了同样的问题。我通过从https://github.com/Kila2/libstdc-.6.0 下载 libstdc++.6.0.9.tbd 和 libstdc++.6.tbd 解决了这个问题。 9.待定。
然后我将这些文件复制到我的项目文件夹中。之后,我按照以下步骤在链接框架和库中添加了这些库:项目>目标>常规>链接框架和库单击(+)>单击“添加其他”>导航到“打开文件”中的项目文件夹并选择这些库并添加。
现在运行项目,它将完美运行..
因为苹果在 Xcode 10.0 中去掉了 libstdc++,所以如果想解决问题,可以尝试手动将文件复制到 lib。
1.iPhoneOS
和iPhoneSimulator
文件
复制文件:libstdc++.6.0.9.tbd
和libstdc++.6.tbd
到libstdc++.tbd
:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
2.iOS.simruntime
文件
复制文件:libstdc++.6.0.9.dylib
和libstdc++.6.dylib
到libstdc++.dylib
:
- /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib
对我来说 -l"stdc++.6" 是在pod install
我在 'Pods/Target\ Support\ Files/Pods-SomeTarget/Pods-SomeTarget.debug.xcconfig' 中找到时添加的
要解决此问题,您可以在 Podfile 中使用 post_install 处理程序:
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "Pods-SomeTarget”
puts "Updating #{target.name} OTHER_LDFLAGS"
target.build_configurations.each do |config|
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
new_xcconfig = xcconfig.gsub('-l"stdc++.6" ', '')
File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
end
end
end
end
Jeremy Huddleston Sequoia 的回答给了我解决这个问题的方向。因此,在继续之前,请确保您已阅读他的答案。
即使在您的项目中更新了 C++ 库后,您也可能会遇到链接错误,即 Xcode 无法将您的项目与此 libstdc++ 库链接。
解决方案是 - 如果您的项目结构包含 libstdc++,它可能会变成红色,因为 Xcode 找不到它的参考。如果您从项目结构中删除该条目并添加新的库(libc++),那么您就可以开始了。
通过将平台库和运行时所需的文件从 9.4 复制到 10.1,我能够解决构建问题。但它只解决了模拟器的情况。在物理设备上运行时,我的应用程序仍然卡在启动时(启动画面)。
对于模拟器,只需从Linked Frameworks and Libraries中删除 libstdc++.6.0.9.tbd 。
这将起作用。不要将 .dylib 文件从 /usr/lib 复制到 simruntime。
从 Xcode 9.4.1 复制到 Xcode 10.2.1 的文件和路径列表
A) 复制文件:libstdc++.6.0.9.tbd 和 libstdc++.6.tbd 和 libstdc++.tbd
来自 > Xcode9_41/Xcode9_41.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib
到 > /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib
B) 复制文件:libstdc++.6.0.9.dylib 和 libstdc++.6.dylib 和 libstdc++.dylib
来自 > Xcode9_41/Xcode9_41.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib
到 > /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib
从旧 Xcode(9.4) 复制它适用于物理 iOS 设备。对于模拟器问题Did find: /usr/lib/libstdc++.6.dylib: mach-o, but not built for iOS simulator
。看起来苹果删除了对模拟器的兼容性支持。只需下载 iOS 11.4 模拟器即可运行。