iOS 11 / Xcode issue - Implicit declaration of function 'sqlite3_key' is invalid in C99


#1

Its early in the beta process but, figured I would post since I had so many issues last year with iOS 10. Trying to build my project on Xcode 9 beta for iOS 11 I am getting the following two errors. Any thoughts?

Implicit declaration of function ‘sqlite3_key’ is invalid in C99
Implicit declaration of function ‘sqlite3_rekey’ is invalid in C99


#2

@tcoyle - can you please verify that you have -DSQLITE_HAS_CODEC in the CFLAGS on the top level project or target(s) that are including the sqlite3.h header file?


#3

Yes that was the first thing I did before posting. Sorry should have mentioned that.


#4

@tcoyle can you please post the section from the build log immediately prior to the error showing the command line used?


#5

@sjlombardo

CompileC /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/Objects-normal/x86_64/APPDatabase.o MyProject/APPSDK/APPDatabase.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/user/Documents/APP/Beta/iOS
export LANG=en_US.US-ASCII
export PATH="/Users/user/Desktop/Betas/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Users/user/Desktop/Betas/Xcode-beta.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Users/user/Desktop/Betas/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/Users/user/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/user/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DAPP -DDEV -DDEBUG=1 -DCOCOAPODS=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Users/user/Desktop/Betas/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mios-simulator-version-min=9.0 -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -fobjc-abi-version=2 -fobjc-legacy-dispatch -index-store-path /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Index/DataStore -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/MyProject-generated-files.hmap -I/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/MyProject-own-target-headers.hmap -I/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/MyProject-all-non-framework-target-headers.hmap -ivfsoverlay /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/all-product-headers.yaml -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/MyProject-project-headers.hmap -I/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/include -I/Users/user/Documents/APP/Beta/iOS/Pods/Google/Headers -I/Users/user/Desktop/Betas/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/usr/include/libxml2 -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/Crashlytics -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/Fabric -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/FirebaseAnalytics -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/FirebaseCore -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/FirebaseInstanceID -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/Google -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/GoogleAnalytics -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/PSPDFKit -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/AFNetworking -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/MBProgressHUD -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/Masonry -I/Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/uservoice-iphone-sdk -I/Users/user/Documents/APP/Beta/iOS/sqlcipher/src -IPods/Headers -IPods/Headers/Private -IPods/Headers/Public -IPods/Headers/Private/Google -IPods/Headers/Private/GoogleAnalytics -IPods/Headers/Public/Google -IPods/Headers/Public/GoogleAnalytics -IPods/Headers/Private/Google/Google -IPods/Headers/Public/Google/Google -I/Users/user/Documents/APP/Beta/iOS/Pods/BuildHeaders -I/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/DerivedSources/x86_64 -I/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/DerivedSources -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator -FPods/PSPDFKit -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/AFNetworking -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/AGWindowView -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/GoogleToolboxForMac -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/MBProgressHUD -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/Masonry -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/PDFGenerator -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/RNCryptor -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/SSKeychain -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/Socket.IO-Client-Swift -F/Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/uservoice-iphone-sdk -F/Users/user/Documents/APP/Beta/iOS/Pods/Crashlytics/iOS -F/Users/user/Documents/APP/Beta/iOS/Pods/Fabric/iOS -F/Users/user/Documents/APP/Beta/iOS/Pods/FirebaseAnalytics/Frameworks -F/Users/user/Documents/APP/Beta/iOS/Pods/FirebaseCore/Frameworks -F/Users/user/Documents/APP/Beta/iOS/Pods/FirebaseInstanceID/Frameworks -F/Users/user/Documents/APP/Beta/iOS/Pods/Google/Frameworks -F/Users/user/Documents/APP/Beta/iOS/Pods/PSPDFKit -F/Users/user/Documents/APP/Beta/iOS -F/Users/user/Documents/APP/Beta/iOS/MyProject -DSQLITE_HAS_CODEC -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/AFNetworking/AFNetworking.framework/Headers -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/AGWindowView/AGWindowView.framework/Headers -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/GoogleToolboxForMac/GoogleToolboxForMac.framework/Headers -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Headers -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/Masonry/Masonry.framework/Headers -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/PDFGenerator/PDFGenerator.framework/Headers -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/RNCryptor/RNCryptor.framework/Headers -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/SSKeychain/SSKeychain.framework/Headers -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/Socket.IO-Client-Swift/SocketIO.framework/Headers -iquote /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Products/DebugDEV-iphonesimulator/uservoice-iphone-sdk/uservoice_iphone_sdk.framework/Headers -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/Crashlytics -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/Fabric -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/FirebaseAnalytics -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/FirebaseCore -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/FirebaseInstanceID -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/Google -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/GoogleAnalytics -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/PSPDFKit -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/AFNetworking -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/MBProgressHUD -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/Masonry -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/PSPDFKit -isystem /Users/user/Documents/APP/Beta/iOS/Pods/Headers/Public/uservoice-iphone-sdk -DSQLITE_HAS_CODEC -MMD -MT dependencies -MF /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/Objects-normal/x86_64/APPDatabase.d --serialize-diagnostics /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/Objects-normal/x86_64/APPDatabase.dia -c /Users/user/Documents/APP/Beta/iOS/MyProject/APPSDK/APPDatabase.m -o /Users/user/Library/Developer/Xcode/DerivedData/MyProject-eaqzeibuordlxpbauycrrjaehlys/Build/Intermediates.noindex/MyProject.build/DebugDEV-iphonesimulator/MyProject.build/Objects-normal/x86_64/APPDatabase.o

