Skip to content

Commit

Permalink
Merge pull request #8 from jeanetienne/update
Browse files Browse the repository at this point in the history
Update to Swift 4.2 and minor changes
  • Loading branch information
jeanetienne authored Jan 23, 2019
2 parents f0178f8 + b77bbcd commit 9ed76ed
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 342 deletions.
50 changes: 19 additions & 31 deletions AssetResizer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
F70398681EE6D347003F2AD6 /* update-version.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "update-version.sh"; sourceTree = "<group>"; };
F70398691EE6D347003F2AD6 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
F703986A1EE6D347003F2AD6 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
F703986C1EE6D7A7003F2AD6 /* .travis.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .travis.yml; sourceTree = "<group>"; };
Expand Down Expand Up @@ -87,7 +86,6 @@
F70398691EE6D347003F2AD6 /* LICENSE */,
F703986A1EE6D347003F2AD6 /* README.md */,
F703986C1EE6D7A7003F2AD6 /* .travis.yml */,
F70398681EE6D347003F2AD6 /* update-version.sh */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -175,7 +173,6 @@
F79678DF1EDFD14600AC0948 /* Frameworks */,
F79678E01EDFD14600AC0948 /* Headers */,
F79678E11EDFD14600AC0948 /* Resources */,
F7F0E35C1EE2693400E09A9A /* Increment Build Number */,
);
buildRules = (
);
Expand Down Expand Up @@ -211,19 +208,19 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "Jean-Étienne";
TargetAttributes = {
F79678E21EDFD14600AC0948 = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = N44EJ7YB22;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
};
F79678EB1EDFD14600AC0948 = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = N44EJ7YB22;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -266,23 +263,6 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
F7F0E35C1EE2693400E09A9A /* Increment Build Number */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Increment Build Number";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "sh update-version.sh --xcodeproj=$PROJECT_FILE --plist=$INFOPLIST_FILE";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
F79678DE1EDFD14600AC0948 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -334,13 +314,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 All @@ -350,7 +332,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 9;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -393,13 +375,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 All @@ -409,7 +393,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 9;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -439,7 +423,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = N44EJ7YB22;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 2;
DYLIB_CURRENT_VERSION = 9;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = AssetResizer/Info.plist;
Expand All @@ -449,7 +433,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -462,7 +447,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = N44EJ7YB22;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 2;
DYLIB_CURRENT_VERSION = 9;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = AssetResizer/Info.plist;
Expand All @@ -471,7 +456,8 @@
PRODUCT_BUNDLE_IDENTIFIER = net.jeanetienne.AssetResizer;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -485,7 +471,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = net.jeanetienne.AssetResizerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -499,7 +486,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = net.jeanetienne.AssetResizerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
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 = "0900"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,8 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
9 changes: 3 additions & 6 deletions AssetResizer/AppIconSet.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// AppIconSet.swift
// AssetResizer
//
// Created by Jean-Étienne on 2/6/17.
// Copyright © 2017 Jean-Étienne. All rights reserved.
// Copyright © 2019 Jean-Étienne. All rights reserved.
//

import Foundation
Expand Down Expand Up @@ -48,7 +45,7 @@ public struct AppIconSet {
if let jsonSizes = jsonContents["images"] as? [[String: String]] {
return jsonSizes.map { jsonSize -> SizeDescription? in
return SizeDescription(json: jsonSize)
}.flatMap { $0 }
}.compactMap { $0 }
} else {
return []
}
Expand Down Expand Up @@ -118,7 +115,7 @@ public struct AppIconSet {

return newJsonSize
}
.flatMap { $0 }
.compactMap { $0 }

