Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 10.0 GM - dyld: lazy symbol binding failed: can't resolve symbol ___cxa_guard_acquire crash. It was working fine before that

I used cocoa pods to install de TesseractOCR library. The app works fine when running on devices, including iOS12 devices. The crash only occurs on the iOS12 Simulator. I also installed the iOS 11.4 Simulator and it works fine on that one. I've been scratching my head for this for a while. This is the crash I get.

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) 
like image 689
Iancu Tudor Avatar asked Sep 14 '18 12:09

Iancu Tudor


3 Answers

libstdc++ is removed in iOS 12 simulator but it remains in the iOS 12.0 (device) .

So as a workaround you can copy the library (libstdc++.6.0.9.tbd) from Xcode 9.4 to Xcode 10. But this is not a long term solution. You should contact the provider of those libraries and request versions built using libc++.

OR You can add following command to your pod file if you're using Cocoapods as a dependency manager:

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

end

like image 128
Vineeth Joseph Avatar answered Nov 04 '22 05:11

Vineeth Joseph


As a cleaner approach you can now replace in your pod file the framework as:

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

Support has been added in this branch for iOS 12. Hope this helps someone as it did me :)

like image 23
Samir K Avatar answered Nov 04 '22 07:11

Samir K


I had to copy the dylib files, not the tdb files to get the simulator running.

Prerequisites: You have Xcode 9.4 installed with exactly that name. Change FROM and even TO below if necessary.

This is my terminal commands for copying the dylib files:

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

WARNING! You should be really careful since there is a sudo involved. DO YOU TRUST ME?

The script will do a dry run if you copy my command right off. Remove the : in front of sudo to actually modify your filesystem. set -x will enable logging of all commands executed.

Not related to the question, but if you use CocoaPods you will probably need to apply the following patch at some point as well: https://gist.github.com/gali8/7d090865a904a16caf5a7a3116c3c3ab

like image 23
JKvr Avatar answered Nov 04 '22 07:11

JKvr