I have xCode 9.2 and Unable to build successfully. I am getting Build Failed. And when I am checking Build Log. I am facing issue with “Implicit declaration of function ‘sqlite3_key’ is invalid in C99”.
Hello @tejasp-excellence based on the error XCode is either not finding the sqlite3.h file (i.e. because the header search paths are incorrect), or the define is not configured properly. If you would like further help you would need to post the output of ls -R from the top level of your project along with the full Xcode build log out to a GitHub gist and then provide the link here.
Quick and dirty solution to get it running would be to add “-Wno-implicit-function-declaration” in other warning flags of build settings. Fact is it is being considered as error now. Adding this flag will force compiler to ignore it.
I upgraded cocaopods to 1.5.1 and now i have same problem.
Hack with post_install, does not work now.
post_install do | installer |
print "SQLCipher: link Pods/Headers/sqlite3.h"
system "mkdir -p Pods/Headers/Private && ln -s ../../SQLCipher/sqlite3.h Pods/Headers/Private"
end
Thank you for the advice! Downgrade cocaopods to 1.4.0 works for me.
But i hope that SQLCipher will resolve this problem for the last cocaopods version.
I’m assuming you are using swift (with use_frameworks! in the Podfile)
This issue is related to Xcode not being able to find the sqlite3.h file as @sjlombardo alluded to. I was able to get it working with the latest version of cocoa pods (1.5.2) and Xcode (Version 9.3 (9E145)) by adding the path to the SQLCipher copy of sqlite3.h to the Header Search Paths: Pods/SQLCipher
You should no longer need to use the post_install hook if you add this Header Search Path.
Hi @mmoore! Yes, i use swift 4 with use_frameworks!. Xcode 9.3.1 and cocapods 1.5.2.
I created empty swift project and I followed your recommendations.
It does not work for me.
You’re using SQLCipher via FMDB, so it looks like the FMDB code isn’t able to properly locate the SQLCipher copy of sqlite3.h
Try putting this post_install hook in your Podfile in the place of the previous one:
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "FMDB"
config_path = target.build_configurations[0].base_configuration_reference.real_path
File.open(config_path, "a") {|file| file.write("HEADER_SEARCH_PATHS = SQLCipher")}
end
end
end
then pod install again and see if it builds without errors.
Here’s an example of a Podfile that seemed to work fine for me:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'testPodFMDB' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for testPodFMDB
pod 'FMDB/SQLCipher'
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "FMDB"
config_path = target.build_configurations[0].base_configuration_reference.real_path
File.open(config_path, "a") {|file| file.write("HEADER_SEARCH_PATHS = SQLCipher")}
end
end
end
end
I’ve re-worked the previous post_install a bit to modify the build settings rather than appending to the xcconfig file (which I think is a bit better of a solution). It should accomplish the same thing (making sure SQLCipher is in the Header Search Paths so the proper sqlite3.h can be found by FMDB):
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "FMDB"
target.build_configurations.each do |config|
header_search = {"HEADER_SEARCH_PATHS" => "SQLCipher"}
config.build_settings.merge!(header_search)
end
end
end
end
For anyone else looking to integrate SQLCipher via FMDB using swift, FMDB has merged my pull request which now takes care of adding SQLCipher to the header search paths, so it should work out of the box without need for a post_install hook.
If you’re directly using the SQLCipher pod and swift, you’ll need to either adjust the bridging header to be #include <SQLCipher/sqlite3.h> or add $(PODS_ROOT)/SQLCipher to the HEADER_SEARCH_PATHS of your application. We’re planning on adjusting the podspec for SQLCipher to account for this in the next point release.
Glad to hear one of the post install hooks worked to properly set the SQLCipher header search paths for FMDB.
I’m not sure on FMDB’s plans on which version the adjustment will be included in, but it’s this commit off of master which merges in my Pull Request which accomplishes the same thing as this post_install hook:
Specifying this commit within the Podfile should eliminate the need for the post_install hook – i.e.:
pod 'FMDB/SQLCipher', :git => 'https://github.com/ccgus/fmdb', :commit => '18152d3ea819d5a65a682ad9f3b22dbbb3c2423e'