Search code examples
iosswiftcocoapodsios-simulatorxcode10

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) 

Solution

  • 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