do {
try AppIconSet.write(jsonContents: jsonContents, atPath: jsonPath)
Expand Down
6 changes: 3 additions & 3 deletions AssetResizer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.2</string>
<string>0.1.0</string>
<key>CFBundleVersion</key>
<string>8</string>
<string>9</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Jean-Étienne. All rights reserved.</string>
<string>Copyright © 2019 Jean-Étienne. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
7 changes: 2 additions & 5 deletions AssetResizer/NSImage+Resizing.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// NSImage+Resizing.swift
// AssetResizer
//
// Created by Jean-Étienne on 1/6/17.
// Copyright © 2017 Jean-Étienne. All rights reserved.
// Copyright © 2019 Jean-Étienne. All rights reserved.
//

import AppKit
Expand All @@ -14,7 +11,7 @@ extension NSImage {
let frame = CGRect(origin: CGPoint.zero, size: size)
guard let bestRepresentation = self.bestRepresentation(for: frame,
context: nil,
hints: [NSImageHintInterpolation: NSImageInterpolation.high])
hints: [.interpolation: NSImageInterpolation.high])
else {
return nil
}
Expand Down
9 changes: 3 additions & 6 deletions AssetResizer/NSImage+Saving.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// NSImage+Saving.swift
// AssetResizer
//
// Created by Jean-Étienne on 1/6/17.
// Copyright © 2017 Jean-Étienne. All rights reserved.
// Copyright © 2019 Jean-Étienne. All rights reserved.
//

import AppKit
Expand All @@ -14,15 +11,15 @@ extension NSImage {
case WritingBitmapRepresentationFailed
}

func save(to url: URL, type: NSBitmapImageFileType) throws {
func save(to url: URL, type: NSBitmapImageRep.FileType) throws {
if let bitmapRepresentation = representation(forType: type) {
try bitmapRepresentation.write(to: url, options: .atomicWrite)
} else {
throw ImageSavingError.WritingBitmapRepresentationFailed
}
}

private func representation(forType type: NSBitmapImageFileType) -> Data? {
private func representation(forType type: NSBitmapImageRep.FileType) -> Data? {
if let tiff = self.tiffRepresentation, let tiffData = NSBitmapImageRep(data: tiff) {
return tiffData.representation(using: type, properties: [:])
}
Expand Down
23 changes: 10 additions & 13 deletions AssetResizer/ResizedImage.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// ResizedImage.swift
// AssetResizer
//
// Created by Jean-Étienne on 1/6/17.
// Copyright © 2017 Jean-Étienne. All rights reserved.
// Copyright © 2019 Jean-Étienne. All rights reserved.
//

import AppKit
Expand All @@ -21,7 +18,7 @@ public struct ResizedImage {
public let sizeDescription: SizeDescription

/// The bitmap type to be used when saving this image to disk
public let bitmapType: NSBitmapImageFileType
public let bitmapType: NSBitmapImageRep.FileType

/// The filename to be used when saving this image to disk
public var filename: String {
Expand All @@ -39,7 +36,7 @@ public struct ResizedImage {
init?(original: NSImage,
name aName: String,
resizing aSizeDescription: SizeDescription,
bitmapType aBitmapType: NSBitmapImageFileType) {
bitmapType aBitmapType: NSBitmapImageRep.FileType) {
guard let resizedOriginal = original.resize(to: aSizeDescription.pixelSize) else {
return nil
}
Expand Down Expand Up @@ -140,21 +137,21 @@ private extension CGFloat {

}

private extension NSBitmapImageFileType {
private extension NSBitmapImageRep.FileType {

var fileExtension: String {
switch self {
case .TIFF:
case .tiff:
return "tiff"
case .BMP:
case .bmp:
return "bmp"
case .GIF:
case .gif:
return "gif"
case .JPEG:
case .jpeg:
return "jpg"
case .PNG:
case .png:
return "png"
case .JPEG2000:
case .jpeg2000:
return "jpg"
}
}
Expand Down
11 changes: 4 additions & 7 deletions AssetResizerTests/AppIconSetTests.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// AppIconSetTests.swift
// AssetResizer
//
// Created by Jean-Étienne on 2/6/17.
// Copyright © 2017 Jean-Étienne. All rights reserved.
// Copyright © 2019 Jean-Étienne. All rights reserved.
//

import XCTest
Expand Down Expand Up @@ -64,8 +61,8 @@ class AppIconSetTests: XCTestCase {
return ResizedImage(original: originalImage,
name: sizeDescription.canonicalName,
resizing: sizeDescription,
bitmapType: .PNG)
}.flatMap { $0 }
bitmapType: .png)
}.compactMap { $0 }

do {
try appIconSet.update(with: resizedImages)
Expand All @@ -74,7 +71,7 @@ class AppIconSetTests: XCTestCase {
}

if let updatedSizes = AppIconSet(atPath: appIconSetPath)?.jsonRepresentation["images"] as? [[String: String]] {
let updatedFilenames = updatedSizes.map { $0["filename"] }.flatMap { $0 }.sorted()
let updatedFilenames = updatedSizes.map { $0["filename"] }.compactMap { $0 }.sorted()
let expectedFilenames = [
"[email protected]",
"[email protected]",
Expand Down
5 changes: 1 addition & 4 deletions AssetResizerTests/AssetResizerTests.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//
// AssetResizerTests.swift
// AssetResizer
//
// Created by Jean-Étienne on 1/6/17.
// Copyright © 2017 Jean-Étienne. All rights reserved.
// Copyright © 2019 Jean-Étienne. All rights reserved.
//

import XCTest
Expand Down
Loading

0 comments on commit 9ed76ed

Please sign in to comment.