Xcode 10.0 GM - dyld:延迟符号绑定失败:无法解析符号___cxa_guard_acquire崩溃。在此之前工作正常



我用cocoa pods来安装deTesseractOCR库。该应用程序在设备(包括iOS12设备(上运行时运行良好。崩溃仅发生在iOS12模拟器上。我还安装了iOS 11.4Simulator,它可以正常工作。我已经为此挠头一段时间了。这是我得到的崩溃。

dyld: lazy symbol binding failed: can't resolve symbol ___cxa_guard_acquire in /Users/IancuTudor/Library/Developer/CoreSimulator/Devices/ABE5EE31-47C8-4457-8F33-B4C265599147/data/Containers/Bundle/Application/40814EAD-8965-47F2-8036-3DE48A8143BF/Bookly.app/Frameworks/TesseractOCR.framework/TesseractOCR because dependent dylib #1 could not be loaded
dyld: can't resolve symbol ___cxa_guard_acquire in /Users/IancuTudor/Library/Developer/CoreSimulator/Devices/ABE5EE31-47C8-4457-8F33-B4C265599147/data/Containers/Bundle/Application/40814EAD-8965-47F2-8036-3DE48A8143BF/Bookly.app/Frameworks/TesseractOCR.framework/TesseractOCR because dependent dylib #1 could not be loaded
(lldb) 
libstdc++ is removed in iOS 12 simulator but it remains in the iOS 12.0 (device) .

因此,作为解决方法,您可以将库(libstdc++.6.0.9.tbd(从Xcode 9.4复制到Xcode 10。但这不是一个长期的解决方案。您应该联系这些库的提供商并请求使用 libc++ 构建的版本。

或者,如果您使用 Cocoapods 作为依赖项管理器,则可以将以下命令添加到 pod 文件中:

post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'TesseractOCRiOS' 
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
header_phase = target.build_phases().select do |phase|
phase.is_a? Xcodeproj::Project::PBXHeadersBuildPhase
end.first
duplicated_header_files = header_phase.files.select do |file|
file.display_name == 'config_auto.h'
end
duplicated_header_files.each do |file|
header_phase.remove_build_file file
end
end
end

结束

作为一种更简洁的方法,您现在可以在 pod 文件中将框架替换为:

pod 'TesseractOCRiOS', :git => 'git://github.com/parallaxe/Tesseract-OCR-iOS.git', :branch => 'macos-support'

此分支中已添加对 iOS 12 的支持。希望这对某人有所帮助,因为它对我:)

我必须复制 dylib 文件,而不是 tdb 文件才能让模拟器运行。

先决条件:您安装了完全使用该名称的Xcode 9.4。如有必要,请更改FROM甚至TO下面。

这是我用于复制 dylib 文件的终端命令:

FROM="Xcode 9.4"
TO="Xcode"
set -x; for f in /Applications/"$FROM".app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libstdc++*; do : sudo cp -p "$f" "${f/$FROM/$TO}"; done; set +x

警告!您应该非常小心,因为涉及sudo。你相信我吗?

如果您立即复制我的命令,该脚本将进行试运行。 删除sudo前面的:以实际修改文件系统。set -x将启用所有执行命令的日志记录。

与问题无关,但是如果您使用CocoaPods,则可能还需要在某些时候应用以下补丁:https://gist.github.com/gali8/7d090865a904a16caf5a7a3116c3c3ab

最新更新