找不到链接sqlite3的Xcode 8符号

问题描述 投票:1回答:3

我有一个使用2个pod的项目,一个使用SQLCipher的私有,以及使用系统sqlite3(-l“sqlite3”)的Google / Analytics。

当我使用Xcode 7构建我的项目时,一切正常,但当我尝试打开sqlite数据库时,我使用Xcode 8应用程序崩溃,原因如下:

dlopen(/usr/lib/libsqlite3.dylib, 0x00000001)
dlopen(/usr/lib/libsqlite3.dylib) ==> 0x1feec4f0
dyld: lazy symbol binding failed: Symbol not found: _sqlite3_key
Referenced from: /var/containers/Bundle/Application/524A1D1F-CC6A-4F7C-B86F-CC65EAF17BD5/MyApp.app/MyApp
Expected in: /usr/lib/libsqlite3.dylib

测试:

|         | iOS 8 | iOS 9 | iOS 10 |
| Xcode 7 |  OK   |  OK   |   OK   |
| Xcode 8 | CRASH | CRASH |    *   |

* app didn't crash but could not open db

Xcode 8改变了什么? (https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html) 对于如何解决这个问题,有任何的建议吗?

xcode google-analytics sqlite cocoapods sqlcipher
3个回答
1
投票

不幸的是,同时使用依赖于sqlite3和SQLCipher的pod并不是SQLCipher支持的场景。您可以查看本文,其中包含使用SQLCipher with XCode 8作为参考的指导,但您要做的是高风险。


1
投票

如果使用pod导入,可以添加post_install来修改OTHER_LDFLAGS,删除iOS系统sqlite3链接标志l“sqlite3”。

post_install do | installer |

installer.pods_project.targets.each do |target|
    puts "#{target.name}"    
    target.build_configurations.each do |config|
        xcconfig_path = config.base_configuration_reference.real_path
        puts xcconfig_path

        build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.split(/\s*=\s*/, 2)}.flatten]

        if build_settings['OTHER_LDFLAGS']
            other_ldflags = build_settings['OTHER_LDFLAGS']

            puts other_ldflags

            if other_ldflags.include? '-l"sqlite3"'

                puts "find -l sqlite3"

                index = other_ldflags.index('-l"sqlite3"')
                length = '-l"sqlite3"'.length
                first_path = other_ldflags[0,index]
                last_path = other_ldflags[index+length..-1]
                exclude_ldflags = first_path + last_path

                puts exclude_ldflags

                build_settings['OTHER_LDFLAGS'] = exclude_ldflags
            end

            # write build_settings dictionary to xcconfig
            File.open(xcconfig_path, "w")
            build_settings.each do |key,value|
                File.open(xcconfig_path, "a") {|file| file.puts "#{key} = #{value}"}
            end
        end
    end
end

结束

大段引用


0
投票

我正在使用sqlCipher,我也遇到了这个问题dyld: lazy symbol binding failed: Symbol not found: _sqlite3_key。我做的是添加-all_load标志项目Build Settings - > Other Linker Flags,然后一切正常。希望这对某人有帮助。 :)

© www.soinside.com 2019 - 2024. All rights reserved.