diff --git a/GRDB.xcodeproj/project.pbxproj b/GRDB.xcodeproj/project.pbxproj index b9114eaf9..a17310e2d 100755 --- a/GRDB.xcodeproj/project.pbxproj +++ b/GRDB.xcodeproj/project.pbxproj @@ -16,10 +16,10 @@ 5605F15E1C672E4000235C62 /* DatabaseDateComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14C1C672E4000235C62 /* DatabaseDateComponents.swift */; }; 5605F15F1C672E4000235C62 /* DatabaseValue+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14D1C672E4000235C62 /* DatabaseValue+Foundation.swift */; }; 5605F1601C672E4000235C62 /* DatabaseValue+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14D1C672E4000235C62 /* DatabaseValue+Foundation.swift */; }; - 5605F1611C672E4000235C62 /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* NSData.swift */; }; - 5605F1621C672E4000235C62 /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* NSData.swift */; }; - 5605F1631C672E4000235C62 /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* NSDate.swift */; }; - 5605F1641C672E4000235C62 /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* NSDate.swift */; }; + 5605F1611C672E4000235C62 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* Data.swift */; }; + 5605F1621C672E4000235C62 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* Data.swift */; }; + 5605F1631C672E4000235C62 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* Date.swift */; }; + 5605F1641C672E4000235C62 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* Date.swift */; }; 5605F1651C672E4000235C62 /* NSNull.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1501C672E4000235C62 /* NSNull.swift */; }; 5605F1661C672E4000235C62 /* NSNull.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1501C672E4000235C62 /* NSNull.swift */; }; 5605F1671C672E4000235C62 /* NSNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1511C672E4000235C62 /* NSNumber.swift */; }; @@ -79,12 +79,12 @@ 560D924A1C672C4B00F4F92B /* RowConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92451C672C4B00F4F92B /* RowConvertible.swift */; }; 560D924B1C672C4B00F4F92B /* TableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92461C672C4B00F4F92B /* TableMapping.swift */; }; 560D924C1C672C4B00F4F92B /* TableMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 560D92461C672C4B00F4F92B /* TableMapping.swift */; }; - 560FC51B1CB003810014AA8E /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* NSData.swift */; }; + 560FC51B1CB003810014AA8E /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* Data.swift */; }; 560FC51C1CB003810014AA8E /* QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */; }; 560FC51D1CB003810014AA8E /* SQLCollation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollation.swift */; }; 560FC51E1CB003810014AA8E /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563445041C4A7FD7003D3DC6 /* Utils.swift */; }; 560FC51F1CB003810014AA8E /* CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1491C672E4000235C62 /* CGFloat.swift */; }; - 560FC5201CB003810014AA8E /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* NSDate.swift */; }; + 560FC5201CB003810014AA8E /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* Date.swift */; }; 560FC5211CB003810014AA8E /* SQLFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F18A1C6B1A8700235C62 /* SQLFunction.swift */; }; 560FC5221CB003810014AA8E /* RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1571C672E4000235C62 /* RawRepresentable.swift */; }; 560FC5231CB003810014AA8E /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238701B9C75030082EB20 /* Configuration.swift */; }; @@ -475,12 +475,12 @@ 56A5E4091BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A5E4081BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift */; }; 56A5E40A1BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A5E4081BA2BCF900707640 /* RecordWithColumnNameManglingTests.swift */; }; 56AFC97A1CB1A41E00F48B96 /* libsqlcipher.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 560FC5561CB004AD0014AA8E /* libsqlcipher.a */; }; - 56AFC9F01CB1A8BB00F48B96 /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* NSData.swift */; }; + 56AFC9F01CB1A8BB00F48B96 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* Data.swift */; }; 56AFC9F11CB1A8BB00F48B96 /* QueryInterfaceRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56300B6F1C53F592005A543B /* QueryInterfaceRequest.swift */; }; 56AFC9F21CB1A8BB00F48B96 /* SQLCollation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1891C6B1A8700235C62 /* SQLCollation.swift */; }; 56AFC9F31CB1A8BB00F48B96 /* Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238711B9C75030082EB20 /* Database.swift */; }; 56AFC9F41CB1A8BB00F48B96 /* CGFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1491C672E4000235C62 /* CGFloat.swift */; }; - 56AFC9F51CB1A8BB00F48B96 /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* NSDate.swift */; }; + 56AFC9F51CB1A8BB00F48B96 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* Date.swift */; }; 56AFC9F61CB1A8BB00F48B96 /* SQLFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F18A1C6B1A8700235C62 /* SQLFunction.swift */; }; 56AFC9F71CB1A8BB00F48B96 /* RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1571C672E4000235C62 /* RawRepresentable.swift */; }; 56AFC9F81CB1A8BB00F48B96 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 563445041C4A7FD7003D3DC6 /* Utils.swift */; }; @@ -788,8 +788,8 @@ F3BA801C1CFB288C003DC1BA /* DatabaseCoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14B1C672E4000235C62 /* DatabaseCoder.swift */; }; F3BA801D1CFB288C003DC1BA /* DatabaseDateComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14C1C672E4000235C62 /* DatabaseDateComponents.swift */; }; F3BA801E1CFB288C003DC1BA /* DatabaseValue+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14D1C672E4000235C62 /* DatabaseValue+Foundation.swift */; }; - F3BA801F1CFB288C003DC1BA /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* NSData.swift */; }; - F3BA80201CFB288C003DC1BA /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* NSDate.swift */; }; + F3BA801F1CFB288C003DC1BA /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* Data.swift */; }; + F3BA80201CFB288C003DC1BA /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* Date.swift */; }; F3BA80211CFB288C003DC1BA /* NSNull.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1501C672E4000235C62 /* NSNull.swift */; }; F3BA80221CFB288C003DC1BA /* NSNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1511C672E4000235C62 /* NSNumber.swift */; }; F3BA80231CFB288C003DC1BA /* NSString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1521C672E4000235C62 /* NSString.swift */; }; @@ -847,8 +847,8 @@ F3BA80781CFB2E61003DC1BA /* DatabaseCoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14B1C672E4000235C62 /* DatabaseCoder.swift */; }; F3BA80791CFB2E61003DC1BA /* DatabaseDateComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14C1C672E4000235C62 /* DatabaseDateComponents.swift */; }; F3BA807A1CFB2E61003DC1BA /* DatabaseValue+Foundation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14D1C672E4000235C62 /* DatabaseValue+Foundation.swift */; }; - F3BA807B1CFB2E61003DC1BA /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* NSData.swift */; }; - F3BA807C1CFB2E61003DC1BA /* NSDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* NSDate.swift */; }; + F3BA807B1CFB2E61003DC1BA /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14E1C672E4000235C62 /* Data.swift */; }; + F3BA807C1CFB2E61003DC1BA /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F14F1C672E4000235C62 /* Date.swift */; }; F3BA807D1CFB2E61003DC1BA /* NSNull.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1501C672E4000235C62 /* NSNull.swift */; }; F3BA807E1CFB2E61003DC1BA /* NSNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1511C672E4000235C62 /* NSNumber.swift */; }; F3BA807F1CFB2E61003DC1BA /* NSString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5605F1521C672E4000235C62 /* NSString.swift */; }; @@ -1217,8 +1217,8 @@ 5605F14B1C672E4000235C62 /* DatabaseCoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseCoder.swift; sourceTree = ""; }; 5605F14C1C672E4000235C62 /* DatabaseDateComponents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseDateComponents.swift; sourceTree = ""; }; 5605F14D1C672E4000235C62 /* DatabaseValue+Foundation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DatabaseValue+Foundation.swift"; sourceTree = ""; }; - 5605F14E1C672E4000235C62 /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSData.swift; sourceTree = ""; }; - 5605F14F1C672E4000235C62 /* NSDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDate.swift; sourceTree = ""; }; + 5605F14E1C672E4000235C62 /* Data.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = ""; }; + 5605F14F1C672E4000235C62 /* Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Date.swift; sourceTree = ""; }; 5605F1501C672E4000235C62 /* NSNull.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSNull.swift; sourceTree = ""; }; 5605F1511C672E4000235C62 /* NSNumber.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSNumber.swift; sourceTree = ""; }; 5605F1521C672E4000235C62 /* NSString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSString.swift; sourceTree = ""; }; @@ -1586,11 +1586,11 @@ 5605F14A1C672E4000235C62 /* Foundation */ = { isa = PBXGroup; children = ( + 5605F14E1C672E4000235C62 /* Data.swift */, 5605F14B1C672E4000235C62 /* DatabaseCoder.swift */, 5605F14C1C672E4000235C62 /* DatabaseDateComponents.swift */, 5605F14D1C672E4000235C62 /* DatabaseValue+Foundation.swift */, - 5605F14E1C672E4000235C62 /* NSData.swift */, - 5605F14F1C672E4000235C62 /* NSDate.swift */, + 5605F14F1C672E4000235C62 /* Date.swift */, 5605F1501C672E4000235C62 /* NSNull.swift */, 5605F1511C672E4000235C62 /* NSNumber.swift */, 5605F1521C672E4000235C62 /* NSString.swift */, @@ -2586,7 +2586,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0710; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Gwendal Roué"; TargetAttributes = { 56E5D7C91B4D3FED00430942 = { @@ -2597,9 +2597,11 @@ }; 56E5D7F81B4D422D00430942 = { CreatedOnToolsVersion = 7.0; + LastSwiftMigration = 0800; }; DC3773F219C8CBB3004FCF85 = { CreatedOnToolsVersion = 6.1; + LastSwiftMigration = 0800; }; F3BA7FFD1CFB25E4003DC1BA = { CreatedOnToolsVersion = 7.3.1; @@ -2916,12 +2918,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 560FC51B1CB003810014AA8E /* NSData.swift in Sources */, + 560FC51B1CB003810014AA8E /* Data.swift in Sources */, 560FC51C1CB003810014AA8E /* QueryInterfaceRequest.swift in Sources */, 560FC51D1CB003810014AA8E /* SQLCollation.swift in Sources */, 560FC51E1CB003810014AA8E /* Utils.swift in Sources */, 560FC51F1CB003810014AA8E /* CGFloat.swift in Sources */, - 560FC5201CB003810014AA8E /* NSDate.swift in Sources */, + 560FC5201CB003810014AA8E /* Date.swift in Sources */, 560FC5211CB003810014AA8E /* SQLFunction.swift in Sources */, 560FC5221CB003810014AA8E /* RawRepresentable.swift in Sources */, 560FC5231CB003810014AA8E /* Configuration.swift in Sources */, @@ -3165,12 +3167,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 56AFC9F01CB1A8BB00F48B96 /* NSData.swift in Sources */, + 56AFC9F01CB1A8BB00F48B96 /* Data.swift in Sources */, 56AFC9F11CB1A8BB00F48B96 /* QueryInterfaceRequest.swift in Sources */, 56AFC9F21CB1A8BB00F48B96 /* SQLCollation.swift in Sources */, 56AFC9F31CB1A8BB00F48B96 /* Database.swift in Sources */, 56AFC9F41CB1A8BB00F48B96 /* CGFloat.swift in Sources */, - 56AFC9F51CB1A8BB00F48B96 /* NSDate.swift in Sources */, + 56AFC9F51CB1A8BB00F48B96 /* Date.swift in Sources */, 56AFC9F61CB1A8BB00F48B96 /* SQLFunction.swift in Sources */, 56AFC9F71CB1A8BB00F48B96 /* RawRepresentable.swift in Sources */, 56AFC9F81CB1A8BB00F48B96 /* Utils.swift in Sources */, @@ -3400,12 +3402,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5605F1621C672E4000235C62 /* NSData.swift in Sources */, + 5605F1621C672E4000235C62 /* Data.swift in Sources */, 56300B791C53F592005A543B /* QueryInterfaceRequest.swift in Sources */, 5605F18E1C6B1A8700235C62 /* SQLCollation.swift in Sources */, 56A2387E1B9C75030082EB20 /* Database.swift in Sources */, 5605F15A1C672E4000235C62 /* CGFloat.swift in Sources */, - 5605F1641C672E4000235C62 /* NSDate.swift in Sources */, + 5605F1641C672E4000235C62 /* Date.swift in Sources */, 5605F1901C6B1A8700235C62 /* SQLFunction.swift in Sources */, 5605F1721C672E4000235C62 /* RawRepresentable.swift in Sources */, 563445061C4A7FD7003D3DC6 /* Utils.swift in Sources */, @@ -3633,12 +3635,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5605F1611C672E4000235C62 /* NSData.swift in Sources */, + 5605F1611C672E4000235C62 /* Data.swift in Sources */, 56300B781C53F592005A543B /* QueryInterfaceRequest.swift in Sources */, 5605F18D1C6B1A8700235C62 /* SQLCollation.swift in Sources */, 563445051C4A7FD7003D3DC6 /* Utils.swift in Sources */, 5605F1591C672E4000235C62 /* CGFloat.swift in Sources */, - 5605F1631C672E4000235C62 /* NSDate.swift in Sources */, + 5605F1631C672E4000235C62 /* Date.swift in Sources */, 5605F18F1C6B1A8700235C62 /* SQLFunction.swift in Sources */, 5605F1711C672E4000235C62 /* RawRepresentable.swift in Sources */, 56A2387B1B9C75030082EB20 /* Configuration.swift in Sources */, @@ -3700,9 +3702,9 @@ F3BA80131CFB2876003DC1BA /* DatabaseValue.swift in Sources */, F3BA80171CFB2876003DC1BA /* RowAdapter.swift in Sources */, F3BA802F1CFB289B003DC1BA /* SQLSelectQuery.swift in Sources */, - F3BA80201CFB288C003DC1BA /* NSDate.swift in Sources */, + F3BA80201CFB288C003DC1BA /* Date.swift in Sources */, F3BA80151CFB2876003DC1BA /* DatabaseWriter.swift in Sources */, - F3BA801F1CFB288C003DC1BA /* NSData.swift in Sources */, + F3BA801F1CFB288C003DC1BA /* Data.swift in Sources */, F3BA800A1CFB286A003DC1BA /* Configuration.swift in Sources */, F3BA80261CFB288C003DC1BA /* StatementArguments+Foundation.swift in Sources */, F3BA802D1CFB289B003DC1BA /* SQLFunction.swift in Sources */, @@ -3843,9 +3845,9 @@ F3BA806F1CFB2E55003DC1BA /* DatabaseValue.swift in Sources */, F3BA80731CFB2E55003DC1BA /* RowAdapter.swift in Sources */, F3BA808B1CFB2E70003DC1BA /* SQLSelectQuery.swift in Sources */, - F3BA807C1CFB2E61003DC1BA /* NSDate.swift in Sources */, + F3BA807C1CFB2E61003DC1BA /* Date.swift in Sources */, F3BA80711CFB2E55003DC1BA /* DatabaseWriter.swift in Sources */, - F3BA807B1CFB2E61003DC1BA /* NSData.swift in Sources */, + F3BA807B1CFB2E61003DC1BA /* Data.swift in Sources */, F3BA80661CFB2E55003DC1BA /* Configuration.swift in Sources */, F3BA80821CFB2E61003DC1BA /* StatementArguments+Foundation.swift in Sources */, F3BA80891CFB2E70003DC1BA /* SQLFunction.swift in Sources */, @@ -4083,6 +4085,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "Tests/GRDBPerformanceTests-Bridging.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -4151,6 +4154,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipherOSXTests; PRODUCT_NAME = GRDBTests; SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -4180,6 +4184,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -4211,6 +4216,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipherOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -4286,6 +4292,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipheriOSTests; PRODUCT_NAME = GRDBTests; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -4317,6 +4324,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCipheriOSEncryptedTests; PRODUCT_NAME = GRDBTests; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -4392,6 +4400,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBiOSTests; PRODUCT_NAME = GRDBTests; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -4407,6 +4416,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests; PRODUCT_NAME = GRDBTests; SDKROOT = macosx; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -4423,6 +4433,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBOSXTests; PRODUCT_NAME = GRDBTests; SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -4449,6 +4461,7 @@ ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -4491,6 +4504,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -4520,6 +4534,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -4540,6 +4555,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.9; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -4621,6 +4637,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCustomSQLite.GRDBCustomSQLiteiOSTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -4699,6 +4716,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.github.groue.GRDBCustomSQLiteOSXTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; diff --git a/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBCipherOSX.xcscheme b/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBCipherOSX.xcscheme index 1517e737e..7b68b015f 100644 --- a/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBCipherOSX.xcscheme +++ b/GRDB.xcodeproj/xcshareddata/xcschemes/GRDBCipherOSX.xcscheme @@ -1,6 +1,6 @@ ?, Int32, UnsafePointer?) -> NSComparisonResult + let function: (Int32, UnsafePointer?, Int32, UnsafePointer?) -> ComparisonResult /// Returns a collation. /// @@ -731,7 +731,7 @@ public final class DatabaseCollation { /// - parameters: /// - name: The function name. /// - function: A function that compares two strings. - public init(_ name: String, function: (String, String) -> NSComparisonResult) { + public init(_ name: String, function: (String, String) -> ComparisonResult) { self.name = name self.function = { (length1, buffer1, length2, buffer2) in // Buffers are not C strings: they do not end with \0. diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index 1122bd7dc..15de06c38 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -443,18 +443,18 @@ extension DatabasePool : DatabaseWriter { public func readFromWrite(_ block: (db: Database) -> Void) { writer.preconditionValidQueue() - let semaphore = dispatch_semaphore_create(0)! + let semaphore = DispatchSemaphore(value: 0) self.readerPool.get { reader in reader.performAsync { db in // Assume COMMIT DEFERRED TRANSACTION does not throw error. try! db.inTransaction(.deferred) { // Now we're isolated: release the writing queue - dispatch_semaphore_signal(semaphore) + semaphore.signal() block(db: db) return .commit } } } - dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER) + _ = semaphore.wait(timeout: .distantFuture) } } diff --git a/GRDB/Core/DatabaseScheduler.swift b/GRDB/Core/DatabaseScheduler.swift index d7e0c05df..b797db51b 100644 --- a/GRDB/Core/DatabaseScheduler.swift +++ b/GRDB/Core/DatabaseScheduler.swift @@ -32,8 +32,8 @@ final class DatabaseScheduler { allowedSerializedDatabases = [database] } - static func makeSerializedQueueAllowing(database: Database) -> dispatch_queue_t { - let queue = dispatch_queue_create("GRDB.SerializedDatabase", nil)! + static func makeSerializedQueueAllowing(database: Database) -> DispatchQueue { + let queue = DispatchQueue(label: "GRDB.SerializedDatabase") let scheduler = DatabaseScheduler(allowedSerializedDatabase: database) let unmanagedScheduler = Unmanaged.passRetained(scheduler) let schedulerPointer = unsafeBitCast(unmanagedScheduler, to: UnsafeMutablePointer.self) @@ -41,7 +41,7 @@ final class DatabaseScheduler { return queue } - static func dispatchSync(_ queue: dispatch_queue_t, database: Database, block: (db: Database) throws -> T) rethrows -> T { + static func dispatchSync(_ queue: DispatchQueue, database: Database, block: (db: Database) throws -> T) rethrows -> T { if let sourceScheduler = currentScheduler() { // We're in a queue where some databases are allowed. // @@ -59,7 +59,7 @@ final class DatabaseScheduler { // // let queue = dispatch_queue_create("...", nil) // dbQueue.inDatabase { db in - // dispatch_sync(queue) { + // queue.sync { // dbQueue.inDatabase { db in // // Never run // } @@ -76,10 +76,10 @@ final class DatabaseScheduler { // currently allowed databases inside. // // The impl function helps us turn dispatch_sync into a rethrowing function - func impl(_ queue: dispatch_queue_t, database: Database, block: (db: Database) throws -> T, onError: (ErrorProtocol) throws -> ()) rethrows -> T { + func impl(_ queue: DispatchQueue, database: Database, block: (db: Database) throws -> T, onError: (ErrorProtocol) throws -> ()) rethrows -> T { var result: T? = nil var blockError: ErrorProtocol? = nil - dispatch_sync(queue) { + queue.sync { let targetScheduler = currentScheduler()! assert(targetScheduler.allowedSerializedDatabases[0] === database) // sanity check @@ -105,10 +105,10 @@ final class DatabaseScheduler { // block to queue. // // The impl function helps us turn dispatch_sync into a rethrowing function - func impl(_ queue: dispatch_queue_t, database: Database, block: (db: Database) throws -> T, onError: (ErrorProtocol) throws -> ()) rethrows -> T { + func impl(_ queue: DispatchQueue, database: Database, block: (db: Database) throws -> T, onError: (ErrorProtocol) throws -> ()) rethrows -> T { var result: T? = nil var blockError: ErrorProtocol? = nil - dispatch_sync(queue) { + queue.sync { do { result = try block(db: database) } catch { diff --git a/GRDB/Core/DatabaseStore.swift b/GRDB/Core/DatabaseStore.swift index 32784728e..463e42bd1 100644 --- a/GRDB/Core/DatabaseStore.swift +++ b/GRDB/Core/DatabaseStore.swift @@ -5,8 +5,8 @@ import Foundation /// db.sqlite-journal, etc.) class DatabaseStore { let path: String - private let source: dispatch_source_t? - private let queue: dispatch_queue_t? + private let source: DispatchSource? + private let queue: DispatchQueue? init(path: String, attributes: [String: AnyObject]?) throws { self.path = path @@ -33,12 +33,12 @@ class DatabaseStore { let directoryDescriptor = open(directoryPath, O_EVTONLY) guard directoryDescriptor != -1 else { // Let NSFileManager throw a nice NSError - try NSFileManager.default().contentsOfDirectory(atPath: directoryPath) + try FileManager.default().contentsOfDirectory(atPath: directoryPath) // Come on, NSFileManager... OK just throw something that is somewhat relevant throw NSError(domain: NSCocoaErrorDomain, code: NSFileReadUnknownError, userInfo: nil) } - let queue = dispatch_queue_create("GRDB.DatabaseStore", nil)! + let queue = DispatchQueue(label: "GRDB.DatabaseStore") let source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, UInt(directoryDescriptor), DISPATCH_VNODE_WRITE, queue)! self.queue = queue self.source = source @@ -59,12 +59,12 @@ class DatabaseStore { deinit { if let source = source { - dispatch_source_cancel(source) + source.cancel() } } private static func setFileAttributes(directoryPath: String, databaseFileName: String, attributes: [String: AnyObject]) { - let fm = NSFileManager.default() + let fm = FileManager.default() // TODO: handle symbolic links: // // According to https://www.sqlite.org/changes.html diff --git a/GRDB/Core/DatabaseValue.swift b/GRDB/Core/DatabaseValue.swift index d43eea100..abdb042f5 100644 --- a/GRDB/Core/DatabaseValue.swift +++ b/GRDB/Core/DatabaseValue.swift @@ -34,7 +34,7 @@ public struct DatabaseValue { case string(String) /// The BLOB storage class, wrapping NSData. - case blob(NSData) + case blob(Data) } /// The SQLite storage @@ -130,7 +130,7 @@ public struct DatabaseValue { case SQLITE_BLOB: let bytes = sqlite3_value_blob(sqliteValue) let length = sqlite3_value_bytes(sqliteValue) - storage = .blob(NSData(bytes: bytes, length: Int(length))) // copy bytes + storage = .blob(Data(bytes: bytes, length: Int(length))) // copy bytes case let type: fatalError("Unexpected SQLite value type: \(type)") } @@ -233,7 +233,7 @@ extension DatabaseValue : StatementColumnConvertible { case SQLITE_BLOB: let bytes = sqlite3_column_blob(sqliteStatement, Int32(index)) let length = sqlite3_column_bytes(sqliteStatement, Int32(index)) - storage = .blob(NSData(bytes: bytes, length: Int(length))) // copy bytes + storage = .blob(Data(bytes: bytes, length: Int(length))) // copy bytes case let type: fatalError("Unexpected SQLite column type: \(type)") } diff --git a/GRDB/Core/SerializedDatabase.swift b/GRDB/Core/SerializedDatabase.swift index 1cb9ebdeb..dc47bba34 100644 --- a/GRDB/Core/SerializedDatabase.swift +++ b/GRDB/Core/SerializedDatabase.swift @@ -11,7 +11,7 @@ final class SerializedDatabase { } /// The dispatch queue - private let queue: dispatch_queue_t + private let queue: DispatchQueue init(path: String, configuration: Configuration = Configuration(), schemaCache: DatabaseSchemaCache) throws { // According to https://www.sqlite.org/threadsafe.html @@ -57,7 +57,7 @@ final class SerializedDatabase { /// Asynchronously executes a block in the serialized dispatch queue. func performAsync(_ block: (db: Database) -> Void) { - dispatch_async(queue) { + queue.async { block(db: self.db) } } diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index 48b18dbd7..b99e6ca4c 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -51,8 +51,8 @@ public class Statement { let sqlStart = UnsafePointer(codeUnits.baseAddress)! var sqlEnd: UnsafePointer? = nil code = sqlite3_prepare_v2(database.sqliteConnection, sqlStart, -1, &sqliteStatement, &sqlEnd) - let remainingData = NSData(bytesNoCopy: UnsafeMutablePointer(sqlEnd!), length: sqlStart + sqlCodeUnits.count - sqlEnd! - 1, freeWhenDone: false) - remainingSQL = String(data: remainingData, encoding: NSUTF8StringEncoding)!.trimmingCharacters(in: .whitespacesAndNewlines()) + let remainingData = Data(bytesNoCopy: UnsafeMutablePointer(sqlEnd!), length: sqlStart + sqlCodeUnits.count - sqlEnd! - 1, freeWhenDone: false) + remainingSQL = String(data: remainingData, encoding: .utf8)!.trimmingCharacters(in: .whitespacesAndNewlines()) } guard code == SQLITE_OK else { diff --git a/GRDB/Core/Support/Foundation/NSData.swift b/GRDB/Core/Support/Foundation/Data.swift similarity index 69% rename from GRDB/Core/Support/Foundation/NSData.swift rename to GRDB/Core/Support/Foundation/Data.swift index e3ad73891..937870175 100644 --- a/GRDB/Core/Support/Foundation/NSData.swift +++ b/GRDB/Core/Support/Foundation/Data.swift @@ -1,11 +1,11 @@ import Foundation /// NSData is convertible to and from DatabaseValue. -extension NSData : DatabaseValueConvertible { +extension Data : DatabaseValueConvertible { /// Returns a value that can be stored in the database. public var databaseValue: DatabaseValue { // SQLite cant' store zero-length blobs. - guard length > 0 else { + guard count > 0 else { return .null } return DatabaseValue(storage: .blob(self)) @@ -13,12 +13,10 @@ extension NSData : DatabaseValueConvertible { /// Returns an NSData initialized from *databaseValue*, if it contains /// a Blob. - public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self? { - switch databaseValue.storage { - case .blob(let data): - return self.init(data: data) - default: + public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Data? { + guard case .blob(let data) = databaseValue.storage else { return nil } + return data } } diff --git a/GRDB/Core/Support/Foundation/DatabaseCoder.swift b/GRDB/Core/Support/Foundation/DatabaseCoder.swift index 348eee4b3..3a2a67c58 100644 --- a/GRDB/Core/Support/Foundation/DatabaseCoder.swift +++ b/GRDB/Core/Support/Foundation/DatabaseCoder.swift @@ -24,7 +24,7 @@ public struct DatabaseCoder: DatabaseValueConvertible { /// Returns a DatabaseCoder if *databaseValue* contains an archived object. public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> DatabaseCoder? { - guard let data = NSData.fromDatabaseValue(databaseValue) else { + guard let data = Data.fromDatabaseValue(databaseValue) else { return nil } return DatabaseCoder(NSKeyedUnarchiver.unarchiveObject(with: data)) diff --git a/GRDB/Core/Support/Foundation/DatabaseDateComponents.swift b/GRDB/Core/Support/Foundation/DatabaseDateComponents.swift index df2da3e9c..7f1a98ee2 100644 --- a/GRDB/Core/Support/Foundation/DatabaseDateComponents.swift +++ b/GRDB/Core/Support/Foundation/DatabaseDateComponents.swift @@ -1,6 +1,6 @@ import Foundation -/// DatabaseDateComponents reads and stores NSDateComponents in the database. +/// DatabaseDateComponents reads and stores DateComponents in the database. public struct DatabaseDateComponents : DatabaseValueConvertible { /// The available formats for reading and storing date components. @@ -46,21 +46,21 @@ public struct DatabaseDateComponents : DatabaseValueConvertible { // MARK: - NSDateComponents conversion /// The date components - public let dateComponents: NSDateComponents + public let dateComponents: DateComponents /// The database format public let format: Format - /// Creates a DatabaseDateComponents from an NSDateComponents and a format. + /// Creates a DatabaseDateComponents from a DateComponents and a format. /// /// The result is nil if and only if *dateComponents* is nil. /// /// - parameters: - /// - dateComponents: An optional NSDateComponents. + /// - dateComponents: An optional DateComponents. /// - format: The format used for storing the date components in /// the database. /// - returns: An optional DatabaseDateComponents. - public init?(_ dateComponents: NSDateComponents?, format: Format) { + public init?(_ dateComponents: DateComponents?, format: Format) { guard let dateComponents = dateComponents else { return nil } @@ -76,9 +76,9 @@ public struct DatabaseDateComponents : DatabaseValueConvertible { let dateString: String? switch format { case .YMD_HM, .YMD_HMS, .YMD_HMSS, .YMD: - let year = (dateComponents.year == NSDateComponentUndefined) ? 0 : dateComponents.year - let month = (dateComponents.month == NSDateComponentUndefined) ? 1 : dateComponents.month - let day = (dateComponents.day == NSDateComponentUndefined) ? 1 : dateComponents.day + let year = dateComponents.year ?? 0 + let month = dateComponents.month ?? 1 + let day = dateComponents.day ?? 1 dateString = NSString(format: "%04d-%02d-%02d", year, month, day) as String default: dateString = nil @@ -87,19 +87,19 @@ public struct DatabaseDateComponents : DatabaseValueConvertible { let timeString: String? switch format { case .YMD_HM, .HM: - let hour = (dateComponents.hour == NSDateComponentUndefined) ? 0 : dateComponents.hour - let minute = (dateComponents.minute == NSDateComponentUndefined) ? 0 : dateComponents.minute + let hour = dateComponents.hour ?? 0 + let minute = dateComponents.minute ?? 0 timeString = NSString(format: "%02d:%02d", hour, minute) as String case .YMD_HMS, .HMS: - let hour = (dateComponents.hour == NSDateComponentUndefined) ? 0 : dateComponents.hour - let minute = (dateComponents.minute == NSDateComponentUndefined) ? 0 : dateComponents.minute - let second = (dateComponents.second == NSDateComponentUndefined) ? 0 : dateComponents.second + let hour = dateComponents.hour ?? 0 + let minute = dateComponents.minute ?? 0 + let second = dateComponents.second ?? 0 timeString = NSString(format: "%02d:%02d:%02d", hour, minute, second) as String case .YMD_HMSS, .HMSS: - let hour = (dateComponents.hour == NSDateComponentUndefined) ? 0 : dateComponents.hour - let minute = (dateComponents.minute == NSDateComponentUndefined) ? 0 : dateComponents.minute - let second = (dateComponents.second == NSDateComponentUndefined) ? 0 : dateComponents.second - let nanosecond = (dateComponents.nanosecond == NSDateComponentUndefined) ? 0 : dateComponents.nanosecond + let hour = dateComponents.hour ?? 0 + let minute = dateComponents.minute ?? 0 + let second = dateComponents.second ?? 0 + let nanosecond = dateComponents.nanosecond ?? 0 timeString = NSString(format: "%02d:%02d:%02d.%03d", hour, minute, second, Int(round(Double(nanosecond) / 1_000_000.0))) as String default: timeString = nil @@ -131,9 +131,9 @@ public struct DatabaseDateComponents : DatabaseValueConvertible { return nil } - let dateComponents = NSDateComponents() - let scanner = NSScanner(string: string) - scanner.charactersToBeSkipped = NSCharacterSet() + var dateComponents = DateComponents() + let scanner = Scanner(string: string) + scanner.charactersToBeSkipped = CharacterSet() let hasDate: Bool @@ -264,7 +264,7 @@ public struct DatabaseDateComponents : DatabaseValueConvertible { // SSS var millisecondDigits: NSString? = nil - if scanner.scanCharacters(from: .decimalDigits(), into: &millisecondDigits), var millisecondDigits = millisecondDigits { + if scanner.scanCharacters(from: .decimalDigits, into: &millisecondDigits), var millisecondDigits = millisecondDigits { if millisecondDigits.length > 3 { millisecondDigits = NSString(string: millisecondDigits.substring(to: 3)) } diff --git a/GRDB/Core/Support/Foundation/NSDate.swift b/GRDB/Core/Support/Foundation/Date.swift similarity index 69% rename from GRDB/Core/Support/Foundation/NSDate.swift rename to GRDB/Core/Support/Foundation/Date.swift index f1fae8494..8bc283173 100644 --- a/GRDB/Core/Support/Foundation/NSDate.swift +++ b/GRDB/Core/Support/Foundation/Date.swift @@ -1,16 +1,16 @@ import Foundation -/// NSDate are stored in the database using the format +/// Date is stored in the database using the format /// "yyyy-MM-dd HH:mm:ss.SSS", in the UTC time zone. -extension NSDate : DatabaseValueConvertible { +extension Date : DatabaseValueConvertible { /// Returns a value that can be stored in the database. public var databaseValue: DatabaseValue { return storageDateFormatter.string(from: self).databaseValue } - /// Returns an NSDate initialized from *databaseValue*, if possible. - public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Self? { + /// Returns a Date initialized from *databaseValue*, if possible. + public static func fromDatabaseValue(_ databaseValue: DatabaseValue) -> Date? { if let databaseDateComponents = DatabaseDateComponents.fromDatabaseValue(databaseValue) { return fromDatabaseDateComponents(databaseDateComponents) } @@ -20,7 +20,7 @@ extension NSDate : DatabaseValueConvertible { return nil } - private static func fromJulianDayNumber(_ julianDayNumber: Double) -> Self? { + private static func fromJulianDayNumber(_ julianDayNumber: Double) -> Date? { // Conversion uses the same algorithm as SQLite: https://www.sqlite.org/src/artifact/8ec787fed4929d8c let JD = Int64(julianDayNumber * 86400000) let Z = Int(((JD + 43200000)/86400000)) @@ -43,7 +43,7 @@ extension NSDate : DatabaseValueConvertible { let minute = s/60 second += Double(s - minute*60) - let dateComponents = NSDateComponents() + var dateComponents = DateComponents() dateComponents.year = year dateComponents.month = month dateComponents.day = day @@ -52,33 +52,31 @@ extension NSDate : DatabaseValueConvertible { dateComponents.second = Int(second) dateComponents.nanosecond = Int((second - Double(Int(second))) * 1.0e9) - let date = UTCCalendar.date(from: dateComponents)! - return self.init(timeInterval: 0, since: date) + return UTCCalendar.date(from: dateComponents)! } - private static func fromDatabaseDateComponents(_ databaseDateComponents: DatabaseDateComponents) -> Self? { + private static func fromDatabaseDateComponents(_ databaseDateComponents: DatabaseDateComponents) -> Date? { guard databaseDateComponents.format.hasYMDComponents else { - // Refuse to turn hours without any date information into NSDate: + // Refuse to turn hours without any date information into Date: return nil } - let date = UTCCalendar.date(from: databaseDateComponents.dateComponents)! - return self.init(timeInterval: 0, since: date) + return UTCCalendar.date(from: databaseDateComponents.dateComponents)! } } /// The DatabaseDate date formatter for stored dates. -private let storageDateFormatter: NSDateFormatter = { - let formatter = NSDateFormatter() +private let storageDateFormatter: DateFormatter = { + let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS" - formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") - formatter.timeZone = NSTimeZone(forSecondsFromGMT: 0) + formatter.locale = Locale(localeIdentifier: "en_US_POSIX") + formatter.timeZone = TimeZone(forSecondsFromGMT: 0) return formatter }() // The NSCalendar for stored dates. -private let UTCCalendar: NSCalendar = { - let calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)! - calendar.locale = NSLocale(localeIdentifier: "en_US_POSIX") - calendar.timeZone = NSTimeZone(forSecondsFromGMT: 0) +private let UTCCalendar: Calendar = { + let calendar = Calendar(calendarIdentifier: .gregorian)! + calendar.locale = Locale(localeIdentifier: "en_US_POSIX") + calendar.timeZone = TimeZone(forSecondsFromGMT: 0) return calendar }() diff --git a/GRDB/Core/Support/Foundation/NSURL.swift b/GRDB/Core/Support/Foundation/NSURL.swift index 6793073fc..ca4af58b5 100644 --- a/GRDB/Core/Support/Foundation/NSURL.swift +++ b/GRDB/Core/Support/Foundation/NSURL.swift @@ -6,7 +6,7 @@ extension NSURL : DatabaseValueConvertible { /// Returns a value that can be stored in the database. /// (the URL's absoluteString). public var databaseValue: DatabaseValue { - return absoluteString.databaseValue + return absoluteString?.databaseValue ?? .null } /// Returns an NSURL initialized from *databaseValue*, if possible. diff --git a/GRDB/Core/Utils.swift b/GRDB/Core/Utils.swift index 402786958..b9ce57735 100644 --- a/GRDB/Core/Utils.swift +++ b/GRDB/Core/Utils.swift @@ -51,11 +51,11 @@ func GRDBPrecondition(_ condition: @autoclosure() -> Bool, _ message: @autoclosu /// A function declared as rethrows that synchronously executes a throwing /// block in a dispatch_queue. -func dispatchSync(_ queue: dispatch_queue_t, _ block: () throws -> T) rethrows -> T { - func impl(_ queue: dispatch_queue_t, block: () throws -> T, onError: (ErrorProtocol) throws -> ()) rethrows -> T { +func dispatchSync(_ queue: DispatchQueue, _ block: () throws -> T) rethrows -> T { + func impl(_ queue: DispatchQueue, block: () throws -> T, onError: (ErrorProtocol) throws -> ()) rethrows -> T { var result: T? = nil var blockError: ErrorProtocol? = nil - dispatch_sync(queue) { + queue.sync { do { result = try block() } catch { @@ -132,25 +132,25 @@ final class ReadWriteBox { init(_ value: T) { self._value = value - self.queue = dispatch_queue_create("GRDB.ReadWriteBox", DISPATCH_QUEUE_CONCURRENT) + self.queue = DispatchQueue(label: "GRDB.ReadWriteBox", attributes: [.concurrent]) } func read(_ block: (T) -> U) -> U { var result: U? = nil - dispatch_sync(queue) { + queue.sync { result = block(self._value) } return result! } func write(_ block: (inout T) -> Void) { - dispatch_barrier_sync(queue) { + queue.sync(flags: [.barrier]) { block(&self._value) } } private var _value: T - private var queue: dispatch_queue_t + private var queue: DispatchQueue } /// A Pool maintains a set of elements that are built them on demand. A pool has @@ -192,14 +192,14 @@ final class ReadWriteBox { final class Pool { var makeElement: (() -> T)? private var items: [PoolItem] = [] - private let queue: dispatch_queue_t // protects items - private let semaphore: dispatch_semaphore_t // limits the number of elements + private let queue: DispatchQueue // protects items + private let semaphore: DispatchSemaphore // limits the number of elements init(maximumCount: Int, makeElement: (() -> T)? = nil) { GRDBPrecondition(maximumCount > 0, "Pool size must be at least 1") self.makeElement = makeElement - self.queue = dispatch_queue_create("GRDB.Pool", nil) - self.semaphore = dispatch_semaphore_create(maximumCount)! + self.queue = DispatchQueue(label: "GRDB.Pool") + self.semaphore = DispatchSemaphore(value: maximumCount) } /// Returns a tuple (element, releaseElement()) @@ -243,8 +243,8 @@ final class Pool { private func lockItem() -> PoolItem { var item: PoolItem! = nil - dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER) - dispatch_sync(queue) { + _ = semaphore.wait(timeout: .distantFuture) + queue.sync { if let availableItem = self.items.first(where: { $0.available }) { item = availableItem item.available = false @@ -257,10 +257,10 @@ final class Pool { } private func unlockItem(_ item: PoolItem) { - dispatch_sync(queue) { + queue.sync { item.available = true } - dispatch_semaphore_signal(semaphore) + semaphore.signal() } } diff --git a/GRDB/Record/FetchedRecordsController.swift b/GRDB/Record/FetchedRecordsController.swift index 76a7da970..90a620e52 100644 --- a/GRDB/Record/FetchedRecordsController.swift +++ b/GRDB/Record/FetchedRecordsController.swift @@ -36,7 +36,7 @@ public final class FetchedRecordsController { /// /// This function should return true if the two records have the /// same identity. For example, they have the same id. - public convenience init(_ databaseWriter: DatabaseWriter, sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, queue: dispatch_queue_t = dispatch_get_main_queue(), isSameRecord: ((Record, Record) -> Bool)? = nil) { + public convenience init(_ databaseWriter: DatabaseWriter, sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, queue: DispatchQueue = .main, isSameRecord: ((Record, Record) -> Bool)? = nil) { self.init(databaseWriter, request: SQLFetchRequest(sql: sql, arguments: arguments, adapter: adapter), queue: queue, isSameRecord: isSameRecord) } @@ -64,7 +64,7 @@ public final class FetchedRecordsController { /// /// This function should return true if the two records have the /// same identity. For example, they have the same id. - public convenience init(_ databaseWriter: DatabaseWriter, request: FetchRequest, queue: dispatch_queue_t = dispatch_get_main_queue(), isSameRecord: ((Record, Record) -> Bool)? = nil) { + public convenience init(_ databaseWriter: DatabaseWriter, request: FetchRequest, queue: DispatchQueue = .main, isSameRecord: ((Record, Record) -> Bool)? = nil) { if let isSameRecord = isSameRecord { self.init(databaseWriter, request: request, queue: queue, isSameItemFactory: { _ in { isSameRecord($0.record, $1.record) } }) } else { @@ -72,7 +72,7 @@ public final class FetchedRecordsController { } } - private init(_ databaseWriter: DatabaseWriter, request: FetchRequest, queue: dispatch_queue_t, isSameItemFactory: (Database) -> (Item, Item) -> Bool) { + private init(_ databaseWriter: DatabaseWriter, request: FetchRequest, queue: DispatchQueue, isSameItemFactory: (Database) -> (Item, Item) -> Bool) { self.request = request self.databaseWriter = databaseWriter self.isSameItem = { _ in return false } @@ -125,7 +125,7 @@ public final class FetchedRecordsController { /// The dispatch queue on which the controller must be used. /// /// Unless specified otherwise at initialization time, it is the main queue. - public let queue: dispatch_queue_t + public let queue: DispatchQueue /// Updates the fetch request, and notifies the delegate of changes in the /// fetched records if delegate is not nil, and performFetch() has been @@ -398,7 +398,7 @@ extension FetchedRecordsController where Record: TableMapping { /// /// - compareRecordsByPrimaryKey: A boolean that tells if two records /// share the same identity if they share the same primay key. - public convenience init(_ databaseWriter: DatabaseWriter, sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, queue: dispatch_queue_t = dispatch_get_main_queue(), compareRecordsByPrimaryKey: Bool) { + public convenience init(_ databaseWriter: DatabaseWriter, sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, queue: DispatchQueue = .main, compareRecordsByPrimaryKey: Bool) { self.init(databaseWriter, request: SQLFetchRequest(sql: sql, arguments: arguments, adapter: adapter), queue: queue, compareRecordsByPrimaryKey: compareRecordsByPrimaryKey) } @@ -423,7 +423,7 @@ extension FetchedRecordsController where Record: TableMapping { /// /// - compareRecordsByPrimaryKey: A boolean that tells if two records /// share the same identity if they share the same primay key. - public convenience init(_ databaseWriter: DatabaseWriter, request: FetchRequest, queue: dispatch_queue_t = dispatch_get_main_queue(), compareRecordsByPrimaryKey: Bool) { + public convenience init(_ databaseWriter: DatabaseWriter, request: FetchRequest, queue: DispatchQueue = .main, compareRecordsByPrimaryKey: Bool) { if compareRecordsByPrimaryKey { self.init(databaseWriter, request: request, queue: queue, isSameItemFactory: { db in let comparator = try! makePrimaryKeyComparator(db, tableName: Record.databaseTableName()) @@ -515,7 +515,7 @@ private class FetchedChangesController { // fetch: let's immediately dispatch the processing task in our // serialized FIFO queue, but have it wait for our fetch to complete, // with a semaphore: - let semaphore = dispatch_semaphore_create(0)! + let semaphore = DispatchSemaphore(value: 0) var fetchedItems: [Item]! = nil var fetchedAlongside: T! = nil @@ -524,15 +524,15 @@ private class FetchedChangesController { fetchedAlongside = self.fetchAlongside(db) // Fetch is complete: - dispatch_semaphore_signal(semaphore) + semaphore.signal() } // Process the fetched items - dispatch_async(observer.queue) { [weak observer] in + observer.queue.async { [weak observer] in // Wait for the fetch to complete: - dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER) + _ = semaphore.wait(timeout: .distantFuture) assert(fetchedItems != nil) assert(fetchedAlongside != nil) @@ -570,7 +570,7 @@ private class FetchedChangesController { // Ready for next check strongObserver.items = fetchedItems - dispatch_async(controllerQueue) { + controllerQueue.async { // Observer invalidated? guard let strongObserver = observer else { return } guard strongObserver.isValid else { return } @@ -610,7 +610,7 @@ private final class FetchedRecordsObserver : Transaction let observedTables: Set var needsComputeChanges: Bool var items: [Item]! // ought to be not nil when observer has started tracking transactions - let queue: dispatch_queue_t // protects items + let queue: DispatchQueue // protects items var checkForChanges: (FetchedRecordsObserver) -> () init(observedTables: Set, checkForChanges: (FetchedRecordsObserver) -> ()) { @@ -618,7 +618,7 @@ private final class FetchedRecordsObserver : Transaction self.items = nil self.observedTables = observedTables self.needsComputeChanges = false - self.queue = dispatch_queue_create("GRDB.FetchedRecordsObserver", DISPATCH_QUEUE_SERIAL) + self.queue = DispatchQueue(label: "GRDB.FetchedRecordsObserver") self.checkForChanges = checkForChanges } diff --git a/Support/module.modulemap b/Support/module.modulemap index 57256af46..562629e1e 100644 --- a/Support/module.modulemap +++ b/Support/module.modulemap @@ -6,16 +6,16 @@ framework module GRDB { } module SQLiteMacOSX { - header "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sqlite3.h" + header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sqlite3.h" export * } module SQLiteiPhoneOS { - header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sqlite3.h" + header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/sqlite3.h" export * } module SQLiteiPhoneSimulator { - header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h" + header "/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h" export * }