Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #43 from readium/fixes/xcode10.2
Browse files Browse the repository at this point in the history
Update Cartfile and fix Xcode 10.2 warnings
  • Loading branch information
aferditamuriqi authored May 23, 2019
2 parents d605378 + d0bba2f commit d731b6e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github "readium/r2-shared-swift" == 1.2.8
github "readium/r2-shared-swift" == 1.2.9
github "stephencelis/SQLite.swift" == 0.11.5
github "krzyzanowskim/CryptoSwift" == 0.15.0
github "weichsel/ZIPFoundation" == 0.9.8
11 changes: 9 additions & 2 deletions r2-lcp-swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
03C3CC66222DBD5B00A01731 /* R2LCPClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03C3CC65222DBD5B00A01731 /* R2LCPClient.framework */; };
CA26EF7C2280331E0011653E /* Connection.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA26EF7B2280331E0011653E /* Connection.swift */; };
CA2AE328221C3CFB008BD18F /* Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2AE327221C3CFB008BD18F /* Deprecated.swift */; };
CA4A38742208647400599297 /* PassphrasesRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA4A38732208647400599297 /* PassphrasesRepository.swift */; };
CA4A388722086F7500599297 /* PassphrasesService.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA4A388622086F7500599297 /* PassphrasesService.swift */; };
Expand Down Expand Up @@ -48,6 +49,7 @@

/* Begin PBXFileReference section */
03C3CC65222DBD5B00A01731 /* R2LCPClient.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = R2LCPClient.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CA26EF7B2280331E0011653E /* Connection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Connection.swift; sourceTree = "<group>"; };
CA2AE327221C3CFB008BD18F /* Deprecated.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Deprecated.swift; sourceTree = "<group>"; };
CA4A38732208647400599297 /* PassphrasesRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassphrasesRepository.swift; sourceTree = "<group>"; };
CA4A388622086F7500599297 /* PassphrasesService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassphrasesService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -200,6 +202,7 @@
F331FBF71F8228F8007F16DF /* Database.swift */,
F36F9E251F826C17001D0DB4 /* Licenses.swift */,
F36F9E271F8270FC001D0DB4 /* Transactions.swift */,
CA26EF7B2280331E0011653E /* Connection.swift */,
);
path = Persistence;
sourceTree = "<group>";
Expand Down Expand Up @@ -292,7 +295,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = Readium;
TargetAttributes = {
F3B2C8861F667222007601E4 = {
Expand All @@ -304,10 +307,11 @@
};
buildConfigurationList = F3B2C8811F667222007601E4 /* Build configuration list for PBXProject "r2-lcp-swift" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = F3B2C87D1F667222007601E4;
productRefGroup = F3B2C8881F667222007601E4 /* Products */;
Expand Down Expand Up @@ -362,6 +366,7 @@
F38FB0421F66847E00F9D602 /* Signature.swift in Sources */,
CABEB3E32215756D00090B6C /* Links.swift in Sources */,
F3B2C8A71F66727C007601E4 /* LicenseDocument.swift in Sources */,
CA26EF7C2280331E0011653E /* Connection.swift in Sources */,
CAE7FB7E220C4C5C00D03587 /* DeviceRepository.swift in Sources */,
F38FB03A1F6683D800F9D602 /* Encryption.swift in Sources */,
F3B2C8AC1F66727C007601E4 /* Link.swift in Sources */,
Expand All @@ -379,6 +384,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
Expand Down Expand Up @@ -441,6 +447,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
24 changes: 24 additions & 0 deletions readium-lcp-swift/Persistence/Connection.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Connection.swift
// r2-lcp-swift
//
// Created by Mickaël Menu on 06.05.19.
//
// Copyright 2019 Readium Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style license which is detailed
// in the LICENSE file present in the project repository where this source code is maintained.
//

import Foundation
import SQLite

extension Connection {

/// FIXME: Used to fix a crash with SQLite.swift pre Xcode 10.2.1.
/// We can't use the version 0.11.6 before Xcode 10.2, but the version 0.11.5 crashes on Xcode 10.2 (ie. https://github.com/stephencelis/SQLite.swift/issues/888)
func count(_ expressible: Expressible) throws -> Int64 {
let sql = "SELECT COUNT(*) FROM (\(expressible.asSQL())) AS countable;"
return (try scalar(sql) as? Int64) ?? 0
}

}
4 changes: 2 additions & 2 deletions readium-lcp-swift/Persistence/Licenses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Licenses {
private func exists(_ license: LicenseDocument) -> Bool {
let db = Database.shared.connection
let filterLicense = licenses.filter(id == license.id)
return ((try? db.scalar(filterLicense.count)) ?? 0) != 0
return ((try? db.count(filterLicense)) ?? 0) != 0
}

private func get(_ column: Expression<Int?>, for licenseId: String) throws -> Int? {
Expand Down Expand Up @@ -107,7 +107,7 @@ extension Licenses: DeviceRepository {

let db = Database.shared.connection
let query = licenses.filter(id == license.id && registered == true)
let count = try db.scalar(query.count)
let count = try db.count(query)
return count != 0
}

Expand Down

0 comments on commit d731b6e

Please sign in to comment.