fmdb icon indicating copy to clipboard operation
fmdb copied to clipboard

Unable to compile FMDB-IOS with Xcode9.3.1 if -DSQLITE_HAS_CODEC provided

Open bgalamb opened this issue 6 years ago • 8 comments

if the flag <OTHER_CFLAGS>-DSQLITE_HAS_CODEC</OTHER_CFLAGS> is enabled the target FMDB-IOS cannot be compiled. See errors:

/XXX/com.sap.mobile.platform.client.oss.ios.fmdb/target/checkout/src/xcode/src/fmdb/FMDatabase.m:401:14: error: implicit declaration of function 'sqlite3_rekey' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int rc = sqlite3_rekey(_db, [keyData bytes], (int)[keyData length]); ^ /XXX/com.sap.mobile.platform.client.oss.ios.fmdb/target/checkout/src/xcode/src/fmdb/FMDatabase.m:401:14: note: did you mean 'sqlite3_reset'? In module 'SQLite3' imported from /XXX/com.sap.mobile.platform.client.oss.ios.fmdb/target/checkout/src/xcode/src/fmdb/FMDatabase.m:8: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk/usr/include/sqlite3.h:4472:16: note: 'sqlite3_reset' declared here SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); ^ /XXX/com.sap.mobile.platform.client.oss.ios.fmdb/target/checkout/src/xcode/src/fmdb/FMDatabase.m:401:14: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes] int rc = sqlite3_rekey(_db, [keyData bytes], (int)[keyData length]); ^ /XXX/com.sap.mobile.platform.client.oss.ios.fmdb/target/checkout/src/xcode/src/fmdb/FMDatabase.m:427:14: error: implicit declaration of function 'sqlite3_key' is invalid in C99 [-Werror,-Wimplicit-function-declaration] int rc = sqlite3_key(_db, [keyData bytes], (int)[keyData length]); ^ /XXX/com.sap.mobile.platform.client.oss.ios.fmdb/target/checkout/src/xcode/src/fmdb/FMDatabase.m:427:14: note: did you mean 'sqlite3_rekey'? /XXX/com.sap.mobile.platform.client.oss.ios.fmdb/target/checkout/src/xcode/src/fmdb/FMDatabase.m:401:14: note: 'sqlite3_rekey' declared here int rc = sqlite3_rekey(_db, [keyData bytes], (int)[keyData length]); ^ /XXX/com.sap.mobile.platform.client.oss.ios.fmdb/target/checkout/src/xcode/src/fmdb/FMDatabase.m:427:14: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes] int rc = sqlite3_key(_db, [keyData bytes], (int)[keyData length]); ^ 4 errors generated.

bgalamb avatar Jun 01 '18 13:06 bgalamb

@bgalamb

You'll want to have a look at this post on the SQLCipher discussion forum as to why this no longer works out of the box.

You can build SQLCipher separately and include the generated sqlite3.h within the FMDB project (so it finds SQLCipher's copy of the sqlite3.h file which includes the definitions for sqlite3_key / sqlite3_rekey)

Alternatively, you can integrate via FMDB/SQLCipher cocoa pod which should work out of the box.

R4N avatar Jun 01 '18 16:06 R4N

This should be fixed by #672 - @ccgus any way you could release a new Podspec to CocoaPods that includes #672?

In the mean time, you can use the workaround posted on that PR:

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

amorde avatar Jul 25 '18 19:07 amorde

The same issue in Xcode 10.1, apparently the fix was not implemented.

pbrewczynski avatar Feb 06 '19 16:02 pbrewczynski

@pbrewczynski

How are you integrating? cocoapods?

I just re-tried integration via cocoapods (v1.5.3) and Xcode (10.1) using swift and it worked fine out of the box for me using the sample code posted on the FMDB GitHub landing page, and adding in a

database.setKey("TestKey");

after the database.open() call

Is your cocoapods repo up-to-date? pod install installed these versions for me:

Installing FMDB (2.7.5)
Installing SQLCipher (4.0.1)

If none of this works for you, it would be helpful to post further details on your integration/language/error.

R4N avatar Feb 06 '19 17:02 R4N

This is my working podfile, cocoapods are for sure up to date.

platform :ios, '8.0'
use_frameworks!

abstract_target 'BasePods' do
        pod 'Mixpanel'
        pod 'JazzHands'
        pod 'FMDB'
        pod 'FMDB/SQLCipher'

        pod 'AFNetworking', '~> 2.2'
        pod 'MDCSwipeToChoose'
        pod 'MRProgress'
        pod 'Raven', :git => 'https://github.com/getsentry/raven-objc.git', :tag => '0.5.0'
        pod 'FBSDKCoreKit'
        pod 'FBSDKLoginKit'
        pod 'FBSDKShareKit'
        pod 'Batch', '~> 1.3'

        target 'Target1'
        target 'Target2'
        target 'Target3'
end


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

pbrewczynski avatar Feb 11 '19 17:02 pbrewczynski

@pbrewczynski

Try removing the standard pod 'FMDB' pod 'FMDB/SQLCipher' should include all the standard FMDB stuff + SQLCipher and including the standard non-SQLCipher one could be causing the conflict for you.

Also you should no longer need the post_install hook since my modification to include the header search paths was merged in.

R4N avatar Feb 11 '19 17:02 R4N

This is my working podfile, cocoapods are for sure up to date.

platform :ios, '8.0'
use_frameworks!

abstract_target 'BasePods' do
        pod 'Mixpanel'
        pod 'JazzHands'
        pod 'FMDB'
        pod 'FMDB/SQLCipher'

        pod 'AFNetworking', '~> 2.2'
        pod 'MDCSwipeToChoose'
        pod 'MRProgress'
        pod 'Raven', :git => 'https://github.com/getsentry/raven-objc.git', :tag => '0.5.0'
        pod 'FBSDKCoreKit'
        pod 'FBSDKLoginKit'
        pod 'FBSDKShareKit'
        pod 'Batch', '~> 1.3'

        target 'Target1'
        target 'Target2'
        target 'Target3'
end


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

May I ask how it was solved in the end,Do not delete FMDB and FMDB/SQLCipher in cocoapods

niuxinhuai avatar Jun 01 '20 01:06 niuxinhuai

@niuxinhuai

My recommendation to @pbrewczynski was to delete the standard pod 'FMDB' from his Podfile as it could cause conflicts. I'm assuming that worked for him as he didn't respond. If you're using FMDB/SQLCipher you don't want to include the standard FMDB pod (without SQLCipher)

R4N avatar Jun 01 '20 14:06 R4N