diff --git a/CHANGES_AND_TODO_LIST.txt b/CHANGES_AND_TODO_LIST.txt index c6a375d4..b2daaf14 100644 --- a/CHANGES_AND_TODO_LIST.txt +++ b/CHANGES_AND_TODO_LIST.txt @@ -1,16 +1,23 @@ TODO: Zip, nada, zilch. Got any ideas? -If you would like to contribute some code- awesome! I just ask that you make it conform to the coding conventions already set in here, and to add a couple of tests for your new code to fmdb.m. And of course, the code should be of general use to more than just a couple of folks. Send your patches to gus@flyingmeat.com. +If you would like to contribute some code ... awesome! I just ask that you make it conform to the coding conventions already set in here, and to add the necessary of tests for your new code to tests target. And of course, the code should be of general use to more than just a couple of folks. Send your patches to gus@flyingmeat.com. + +2015.12.28 + Removed `sqlite3.h` from the headers to simplify incorporation of FMDB into a framework. This eliminates the dreaded "non-modular headers" error in frameworks. + + To accomplish this, the few references to SQLite pointers have been changed to return `void` pointers. This means that if you have application code that used SQLite pointers exposed by FMDB, you may have to cast the pointer to the appropriate type when you use it (and `#import ` yourself). In general, we would advise against using SQLite pointers unless you absolutely need to. + + Also changed the `FMDatabaseVariadic.swift` to throw errors for Swift 2. 2015.10.29 Added renditions of `executeUpdate:values:error:` and `executeQuery:values:error:`, which in Swift 2 throw errors. 2015.01.23 - Added Swift renditions of the variadic methods of FMDatabaseAdditions. + Added Swift renditions of the variadic methods of `FMDatabaseAdditions`. 2014.10.19 -Added a 'nextWithError:' to FMResultSet. Thanks to Roshan Muralidharan for the patch. + Added a `nextWithError:` to `FMResultSet`. Thanks to Roshan Muralidharan for the patch. 2014.09.10 New classes for exposing SQLite's FTS features. Thanks to Andrew Goodale for the code. @@ -18,7 +25,7 @@ Added a 'nextWithError:' to FMResultSet. Thanks to Roshan Muralidharan for the 2014.04.23 New executeStatements: method, which will take a single UTF-8 string with multiple statements in it. This is great for batch updates. There is also a executeStatements:withResultBlock: version which takes a callback block which will be used for any statements which return rows in the bulk statement. Thanks to Rob Ryan for contributing code for this. - Deprecated update:withErrorAndBindings: in favor of executeUpdate:withErrorAndBindings: + Deprecated `update:withErrorAndBindings:` in favor of `executeUpdate:withErrorAndBindings:` or `executeUpdate:values:error:`. 2014.04.09 Added back in busy handler code after a brief hiatus (check out the 2013.12.10 notes). But now doing so with sqlite3_busy_handler instead of while loops in the various execution places. diff --git a/FMDB.podspec b/FMDB.podspec index 1a9be001..fb2ad59c 100644 --- a/FMDB.podspec +++ b/FMDB.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'FMDB' - s.version = '2.5.2' + s.version = '2.6' s.summary = 'A Cocoa / Objective-C wrapper around SQLite.' s.homepage = 'https://github.com/ccgus/fmdb' s.license = 'MIT' diff --git a/README.markdown b/README.markdown index 5044384a..f4d7c3d4 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,5 @@ -# FMDB v2.5 +# FMDB v2.6 + This is an Objective-C wrapper around SQLite: http://sqlite.org/ ## The FMDB Mailing List: diff --git a/Tests/FMDatabaseAdditionsTests.m b/Tests/FMDatabaseAdditionsTests.m index b36d1732..9f6e84fc 100644 --- a/Tests/FMDatabaseAdditionsTests.m +++ b/Tests/FMDatabaseAdditionsTests.m @@ -9,6 +9,12 @@ #import #import "FMDatabaseAdditions.h" +#if FMDB_SQLITE_STANDALONE +#import +#else +#import +#endif + @interface FMDatabaseAdditionsTests : FMDBTempDBTests @end @@ -101,9 +107,8 @@ - (void)testUserVersion { XCTAssertTrue([[self db] userVersion] == 12); } +- (void)testApplicationID { #if SQLITE_VERSION_NUMBER >= 3007017 -- (void)testApplicationID -{ uint32_t appID = NSHFSTypeCodeFromFileType(NSFileTypeForHFSTypeCode('fmdb')); [self.db setApplicationID:appID]; @@ -117,7 +122,11 @@ - (void)testApplicationID NSString *s = [self.db applicationIDString]; XCTAssertEqualObjects(s, @"acrn"); -} +#else + NSString *errorMessage = NSLocalizedString(@"Application ID functions require SQLite 3.7.17", nil); + XCTFail("%@", errorMessage); + if (self.db.logsErrors) NSLog(@"%@", errorMessage); #endif +} @end diff --git a/Tests/FMDatabaseQueueTests.m b/Tests/FMDatabaseQueueTests.m index cd7fb92f..b1c572a7 100644 --- a/Tests/FMDatabaseQueueTests.m +++ b/Tests/FMDatabaseQueueTests.m @@ -9,6 +9,12 @@ #import #import "FMDatabaseQueue.h" +#if FMDB_SQLITE_STANDALONE +#import +#else +#import +#endif + @interface FMDatabaseQueueTests : FMDBTempDBTests @property FMDatabaseQueue *queue; diff --git a/Tests/FMDatabaseTests.m b/Tests/FMDatabaseTests.m index 461acbaf..a9db9716 100644 --- a/Tests/FMDatabaseTests.m +++ b/Tests/FMDatabaseTests.m @@ -10,6 +10,13 @@ #import "FMDatabase.h" #import "FMDatabaseAdditions.h" +#if FMDB_SQLITE_STANDALONE +#import +#else +#import +#endif + + @interface FMDatabaseTests : FMDBTempDBTests @end @@ -804,7 +811,7 @@ - (void)testCustomFunction [self.db executeUpdate:@"insert into ftest values ('not h!')"]; [self.db executeUpdate:@"insert into ftest values ('definitely not h!')"]; - [self.db makeFunctionNamed:@"StringStartsWithH" maximumArguments:1 withBlock:^(sqlite3_context *context, int aargc, sqlite3_value **aargv) { + [self.db makeFunctionNamed:@"StringStartsWithH" maximumArguments:1 withBlock:^(void *context, int aargc, void **aargv) { if (sqlite3_value_type(aargv[0]) == SQLITE_TEXT) { @autoreleasepool { @@ -833,7 +840,7 @@ - (void)testCustomFunction } - (void)testVersionNumber { - XCTAssertTrue([FMDatabase FMDBVersion] == 0x0250); // this is going to break everytime we bump it. + XCTAssertTrue([FMDatabase FMDBVersion] == 0x0260); // this is going to break everytime we bump it. } - (void)testExecuteStatements diff --git a/Tests/FMResultSetTests.m b/Tests/FMResultSetTests.m index b62eea3f..37968280 100644 --- a/Tests/FMResultSetTests.m +++ b/Tests/FMResultSetTests.m @@ -10,6 +10,12 @@ #import "FMDatabase.h" #import "FMResultSet.h" +#if FMDB_SQLITE_STANDALONE +#import +#else +#import +#endif + @interface FMResultSetTests : FMDBTempDBTests @end diff --git a/fmdb.xcodeproj/project.pbxproj b/fmdb.xcodeproj/project.pbxproj index fa28974c..37bd7d35 100644 --- a/fmdb.xcodeproj/project.pbxproj +++ b/fmdb.xcodeproj/project.pbxproj @@ -23,12 +23,36 @@ 6290CBB7188FE836009790F8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6290CBB6188FE836009790F8 /* Foundation.framework */; }; 67CB1E3019AD27D000A3CA7F /* FMDatabaseFTS3Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 67CB1E2F19AD27D000A3CA7F /* FMDatabaseFTS3Tests.m */; }; 8314AF3318CD73D600EC0E25 /* FMDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 8314AF3218CD73D600EC0E25 /* FMDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F131C326B9400FFC730 /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = CCC24EBB0A13E34D00A6D3E3 /* FMDatabase.m */; }; + 83C73F141C326B9400FFC730 /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = CCC24EC00A13E34D00A6D3E3 /* FMResultSet.m */; }; + 83C73F151C326B9400FFC730 /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CC47A00E148581E9002CCDAB /* FMDatabaseQueue.m */; }; + 83C73F161C326B9400FFC730 /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CC50F2CB0DF9183600E4AAAE /* FMDatabaseAdditions.m */; }; + 83C73F171C326B9400FFC730 /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E4EB813B31188005F9210 /* FMDatabasePool.m */; }; + 83C73F181C326BAB00FFC730 /* FMDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 8314AF3218CD73D600EC0E25 /* FMDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F191C326BAB00FFC730 /* FMDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC24EBA0A13E34D00A6D3E3 /* FMDatabase.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F1A1C326BAB00FFC730 /* FMResultSet.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC24EBF0A13E34D00A6D3E3 /* FMResultSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F1B1C326BAB00FFC730 /* FMDatabaseQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = CC47A00D148581E9002CCDAB /* FMDatabaseQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F1C1C326BAB00FFC730 /* FMDatabaseAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = CC50F2CC0DF9183600E4AAAE /* FMDatabaseAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F1D1C326BAB00FFC730 /* FMDatabasePool.h in Headers */ = {isa = PBXBuildFile; fileRef = CC9E4EB713B31188005F9210 /* FMDatabasePool.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F1E1C326BC100FFC730 /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = CCC24EBB0A13E34D00A6D3E3 /* FMDatabase.m */; }; + 83C73F1F1C326BC100FFC730 /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = CCC24EC00A13E34D00A6D3E3 /* FMResultSet.m */; }; + 83C73F201C326BC100FFC730 /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = CC47A00E148581E9002CCDAB /* FMDatabaseQueue.m */; }; + 83C73F211C326BC100FFC730 /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CC50F2CB0DF9183600E4AAAE /* FMDatabaseAdditions.m */; }; + 83C73F221C326BC100FFC730 /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = CC9E4EB813B31188005F9210 /* FMDatabasePool.m */; }; + 83C73F231C326BD600FFC730 /* FMDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 8314AF3218CD73D600EC0E25 /* FMDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F241C326BD600FFC730 /* FMDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC24EBA0A13E34D00A6D3E3 /* FMDatabase.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F251C326BD600FFC730 /* FMResultSet.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC24EBF0A13E34D00A6D3E3 /* FMResultSet.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F261C326BD600FFC730 /* FMDatabaseQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = CC47A00D148581E9002CCDAB /* FMDatabaseQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F271C326BD600FFC730 /* FMDatabaseAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = CC50F2CC0DF9183600E4AAAE /* FMDatabaseAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F281C326BD600FFC730 /* FMDatabasePool.h in Headers */ = {isa = PBXBuildFile; fileRef = CC9E4EB713B31188005F9210 /* FMDatabasePool.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83C73F2A1C326CE800FFC730 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 83C73F291C326CE800FFC730 /* libsqlite3.tbd */; }; + 83C73F2C1C326CF400FFC730 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 83C73F2B1C326CF400FFC730 /* libsqlite3.tbd */; }; + 83C73F2F1C326D2F00FFC730 /* FMDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83C73F0B1C326ADA00FFC730 /* FMDB.framework */; }; 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; 8DD76F9F0486AA7600D96B5E /* fmdb.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859EA3029092ED04C91782 /* fmdb.1 */; }; BF5D041918416BB2008C5AA9 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF5D041818416BB2008C5AA9 /* XCTest.framework */; }; BF5D041F18416BB2008C5AA9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BF5D041D18416BB2008C5AA9 /* InfoPlist.strings */; }; BF5D042118416BB2008C5AA9 /* FMDatabaseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BF5D042018416BB2008C5AA9 /* FMDatabaseTests.m */; }; - BF5D04281841702E008C5AA9 /* libFMDB.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE4290EF12B42F870088BD94 /* libFMDB.a */; }; BF940F5C18417D490001E077 /* FMDBTempDBTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BF940F5B18417D490001E077 /* FMDBTempDBTests.m */; }; BF940F5E18417DEA0001E077 /* FMDatabaseAdditionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BF940F5D18417DEA0001E077 /* FMDatabaseAdditionsTests.m */; }; BFC152B118417F0D00605DF7 /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = CC50F2CB0DF9183600E4AAAE /* FMDatabaseAdditions.m */; }; @@ -60,12 +84,12 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - BF5D042318416BB2008C5AA9 /* PBXContainerItemProxy */ = { + 83C73F2D1C326D2000FFC730 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; proxyType = 1; - remoteGlobalIDString = EE4290EE12B42F870088BD94; - remoteInfo = FMDB; + remoteGlobalIDString = 83C73F0A1C326ADA00FFC730; + remoteInfo = "FMDB MacOS"; }; /* End PBXContainerItemProxy section */ @@ -103,6 +127,12 @@ 831DE6FD175B7C9C001F7317 /* README.markdown */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.markdown; sourceTree = ""; }; 832F502419EC4C6B0087DCBF /* FMDatabaseVariadic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FMDatabaseVariadic.swift; path = "src/extra/Swift extensions/FMDatabaseVariadic.swift"; sourceTree = ""; }; 8352D5AC1A73DCEA003A8E09 /* FMDatabaseAdditionsVariadic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FMDatabaseAdditionsVariadic.swift; path = "src/extra/Swift extensions/FMDatabaseAdditionsVariadic.swift"; sourceTree = ""; }; + 83C73EFE1C326AB000FFC730 /* FMDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FMDB.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 83C73F0B1C326ADA00FFC730 /* FMDB.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FMDB.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 83C73F291C326CE800FFC730 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; }; + 83C73F2B1C326CF400FFC730 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/usr/lib/libsqlite3.tbd; sourceTree = DEVELOPER_DIR; }; + 83C73F301C326D8600FFC730 /* FMDB.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = FMDB.podspec; sourceTree = ""; }; + 83C73F311C326FA600FFC730 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = src/fmdb/Info.plist; sourceTree = ""; }; 8DD76FA10486AA7600D96B5E /* fmdb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fmdb; sourceTree = BUILT_PRODUCTS_DIR; }; BF5D041618416BB2008C5AA9 /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; BF5D041818416BB2008C5AA9 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; @@ -152,6 +182,22 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 83C73EFA1C326AB000FFC730 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 83C73F2C1C326CF400FFC730 /* libsqlite3.tbd in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 83C73F071C326ADA00FFC730 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 83C73F2A1C326CE800FFC730 /* libsqlite3.tbd in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8DD76F9B0486AA7600D96B5E /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -166,7 +212,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - BF5D04281841702E008C5AA9 /* libFMDB.a in Frameworks */, + 83C73F2F1C326D2F00FFC730 /* FMDB.framework in Frameworks */, BF5D041918416BB2008C5AA9 /* XCTest.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -184,12 +230,9 @@ 08FB7794FE84155DC02AAC07 /* fmdb */ = { isa = PBXGroup; children = ( - 831DE6FD175B7C9C001F7317 /* README.markdown */, - CC8C138B0E3135C400FBE1E7 /* LICENSE.txt */, - CC8C138A0E3135C400FBE1E7 /* CHANGES_AND_TODO_LIST.txt */, - CC8C138C0E3135C400FBE1E7 /* CONTRIBUTORS.txt */, - 08FB7795FE84155DC02AAC07 /* Source */, + 83C73F301C326D8600FFC730 /* FMDB.podspec */, C6859EA2029092E104C91782 /* Documentation */, + 08FB7795FE84155DC02AAC07 /* Source */, 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */, BF5D041A18416BB2008C5AA9 /* Tests */, BF5D041718416BB2008C5AA9 /* Frameworks */, @@ -225,6 +268,8 @@ EE4290EF12B42F870088BD94 /* libFMDB.a */, BF5D041618416BB2008C5AA9 /* Tests.xctest */, 6290CBB5188FE836009790F8 /* libFMDB-IOS.a */, + 83C73EFE1C326AB000FFC730 /* FMDB.framework */, + 83C73F0B1C326ADA00FFC730 /* FMDB.framework */, ); name = Products; sourceTree = ""; @@ -255,6 +300,7 @@ CC50F2CB0DF9183600E4AAAE /* FMDatabaseAdditions.m */, CC9E4EB713B31188005F9210 /* FMDatabasePool.h */, CC9E4EB813B31188005F9210 /* FMDatabasePool.m */, + 83C73F311C326FA600FFC730 /* Info.plist */, ); name = fmdb; sourceTree = ""; @@ -289,6 +335,8 @@ BF5D041718416BB2008C5AA9 /* Frameworks */ = { isa = PBXGroup; children = ( + 83C73F2B1C326CF400FFC730 /* libsqlite3.tbd */, + 83C73F291C326CE800FFC730 /* libsqlite3.tbd */, BF5D041818416BB2008C5AA9 /* XCTest.framework */, 6290CBB6188FE836009790F8 /* Foundation.framework */, 6290CBC6188FE837009790F8 /* UIKit.framework */, @@ -326,6 +374,10 @@ C6859EA2029092E104C91782 /* Documentation */ = { isa = PBXGroup; children = ( + 831DE6FD175B7C9C001F7317 /* README.markdown */, + CC8C138B0E3135C400FBE1E7 /* LICENSE.txt */, + CC8C138A0E3135C400FBE1E7 /* CHANGES_AND_TODO_LIST.txt */, + CC8C138C0E3135C400FBE1E7 /* CONTRIBUTORS.txt */, C6859EA3029092ED04C91782 /* fmdb.1 */, ); name = Documentation; @@ -357,6 +409,32 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 83C73EFB1C326AB000FFC730 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 83C73F181C326BAB00FFC730 /* FMDB.h in Headers */, + 83C73F191C326BAB00FFC730 /* FMDatabase.h in Headers */, + 83C73F1A1C326BAB00FFC730 /* FMResultSet.h in Headers */, + 83C73F1B1C326BAB00FFC730 /* FMDatabaseQueue.h in Headers */, + 83C73F1C1C326BAB00FFC730 /* FMDatabaseAdditions.h in Headers */, + 83C73F1D1C326BAB00FFC730 /* FMDatabasePool.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 83C73F081C326ADA00FFC730 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 83C73F231C326BD600FFC730 /* FMDB.h in Headers */, + 83C73F241C326BD600FFC730 /* FMDatabase.h in Headers */, + 83C73F251C326BD600FFC730 /* FMResultSet.h in Headers */, + 83C73F261C326BD600FFC730 /* FMDatabaseQueue.h in Headers */, + 83C73F271C326BD600FFC730 /* FMDatabaseAdditions.h in Headers */, + 83C73F281C326BD600FFC730 /* FMDatabasePool.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; EE4290EB12B42F870088BD94 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -391,6 +469,42 @@ productReference = 6290CBB5188FE836009790F8 /* libFMDB-IOS.a */; productType = "com.apple.product-type.library.static"; }; + 83C73EFD1C326AB000FFC730 /* FMDB iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 83C73F051C326AB000FFC730 /* Build configuration list for PBXNativeTarget "FMDB iOS" */; + buildPhases = ( + 83C73EF91C326AB000FFC730 /* Sources */, + 83C73EFA1C326AB000FFC730 /* Frameworks */, + 83C73EFB1C326AB000FFC730 /* Headers */, + 83C73EFC1C326AB000FFC730 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "FMDB iOS"; + productName = "FMDB iOS"; + productReference = 83C73EFE1C326AB000FFC730 /* FMDB.framework */; + productType = "com.apple.product-type.framework"; + }; + 83C73F0A1C326ADA00FFC730 /* FMDB MacOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 83C73F101C326ADB00FFC730 /* Build configuration list for PBXNativeTarget "FMDB MacOS" */; + buildPhases = ( + 83C73F061C326ADA00FFC730 /* Sources */, + 83C73F071C326ADA00FFC730 /* Frameworks */, + 83C73F081C326ADA00FFC730 /* Headers */, + 83C73F091C326ADA00FFC730 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "FMDB MacOS"; + productName = "FMDB MacOS"; + productReference = 83C73F0B1C326ADA00FFC730 /* FMDB.framework */; + productType = "com.apple.product-type.framework"; + }; 8DD76F960486AA7600D96B5E /* fmdb */ = { isa = PBXNativeTarget; buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "fmdb" */; @@ -420,7 +534,7 @@ buildRules = ( ); dependencies = ( - BF5D042418416BB2008C5AA9 /* PBXTargetDependency */, + 83C73F2E1C326D2000FFC730 /* PBXTargetDependency */, ); name = Tests; productName = Tests; @@ -452,6 +566,12 @@ attributes = { LastUpgradeCheck = 0710; TargetAttributes = { + 83C73EFD1C326AB000FFC730 = { + CreatedOnToolsVersion = 7.2; + }; + 83C73F0A1C326ADA00FFC730 = { + CreatedOnToolsVersion = 7.2; + }; BF5D041518416BB2008C5AA9 = { TestTargetID = EE4290EE12B42F870088BD94; }; @@ -476,11 +596,27 @@ EE4290EE12B42F870088BD94 /* FMDB */, BF5D041518416BB2008C5AA9 /* Tests */, 6290CBB4188FE836009790F8 /* FMDB-IOS */, + 83C73EFD1C326AB000FFC730 /* FMDB iOS */, + 83C73F0A1C326ADA00FFC730 /* FMDB MacOS */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 83C73EFC1C326AB000FFC730 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 83C73F091C326ADA00FFC730 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; BF5D041418416BB2008C5AA9 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -504,6 +640,30 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 83C73EF91C326AB000FFC730 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 83C73F131C326B9400FFC730 /* FMDatabase.m in Sources */, + 83C73F141C326B9400FFC730 /* FMResultSet.m in Sources */, + 83C73F151C326B9400FFC730 /* FMDatabaseQueue.m in Sources */, + 83C73F161C326B9400FFC730 /* FMDatabaseAdditions.m in Sources */, + 83C73F171C326B9400FFC730 /* FMDatabasePool.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 83C73F061C326ADA00FFC730 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 83C73F1E1C326BC100FFC730 /* FMDatabase.m in Sources */, + 83C73F1F1C326BC100FFC730 /* FMResultSet.m in Sources */, + 83C73F201C326BC100FFC730 /* FMDatabaseQueue.m in Sources */, + 83C73F211C326BC100FFC730 /* FMDatabaseAdditions.m in Sources */, + 83C73F221C326BC100FFC730 /* FMDatabasePool.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 8DD76F990486AA7600D96B5E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -553,10 +713,10 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - BF5D042418416BB2008C5AA9 /* PBXTargetDependency */ = { + 83C73F2E1C326D2000FFC730 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = EE4290EE12B42F870088BD94 /* FMDB */; - targetProxy = BF5D042318416BB2008C5AA9 /* PBXContainerItemProxy */; + target = 83C73F0A1C326ADA00FFC730 /* FMDB MacOS */; + targetProxy = 83C73F2D1C326D2000FFC730 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -721,6 +881,167 @@ }; name = Release; }; + 83C73F031C326AB000FFC730 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = src/fmdb/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.flyingmeat.FMDB-iOS"; + PRODUCT_NAME = FMDB; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 83C73F041C326AB000FFC730 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = src/fmdb/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "com.flyingmeat.FMDB-iOS"; + PRODUCT_NAME = FMDB; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 83C73F111C326ADB00FFC730 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = src/fmdb/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.flyingmeat.FMDB-MacOS"; + PRODUCT_NAME = FMDB; + SKIP_INSTALL = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 83C73F121C326ADB00FFC730 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_NS_ASSERTIONS = NO; + FRAMEWORK_VERSION = A; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = src/fmdb/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "com.flyingmeat.FMDB-MacOS"; + PRODUCT_NAME = FMDB; + SKIP_INSTALL = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; BF5D042518416BB2008C5AA9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -857,6 +1178,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 83C73F051C326AB000FFC730 /* Build configuration list for PBXNativeTarget "FMDB iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 83C73F031C326AB000FFC730 /* Debug */, + 83C73F041C326AB000FFC730 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 83C73F101C326ADB00FFC730 /* Build configuration list for PBXNativeTarget "FMDB MacOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 83C73F111C326ADB00FFC730 /* Debug */, + 83C73F121C326ADB00FFC730 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; BF5D042718416BB2008C5AA9 /* Build configuration list for PBXNativeTarget "Tests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/fmdb.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme b/fmdb.xcodeproj/xcshareddata/xcschemes/FMDB MacOS.xcscheme similarity index 63% rename from fmdb.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme rename to fmdb.xcodeproj/xcshareddata/xcschemes/FMDB MacOS.xcscheme index 754abff4..e1909bcd 100644 --- a/fmdb.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme +++ b/fmdb.xcodeproj/xcshareddata/xcschemes/FMDB MacOS.xcscheme @@ -1,6 +1,6 @@ @@ -28,26 +28,7 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> - - - - - - - - @@ -64,9 +45,9 @@ @@ -82,9 +63,9 @@ diff --git a/fmdb.xcodeproj/xcshareddata/xcschemes/FMDB iOS.xcscheme b/fmdb.xcodeproj/xcshareddata/xcschemes/FMDB iOS.xcscheme new file mode 100644 index 00000000..9d1a1dbe --- /dev/null +++ b/fmdb.xcodeproj/xcshareddata/xcschemes/FMDB iOS.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/extra/Swift extensions/FMDatabaseVariadic.swift b/src/extra/Swift extensions/FMDatabaseVariadic.swift index 50936e76..edcf055a 100644 --- a/src/extra/Swift extensions/FMDatabaseVariadic.swift +++ b/src/extra/Swift extensions/FMDatabaseVariadic.swift @@ -13,24 +13,26 @@ extension FMDatabase { /// This is a rendition of executeQuery that handles Swift variadic parameters /// for the values to be bound to the ? placeholders in the SQL. /// + /// This throws any error that occurs. + /// /// - parameter sql: The SQL statement to be used. /// - parameter values: The values to be bound to the ? placeholders /// - /// - returns: This returns FMResultSet if successful. Returns nil upon error. + /// - returns: This returns FMResultSet if successful. If unsuccessful, it throws an error. - func executeQuery(sql:String, _ values: AnyObject...) -> FMResultSet? { - return executeQuery(sql, withArgumentsInArray: values as [AnyObject]); + func executeQuery(sql:String, _ values: AnyObject...) throws -> FMResultSet { + return try executeQuery(sql, values: values as [AnyObject]); } /// This is a rendition of executeUpdate that handles Swift variadic parameters /// for the values to be bound to the ? placeholders in the SQL. /// + /// This throws any error that occurs. + /// /// - parameter sql: The SQL statement to be used. /// - parameter values: The values to be bound to the ? placeholders - /// - /// - returns: This returns true if successful. Returns false upon error. - func executeUpdate(sql:String, _ values: AnyObject...) -> Bool { - return executeUpdate(sql, withArgumentsInArray: values as [AnyObject]); + func executeUpdate(sql:String, _ values: AnyObject...) throws { + try executeUpdate(sql, values: values as [AnyObject]); } -} \ No newline at end of file +} diff --git a/src/fmdb/FMDB.h b/src/fmdb/FMDB.h index 39e2f431..1ff54650 100644 --- a/src/fmdb/FMDB.h +++ b/src/fmdb/FMDB.h @@ -1,3 +1,8 @@ +#import + +FOUNDATION_EXPORT double FMDBVersionNumber; +FOUNDATION_EXPORT const unsigned char FMDBVersionString[]; + #import "FMDatabase.h" #import "FMResultSet.h" #import "FMDatabaseAdditions.h" diff --git a/src/fmdb/FMDatabase.h b/src/fmdb/FMDatabase.h index 88b96d53..7dd5f8ce 100644 --- a/src/fmdb/FMDatabase.h +++ b/src/fmdb/FMDatabase.h @@ -1,9 +1,4 @@ #import -#if FMDB_SQLITE_STANDALONE -#import -#else -#import -#endif #import "FMResultSet.h" #import "FMDatabasePool.h" @@ -77,7 +72,7 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary @interface FMDatabase : NSObject { - sqlite3* _db; + void* _db; NSString* _databasePath; BOOL _logsErrors; BOOL _crashOnErrors; @@ -213,9 +208,7 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary `SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE` The database is opened for reading and writing, and is created if it does not already exist. This is the behavior that is always used for `open` method. - - If vfs is given the value is passed to the vfs parameter of sqlite3_open_v2. - + @return `YES` if successful, `NO` on error. @see [sqlite3_open_v2()](http://sqlite.org/c3ref/open.html) @@ -223,10 +216,34 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary @see close */ -#if SQLITE_VERSION_NUMBER >= 3005000 - (BOOL)openWithFlags:(int)flags; + +/** Opening a new database connection with flags and an optional virtual file system (VFS) + + @param flags one of the following three values, optionally combined with the `SQLITE_OPEN_NOMUTEX`, `SQLITE_OPEN_FULLMUTEX`, `SQLITE_OPEN_SHAREDCACHE`, `SQLITE_OPEN_PRIVATECACHE`, and/or `SQLITE_OPEN_URI` flags: + + `SQLITE_OPEN_READONLY` + + The database is opened in read-only mode. If the database does not already exist, an error is returned. + + `SQLITE_OPEN_READWRITE` + + The database is opened for reading and writing if possible, or reading only if the file is write protected by the operating system. In either case the database must already exist, otherwise an error is returned. + + `SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE` + + The database is opened for reading and writing, and is created if it does not already exist. This is the behavior that is always used for `open` method. + + @param vfsName If vfs is given the value is passed to the vfs parameter of sqlite3_open_v2. + + @return `YES` if successful, `NO` on error. + + @see [sqlite3_open_v2()](http://sqlite.org/c3ref/open.html) + @see open + @see close + */ + - (BOOL)openWithFlags:(int)flags vfs:(NSString *)vfsName; -#endif /** Closing a database connection @@ -473,7 +490,7 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary */ -- (sqlite_int64)lastInsertRowId; +- (int64_t)lastInsertRowId; /** The number of rows changed by prior SQL statement. @@ -793,7 +810,7 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary */ -- (sqlite3*)sqliteHandle; +- (void*)sqliteHandle; ///----------------------------- @@ -857,8 +874,6 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary - (NSTimeInterval)maxBusyRetryTimeInterval; -#if SQLITE_VERSION_NUMBER >= 3007000 - ///------------------ /// @name Save points ///------------------ @@ -920,8 +935,6 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary - (NSError*)inSavePoint:(void (^)(BOOL *rollback))block; -#endif - ///---------------------------- /// @name SQLite library status ///---------------------------- @@ -998,7 +1011,7 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary @see [sqlite3_create_function()](http://sqlite.org/c3ref/create_function.html) */ -- (void)makeFunctionNamed:(NSString*)name maximumArguments:(int)count withBlock:(void (^)(sqlite3_context *context, int argc, sqlite3_value **argv))block; +- (void)makeFunctionNamed:(NSString*)name maximumArguments:(int)count withBlock:(void (^)(void *context, int argc, void **argv))block; ///--------------------- @@ -1102,7 +1115,7 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary */ @interface FMStatement : NSObject { - sqlite3_stmt *_statement; + void *_statement; NSString *_query; long _useCount; BOOL _inUse; @@ -1125,7 +1138,7 @@ typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary @see [`sqlite3_stmt`](http://www.sqlite.org/c3ref/stmt.html) */ -@property (atomic, assign) sqlite3_stmt *statement; +@property (atomic, assign) void *statement; /** Indication of whether the statement is in use */ diff --git a/src/fmdb/FMDatabase.m b/src/fmdb/FMDatabase.m index e9757a60..27ae0f22 100644 --- a/src/fmdb/FMDatabase.m +++ b/src/fmdb/FMDatabase.m @@ -2,6 +2,12 @@ #import "unistd.h" #import +#if FMDB_SQLITE_STANDALONE +#import +#else +#import +#endif + @interface FMDatabase () - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arrayArgs orDictionary:(NSDictionary *)dictionaryArgs orVAList:(va_list)args; @@ -67,7 +73,7 @@ - (NSString *)databasePath { } + (NSString*)FMDBUserVersion { - return @"2.5"; + return @"2.6"; } // returns 0x0240 for version 2.4. This makes it super easy to do things like: @@ -109,7 +115,7 @@ + (BOOL)isSQLiteThreadSafe { return sqlite3_threadsafe() != 0; } -- (sqlite3*)sqliteHandle { +- (void*)sqliteHandle { return _db; } @@ -134,7 +140,7 @@ - (BOOL)open { return YES; } - int err = sqlite3_open([self sqlitePath], &_db ); + int err = sqlite3_open([self sqlitePath], (sqlite3**)&_db ); if(err != SQLITE_OK) { NSLog(@"error opening!: %d", err); return NO; @@ -149,16 +155,16 @@ - (BOOL)open { return YES; } -#if SQLITE_VERSION_NUMBER >= 3005000 - (BOOL)openWithFlags:(int)flags { return [self openWithFlags:flags vfs:nil]; } - (BOOL)openWithFlags:(int)flags vfs:(NSString *)vfsName { +#if SQLITE_VERSION_NUMBER >= 3005000 if (_db) { return YES; } - int err = sqlite3_open_v2([self sqlitePath], &_db, flags, [vfsName UTF8String]); + int err = sqlite3_open_v2([self sqlitePath], (sqlite3**)&_db, flags, [vfsName UTF8String]); if(err != SQLITE_OK) { NSLog(@"error opening!: %d", err); return NO; @@ -170,8 +176,11 @@ - (BOOL)openWithFlags:(int)flags vfs:(NSString *)vfsName { } return YES; -} +#else + NSLog(@"openWithFlags requires SQLite 3.5"); + return NO; #endif +} - (BOOL)close { @@ -1265,14 +1274,12 @@ - (BOOL)inTransaction { return _inTransaction; } -#if SQLITE_VERSION_NUMBER >= 3007000 - static NSString *FMDBEscapeSavePointName(NSString *savepointName) { return [savepointName stringByReplacingOccurrencesOfString:@"'" withString:@"''"]; } - (BOOL)startSavePointWithName:(NSString*)name error:(NSError**)outErr { - +#if SQLITE_VERSION_NUMBER >= 3007000 NSParameterAssert(name); NSString *sql = [NSString stringWithFormat:@"savepoint '%@';", FMDBEscapeSavePointName(name)]; @@ -1287,10 +1294,15 @@ - (BOOL)startSavePointWithName:(NSString*)name error:(NSError**)outErr { } return YES; +#else + NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); + return NO; +#endif } - (BOOL)releaseSavePointWithName:(NSString*)name error:(NSError**)outErr { - +#if SQLITE_VERSION_NUMBER >= 3007000 NSParameterAssert(name); NSString *sql = [NSString stringWithFormat:@"release savepoint '%@';", FMDBEscapeSavePointName(name)]; @@ -1301,10 +1313,15 @@ - (BOOL)releaseSavePointWithName:(NSString*)name error:(NSError**)outErr { } return worked; +#else + NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); + return NO; +#endif } - (BOOL)rollbackToSavePointWithName:(NSString*)name error:(NSError**)outErr { - +#if SQLITE_VERSION_NUMBER >= 3007000 NSParameterAssert(name); NSString *sql = [NSString stringWithFormat:@"rollback transaction to savepoint '%@';", FMDBEscapeSavePointName(name)]; @@ -1315,9 +1332,15 @@ - (BOOL)rollbackToSavePointWithName:(NSString*)name error:(NSError**)outErr { } return worked; +#else + NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); + return NO; +#endif } - (NSError*)inSavePoint:(void (^)(BOOL *rollback))block { +#if SQLITE_VERSION_NUMBER >= 3007000 static unsigned long savePointIdx = 0; NSString *name = [NSString stringWithFormat:@"dbSavePoint%ld", savePointIdx++]; @@ -1341,9 +1364,13 @@ - (NSError*)inSavePoint:(void (^)(BOOL *rollback))block { [self releaseSavePointWithName:name error:&err]; return err; +#else + NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); + return [NSError errorWithDomain:@"FMDatabase" code:0 userInfo:@{NSLocalizedDescriptionKey : errorMessage}]; +#endif } -#endif #pragma mark Cache statements @@ -1379,7 +1406,7 @@ void FMDBBlockSQLiteCallBackFunction(sqlite3_context *context, int argc, sqlite3 } -- (void)makeFunctionNamed:(NSString*)name maximumArguments:(int)count withBlock:(void (^)(sqlite3_context *context, int argc, sqlite3_value **argv))block { +- (void)makeFunctionNamed:(NSString*)name maximumArguments:(int)count withBlock:(void (^)(void *context, int argc, void **argv))block { if (!_openFunctions) { _openFunctions = [NSMutableSet new]; diff --git a/src/fmdb/FMDatabaseAdditions.h b/src/fmdb/FMDatabaseAdditions.h index 85bb2778..9dd0b629 100644 --- a/src/fmdb/FMDatabaseAdditions.h +++ b/src/fmdb/FMDatabaseAdditions.h @@ -209,8 +209,6 @@ - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error; -#if SQLITE_VERSION_NUMBER >= 3007017 - ///----------------------------------- /// @name Application identifier tasks ///----------------------------------- @@ -252,7 +250,6 @@ */ - (void)setApplicationIDString:(NSString*)string; -#endif #endif diff --git a/src/fmdb/FMDatabaseAdditions.m b/src/fmdb/FMDatabaseAdditions.m index 4ab35fa2..61fa747e 100644 --- a/src/fmdb/FMDatabaseAdditions.m +++ b/src/fmdb/FMDatabaseAdditions.m @@ -10,6 +10,12 @@ #import "FMDatabaseAdditions.h" #import "TargetConditionals.h" +#if FMDB_SQLITE_STANDALONE +#import +#else +#import +#endif + @interface FMDatabase (PrivateStuff) - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arrayArgs orDictionary:(NSDictionary *)dictionaryArgs orVAList:(va_list)args; @end @@ -119,10 +125,9 @@ - (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName } -#if SQLITE_VERSION_NUMBER >= 3007017 - (uint32_t)applicationID { - +#if SQLITE_VERSION_NUMBER >= 3007017 uint32_t r = 0; FMResultSet *rs = [self executeQuery:@"pragma application_id"]; @@ -134,18 +139,30 @@ - (uint32_t)applicationID { [rs close]; return r; +#else + NSString *errorMessage = NSLocalizedString(@"Application ID functions require SQLite 3.7.17", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); + return 0; +#endif } - (void)setApplicationID:(uint32_t)appID { +#if SQLITE_VERSION_NUMBER >= 3007017 NSString *query = [NSString stringWithFormat:@"pragma application_id=%d", appID]; FMResultSet *rs = [self executeQuery:query]; [rs next]; [rs close]; +#else + NSString *errorMessage = NSLocalizedString(@"Application ID functions require SQLite 3.7.17", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); +#endif } #if TARGET_OS_MAC && !TARGET_OS_IPHONE + - (NSString*)applicationIDString { +#if SQLITE_VERSION_NUMBER >= 3007017 NSString *s = NSFileTypeForHFSTypeCode([self applicationID]); assert([s length] == 6); @@ -154,20 +171,25 @@ - (NSString*)applicationIDString { return s; - +#else + NSString *errorMessage = NSLocalizedString(@"Application ID functions require SQLite 3.7.17", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); + return nil; +#endif } - (void)setApplicationIDString:(NSString*)s { - +#if SQLITE_VERSION_NUMBER >= 3007017 if ([s length] != 4) { NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]); } [self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"'%@'", s])]; -} - - +#else + NSString *errorMessage = NSLocalizedString(@"Application ID functions require SQLite 3.7.17", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); #endif +} #endif diff --git a/src/fmdb/FMDatabasePool.h b/src/fmdb/FMDatabasePool.h index 39d58966..1915858f 100644 --- a/src/fmdb/FMDatabasePool.h +++ b/src/fmdb/FMDatabasePool.h @@ -7,11 +7,6 @@ // #import -#if FMDB_SQLITE_STANDALONE -#import -#else -#import -#endif @class FMDatabase; @@ -160,8 +155,6 @@ - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block; -#if SQLITE_VERSION_NUMBER >= 3007000 - /** Synchronously perform database operations in pool using save point. @param block The code to be run on the `FMDatabasePool` pool. @@ -172,7 +165,6 @@ */ - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block; -#endif @end diff --git a/src/fmdb/FMDatabasePool.m b/src/fmdb/FMDatabasePool.m index 010e2920..e8e52cb5 100644 --- a/src/fmdb/FMDatabasePool.m +++ b/src/fmdb/FMDatabasePool.m @@ -6,6 +6,12 @@ // Copyright 2011 Flying Meat Inc. All rights reserved. // +#if FMDB_SQLITE_STANDALONE +#import +#else +#import +#endif + #import "FMDatabasePool.h" #import "FMDatabase.h" @@ -238,9 +244,9 @@ - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block { - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block { [self beginTransaction:NO withBlock:block]; } -#if SQLITE_VERSION_NUMBER >= 3007000 + - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block { - +#if SQLITE_VERSION_NUMBER >= 3007000 static unsigned long savePointIdx = 0; NSString *name = [NSString stringWithFormat:@"savePoint%ld", savePointIdx++]; @@ -267,7 +273,11 @@ - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block { [self pushDatabaseBackInPool:db]; return err; -} +#else + NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); + return [NSError errorWithDomain:@"FMDatabase" code:0 userInfo:@{NSLocalizedDescriptionKey : errorMessage}]; #endif +} @end diff --git a/src/fmdb/FMDatabaseQueue.h b/src/fmdb/FMDatabaseQueue.h index 7383ba5a..ae45b658 100644 --- a/src/fmdb/FMDatabaseQueue.h +++ b/src/fmdb/FMDatabaseQueue.h @@ -7,11 +7,6 @@ // #import -#if FMDB_SQLITE_STANDALONE -#import -#else -#import -#endif @class FMDatabase; @@ -179,11 +174,9 @@ @param block The code to be run on the queue of `FMDatabaseQueue` */ -#if SQLITE_VERSION_NUMBER >= 3007000 // NOTE: you can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock. // If you need to nest, use FMDatabase's startSavePointWithName:error: instead. - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block; -#endif @end diff --git a/src/fmdb/FMDatabaseQueue.m b/src/fmdb/FMDatabaseQueue.m index 3cdecdc3..c877a341 100644 --- a/src/fmdb/FMDatabaseQueue.m +++ b/src/fmdb/FMDatabaseQueue.m @@ -9,6 +9,12 @@ #import "FMDatabaseQueue.h" #import "FMDatabase.h" +#if FMDB_SQLITE_STANDALONE +#import +#else +#import +#endif + /* Note: we call [self retain]; before using dispatch_sync, just incase @@ -204,9 +210,8 @@ - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block { [self beginTransaction:NO withBlock:block]; } -#if SQLITE_VERSION_NUMBER >= 3007000 - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block { - +#if SQLITE_VERSION_NUMBER >= 3007000 static unsigned long savePointIdx = 0; __block NSError *err = 0x00; FMDBRetain(self); @@ -230,7 +235,11 @@ - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block { }); FMDBRelease(self); return err; -} +#else + NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil); + if (self.logsErrors) NSLog(@"%@", errorMessage); + return [NSError errorWithDomain:@"FMDatabase" code:0 userInfo:@{NSLocalizedDescriptionKey : errorMessage}]; #endif +} @end diff --git a/src/fmdb/FMResultSet.h b/src/fmdb/FMResultSet.h index 10a2c0b7..af0433b4 100644 --- a/src/fmdb/FMResultSet.h +++ b/src/fmdb/FMResultSet.h @@ -1,9 +1,4 @@ #import -#if FMDB_SQLITE_STANDALONE -#import -#else -#import -#endif #ifndef __has_feature // Optional. #define __has_feature(x) 0 // Compatibility with non-clang compilers. diff --git a/src/fmdb/FMResultSet.m b/src/fmdb/FMResultSet.m index ca7e166d..cfc51e11 100644 --- a/src/fmdb/FMResultSet.m +++ b/src/fmdb/FMResultSet.m @@ -2,6 +2,12 @@ #import "FMDatabase.h" #import "unistd.h" +#if FMDB_SQLITE_STANDALONE +#import +#else +#import +#endif + @interface FMDatabase () - (void)resultSetDidClose:(FMResultSet *)resultSet; @end diff --git a/src/fmdb/Info.plist b/src/fmdb/Info.plist new file mode 100644 index 00000000..f4d50a8c --- /dev/null +++ b/src/fmdb/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 2.6 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + +