我有一个使用2个pod的项目,一个使用SQLCipher的私有,以及使用系统sqlite3的Google / Analytics(-l" sqlite3")。
当我使用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)
有关如何解决此问题的任何建议吗?
答案 0 :(得分:1)
不幸的是,同时使用依赖于sqlite3和SQLCipher的pod并不是SQLCipher支持的场景。您可以查看此文章,其中包含使用SQLCipher with XCode 8作为参考的指导,但您尝试做的是高风险。
答案 1 :(得分: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
端
块引用
答案 2 :(得分:0)
我正在使用sqlCipher,我也遇到了这个问题dyld: lazy symbol binding failed: Symbol not found: _sqlite3_key
。我所做的是将-all_load
标志添加到项目Build Settings
- > Other Linker Flags
,然后一切正常。希望这对某人有帮助。 :)