Skip to content

Commit

Permalink
Add Swift 5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed Aug 28, 2019
1 parent d6a1b68 commit be6953d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
19 changes: 11 additions & 8 deletions FastImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,26 +194,27 @@
A1B48FC21A0DD89F001BB364 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Kyle Hickinson";
TargetAttributes = {
27CF938D223352940093543E = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
A1B48FD41A0DD89F001BB364 = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = A1B48FC51A0DD89F001BB364 /* Build configuration list for PBXProject "FastImage" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = A1B48FC11A0DD89F001BB364;
productRefGroup = A1B48FCB1A0DD89F001BB364 /* Products */;
Expand Down Expand Up @@ -317,7 +318,7 @@
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -364,7 +365,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -375,6 +376,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -427,6 +429,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -482,7 +485,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.kylehickinson.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -494,7 +497,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.kylehickinson.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
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 = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
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
6 changes: 2 additions & 4 deletions FastImage/DataExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ extension Data {
}
func read<ResultType>(_ range: Range<Data.Index>) throws -> ResultType {
if range.upperBound <= count {
return subdata(in: range).withUnsafeBytes({ $0.pointee })
return subdata(in: range).withUnsafeBytes { $0.load(as: ResultType.self) }
}
throw AccessError(range: range, data: self)
}
func readBytes(_ range: Range<Data.Index>) throws -> [UInt8] {
if range.upperBound <= count {
return subdata(in: range).withUnsafeBytes { bytes in
Array(UnsafeBufferPointer(start: bytes, count: range.count / MemoryLayout<UInt8>.stride))
}
return subdata(in: range).withUnsafeBytes { [UInt8]($0) }
}
throw AccessError(range: range, data: self)
}
Expand Down
4 changes: 4 additions & 0 deletions FastImage/Size Decoders/JPGSizeDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ final class JPGSizeDecoder: ImageSizeDecoder {
if exifString == "Exif" {
let exifData = data.advanced(by: offset + 8)
if let exif = try? Exif(data: exifData), imageOrientation == nil {
#if swift(>=5.0)
imageOrientation = exif.orientation
#else
imageOrientation = exif?.orientation
#endif
}
}
offset += Int(exifLength)
Expand Down

0 comments on commit be6953d

Please sign in to comment.