/Users/user/Documents/APP/Beta/iOS/MyProject/APPSDK/APPDatabase.m:137:5: error: implicit declaration of function ‘sqlite3_key’ is invalid in C99 [-Werror,-Wimplicit-function-declaration]
sqlite3_key(database, key, (int)strlen(key));
^
/Users/user/Documents/APP/Beta/iOS/MyProject/APPSDK/APPDatabase.m:163:9: error: implicit declaration of function ‘sqlite3_rekey’ is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (sqlite3_rekey(database, k, (int)strlen(k)) != SQLITE_OK) {
^
2 errors generated.


#6

@tcoyle I was able to build a reference project using a similar configuration (i.e. SQLCipher via CocoaPods, using Xcode 9 beta, targeting iOS 11 and the 5th generation iPad). There were no build errors, and everything worked smoothly.

Based on our past discussions, I recall that your project is much more complicated, with multiple pod dependencies, configurations, schemes, etc. In this case from your build output, we can see the -DSQLITE_HAS_CODEC, but it is theoretically possible that a sqlite3.h file is being picked up from some other include directory, of which there are numerous.

In order to narrow this down, I would consider adding a header search path explicitly referencing the location of the SQLCipher header above everything else, or adding the .h to your project explicitly, so it is first in line. If that resolves the problem, then it would be helpful to search the other include directories to see if there is a conflicting sqlite3.h present.

A project configuration like this could have been present earlier, but manifested only as a warning whereas now [-Werror,-Wimplicit-function-declaration] is treating it as an error.


#7

I will try those suggestions out and let you know. But just a note: I don’t use SQLCipher via Cocoapods I use it manually adding the SQLCipher project to my project. Not sure if that makes a difference. I’ll try to reproduce myself in a second project as well.

I use cocoapods for all my other dependencies tho.


#8

@sjlombardo I was able to reproduce the issue in a brand new project, with no additional dependencies. All I did was add SQLCipher to the project (via https://www.zetetic.net/sqlcipher/ios-tutorial/), and add the sample code provided.

I am sending you the project via PM.


#9

Hello @tcoyle thanks for the standalone reference. The issue here is the Header Search path. Can you try changing it from $(PROJECT_DIR)/sqlcipher/src to $(PROJECT_DIR)/sqlcipher (i.e. remove the /src from the path). That should allow the sqlite3.h file to be located. It resolves the problem in the sample project, so I would like to see if it fixes the issue in your application build. If so, we will adjust the documentation on the site to reflect as well.


#10

why yes. that did the trick! easy enough! thanks much for the quick responses and help!


#11

Hello @tcoyle excellent, I’m glad that did the trick! We’ve updated the corresponding documentation as well.


#12

@sjlombardo

I am facing anther issue with Xcode 9 beta => iOS 11 beta.

Implicit declaration of functions sqlite3_key , sqlite3_rekey invalid in c99

Getting this compiler error while running the project having SQLcipher. I have checked the sqlite3.h header file in Xcode 9 beta. But I didn’t found the above declarations(sqlite3_key , sqlite3_rekey) in the header file.

I am facing this issue only in Xcode 9 beta. My project already have -DSQLITE_HAS_CODEC in CFlags.

Could you please help me in resolving the above errors?

Thanks in advance.


#13

@YamunaChebolu - what method are you using to include SQLCipher in your project?


#14

I have the same issue here, when I tried to build my project under Xcode 9 beta 2, when doing build, it reported the same issue as other reported.
I have sqlcipher.a lib file included within my link Binary, I don’t use SQLCipher via Cocoapods, and do not add SQLCipher.project into my project.
I have enabled DSQLITE_HAS_CODEC in other C Flag as well.

my issue is: Implicit declaration of function ‘sqlite3_key’ is invalid in C99


#15

@Jeff_Lu are you including the sqlite3.h file that you got with SQLCipher? If not, you will have that problem. XCode needs to resolve the SQLCipher sqlite3.h file prior to the one from the SDK.


#16

Yes, I did include sqlite3.h with in my source.


#17

@Jeff_Lu 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.


#18

@sjlombardo

Thanks fro the update.

I have added DSQLITE_HAS_CODEC" in Other C Flags. But I have linked it properly and I can able to build my project successfully in Xcode 8 and previous versions. But I faced this issue in only Xcode 9 beta versions. I have verified the sqlite3.h file in both versions of Xcode(8 and 9) and found that the methods “sqlite3_key” and “sqlite3_rekey” were not exist in Xcode 9 version of sqlite3.h file. I think that’s why I am getting these errors in Xcode 9 beta.

Could you please check this in this perspective.

Thanks in advance!


#19

@YamunaChebolu Yes, that is the reason that the solution referenced earlier in the thread works, and why we have specifically asked about including the sqlite3.h that accompanies the SQLCipher distribution. You need to make sure that SQLCipher’s version of sqlite3.h is include in your project and can be located by the compiler via the Header Search path. This is required in addition to defining -DSQLITE_HAS_CODEC so that the function definitions are present. Please make sure that you are including the proper header file and the issue should be solved.


#20

@sjlombardo

Thanks for the reply. I have cerated a sample project and still I am facing issue with SQLCipher. I have added SQLCipher to the sample project (via https://www.zetetic.net/sqlcipher/ios-tutorial/8), and add the sample code which having “sqlite3_key” method. But still I am facing the issue.

I am sending you the project via Email. Could please check the settings and please let em know what I am missing in that.