首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未找到链接sqlite3的Xcode 8符号

未找到链接sqlite3的Xcode 8符号
EN

Stack Overflow用户
提问于 2016-10-03 22:41:24
回答 3查看 946关注 0票数 1

我在witch中有一个项目,我使用2个pods,一个使用SQLCipher的私有项目,以及使用系统sqlite3 (-l"sqlite3")的谷歌/分析。

当我使用Xcode 7构建我的项目时,一切工作正常,但是当我使用Xcode 8构建应用程序时,当我试图打开sqlite db时,由于以下原因,应用程序崩溃:

代码语言:javascript
复制
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

测试结果:

代码语言:javascript
复制
|         | iOS 8 | iOS 9 | iOS 10 |
| Xcode 7 |  OK   |  OK   |   OK   |
| Xcode 8 | CRASH | CRASH |    *   |

* app didn't crash but could not open db

Xcode8有什么变化?(https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html)

对如何解决这个问题有什么建议吗?

EN

回答 3

Stack Overflow用户

发布于 2016-12-13 18:37:35

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

post_install do |安装程序|

代码语言:javascript
复制
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

结束

区块报价

票数 2
EN

Stack Overflow用户

发布于 2016-10-05 05:37:16

不幸的是,同时使用依赖于sqlite3和SQLCipher的pods并不是SQLCipher真正支持的场景。您可能会阅读这篇包含使用SQLCipher with XCode 8作为参考的指南的文章,但您尝试做的是高风险的事情。

票数 1
EN

Stack Overflow用户

发布于 2017-12-26 17:01:57

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

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39834275

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档