Skip to content

Commit

Permalink
Updates to Swift 4.2 and fixed a few warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
jstapels committed Jul 16, 2019
1 parent 46481c8 commit b503455
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
14 changes: 10 additions & 4 deletions GoFont.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Code Adepts";
TargetAttributes = {
AD6FB7901E207ED8001BA39D = {
Expand All @@ -145,7 +145,7 @@
};
buildConfigurationList = AD6FB78C1E207ED8001BA39D /* Build configuration list for PBXProject "GoFont" */;
compatibilityVersion = "Xcode 8.0";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -211,6 +211,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand All @@ -220,13 +221,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -266,6 +269,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand All @@ -275,13 +279,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -316,7 +322,7 @@
CODE_SIGN_ENTITLEMENTS = GoFont/GoFont.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 9TC6Q3R3J9;
DEVELOPMENT_TEAM = S4533V6XQ6;
INFOPLIST_FILE = GoFont/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
Expand All @@ -336,7 +342,7 @@
CODE_SIGN_ENTITLEMENTS = GoFont/GoFont.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 9TC6Q3R3J9;
DEVELOPMENT_TEAM = S4533V6XQ6;
INFOPLIST_FILE = GoFont/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
Expand Down
9 changes: 5 additions & 4 deletions GoFont/FontManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FontManager {
}

func getFont(name: String) -> FontFamily? {
return handlers.flatMap({ $0.getFont(name: name) }).first
return handlers.compactMap({ $0.getFont(name: name) }).first
}
}

Expand Down Expand Up @@ -94,10 +94,11 @@ struct AnyFont: Hashable, Comparable {
var font: FontFamily
var variantId: String

var hashValue: Int {
return 31 &* font.name.hashValue &+ variantId.hashValue
func hash(into hasher: inout Hasher) {
hasher.combine(font.name)
hasher.combine(variantId)
}

static func == (lhs: AnyFont, rhs: AnyFont) -> Bool {
return lhs.font.name == rhs.font.name && lhs.variantId == rhs.variantId
}
Expand Down
2 changes: 1 addition & 1 deletion GoFont/GoogleFonts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ struct GoogleFonts: FontHandler {
func query(search: String, sort: FontSort) -> [FontFamily] {
return families[sort]!
.filter { search.isEmpty || $0.lowercased().contains(search.lowercased()) }
.map { fonts[$0]! }
.compactMap { fonts[$0] }
}

func getFont(name: String) -> FontFamily? {
Expand Down
2 changes: 1 addition & 1 deletion GoFont/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ class ViewController: NSViewController, NSTextFieldDelegate, WKScriptMessageHand
// Selected fonts html.
let selectionsHtml = selectedFamilyIds
.filter { !shownIds.contains($0) }
.flatMap { getSelectedFontHtml(name: $0) }
.compactMap { getSelectedFontHtml(name: $0) }
.joined()

// Render output.
Expand Down

0 comments on commit b503455

Please sign in to comment.