Reputation: 1263
I have an project in witch I use 2 pods, a private one that uses SQLCipher, and Google/Analytics that uses the systems sqlite3 (-l"sqlite3").
When I build my project with Xcode 7, everything works correctly, but when I build with Xcode 8 app crashes when trying to open the sqlite db with the following reason:
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
Tested:
| | iOS 8 | iOS 9 | iOS 10 |
| Xcode 7 | OK | OK | OK |
| Xcode 8 | CRASH | CRASH | * |
* app didn't crash but could not open db
What did Xcode 8 change? (https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html)
Any suggestions on how to fix this?
Upvotes: 1
Views: 1126
Reputation: 508
I'm using sqlCipher and I got this problem dyld: lazy symbol binding failed: Symbol not found: _sqlite3_key
too. What I do is to add -all_load
flag to project Build Settings
-> Other Linker Flags
, then all works fine. Hope this maybe help to someone. :)
Upvotes: -1
Reputation: 21
If use pod import, you can add post_install to modify OTHER_LDFLAGS, remove iOS system sqlite3 link flag 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
end
Blockquote
Upvotes: 2
Reputation: 1523
Unfortunately, simultaneously using pods dependent on sqlite3 and SQLCipher isn't really a supported scenario with SQLCipher. You might check out this article containing guidance for using SQLCipher with XCode 8 for reference, but what you are trying to do is high risk.
Upvotes: 1