Skip to content

Commit 181ba93

Browse files
authored
Merge pull request #257 from hyperoslo/swift-5-update
Swift 5 update
2 parents 6adcf97 + 3f253ea commit 181ba93

File tree

10 files changed

+32
-28
lines changed

10 files changed

+32
-28
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ version: 2
22
jobs:
33
build-and-test:
44
macos:
5-
xcode: "10.0.0"
5+
xcode: "11.0.0"
66
shell: /bin/bash --login -o pipefail
77
steps:
88
- checkout
99
- run: xcodebuild -project Cache.xcodeproj -scheme "Cache-macOS" -sdk macosx clean
1010
- run: xcodebuild -project Cache.xcodeproj -scheme "Cache-macOS" -sdk macosx -enableCodeCoverage YES test
1111
- run: xcodebuild -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator clean
12-
- run: xcodebuild -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=12.0,name=iPhone X' -enableCodeCoverage YES test
13-
- run: xcodebuild -project Cache.xcodeproj -scheme "Cache-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' clean
14-
- run: xcodebuild -project Cache.xcodeproj -scheme "Cache-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=12.0' -enableCodeCoverage YES test
12+
- run: xcodebuild -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.1,name=iPhone 11 Pro' -enableCodeCoverage YES test
13+
- run: xcodebuild -project Cache.xcodeproj -scheme "Cache-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=13.0' clean
14+
- run: xcodebuild -project Cache.xcodeproj -scheme "Cache-tvOS" -destination 'platform=tvOS Simulator,name=Apple TV,OS=13.0' -enableCodeCoverage YES test
1515

1616
workflows:
1717
version: 2

Cache.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ Pod::Spec.new do |s|
1919

2020
s.frameworks = 'Foundation'
2121

22-
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' }
22+
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' }
23+
s.swift_version = '5.0'
2324
end

Cache.xcodeproj/project.pbxproj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
D270148B20D113EA003B45C7 /* Optional+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+Extension.swift"; sourceTree = "<group>"; };
190190
D270148F20D1251E003B45C7 /* TypeWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypeWrapper.swift; sourceTree = "<group>"; };
191191
D270149320D125AC003B45C7 /* MemoryCapsule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryCapsule.swift; sourceTree = "<group>"; };
192-
D27014A420D129EB003B45C7 /* TransformerFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransformerFactory.swift; sourceTree = "<group>"; };
192+
D27014A420D129EB003B45C7 /* TransformerFactory.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = TransformerFactory.swift; sourceTree = "<group>"; tabWidth = 4; };
193193
D285143E1F6FFE1F00C674D1 /* ObjectConverterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObjectConverterTests.swift; sourceTree = "<group>"; };
194194
D28897041F8B79B300C61DEE /* JSONDecoder+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "JSONDecoder+Extensions.swift"; sourceTree = "<group>"; };
195195
D292DAFC1F6A970B0060F614 /* Result.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; };
@@ -667,7 +667,7 @@
667667
isa = PBXProject;
668668
attributes = {
669669
LastSwiftUpdateCheck = 0800;
670-
LastUpgradeCheck = 0930;
670+
LastUpgradeCheck = 1030;
671671
ORGANIZATIONNAME = "Hyper Interaktiv AS";
672672
TargetAttributes = {
673673
BDEDD3551DBCE5B1007416A6 = {
@@ -697,10 +697,11 @@
697697
};
698698
buildConfigurationList = D5DC59DA1C20593E003BD79B /* Build configuration list for PBXProject "Cache" */;
699699
compatibilityVersion = "Xcode 3.2";
700-
developmentRegion = English;
700+
developmentRegion = en;
701701
hasScannedForEncodings = 0;
702702
knownRegions = (
703703
en,
704+
Base,
704705
);
705706
mainGroup = D5DC59D61C20593E003BD79B;
706707
productRefGroup = D5DC59E11C20593E003BD79B /* Products */;
@@ -1170,6 +1171,7 @@
11701171
isa = XCBuildConfiguration;
11711172
buildSettings = {
11721173
ALWAYS_SEARCH_USER_PATHS = NO;
1174+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
11731175
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
11741176
CLANG_CXX_LIBRARY = "libc++";
11751177
CLANG_ENABLE_MODULES = YES;
@@ -1218,7 +1220,7 @@
12181220
ONLY_ACTIVE_ARCH = YES;
12191221
SDKROOT = iphoneos;
12201222
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1221-
SWIFT_VERSION = 4.2;
1223+
SWIFT_VERSION = 5.0;
12221224
TARGETED_DEVICE_FAMILY = "1,2";
12231225
VERSIONING_SYSTEM = "apple-generic";
12241226
VERSION_INFO_PREFIX = "";
@@ -1229,6 +1231,7 @@
12291231
isa = XCBuildConfiguration;
12301232
buildSettings = {
12311233
ALWAYS_SEARCH_USER_PATHS = NO;
1234+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
12321235
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
12331236
CLANG_CXX_LIBRARY = "libc++";
12341237
CLANG_ENABLE_MODULES = YES;
@@ -1270,7 +1273,7 @@
12701273
MTL_ENABLE_DEBUG_INFO = NO;
12711274
SDKROOT = iphoneos;
12721275
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1273-
SWIFT_VERSION = 4.2;
1276+
SWIFT_VERSION = 5.0;
12741277
TARGETED_DEVICE_FAMILY = "1,2";
12751278
VALIDATE_PRODUCT = YES;
12761279
VERSIONING_SYSTEM = "apple-generic";

Cache.xcodeproj/xcshareddata/xcschemes/Cache-iOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0930"
3+
LastUpgradeVersion = "1030"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Cache.xcodeproj/xcshareddata/xcschemes/Cache-macOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0930"
3+
LastUpgradeVersion = "1030"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Cache.xcodeproj/xcshareddata/xcschemes/Cache-tvOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0930"
3+
LastUpgradeVersion = "1030"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Package.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.1
22

33
import PackageDescription
44

@@ -13,11 +13,12 @@ let package = Package(
1313
targets: [
1414
.target(
1515
name: "Cache",
16-
path: "Source/Shared",
17-
exclude: ["Library/ImageWrapper.swift"]), // relative to the target path
16+
path: "Source",
17+
exclude: ["Library/ImageWrapper.swift"]),
1818
.testTarget(
1919
name: "CacheTests",
2020
dependencies: ["Cache"],
2121
path: "Tests"),
22-
]
22+
],
23+
swiftLanguageVersions: [.v5]
2324
)

Source/Mac/NSImage+Extensions.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(AppKit)
12
import AppKit
23

34
/// Helper UIImage extension.
@@ -34,3 +35,5 @@ extension NSImage {
3435
.representation(using: imageFileType, properties: [:])
3536
}
3637
}
38+
39+
#endif

Source/iOS/UIImage+Extensions.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(UIKit)
12
import UIKit
23

34
/// Helper UIImage extension.
@@ -22,14 +23,9 @@ extension UIImage {
2223

2324
/// Convert to data
2425
func cache_toData() -> Data? {
25-
#if swift(>=4.2)
2626
return hasAlpha
2727
? pngData()
2828
: jpegData(compressionQuality: 1.0)
29-
#else
30-
return hasAlpha
31-
? UIImagePNGRepresentation(self)
32-
: UIImageJPEGRepresentation(self, 1.0)
33-
#endif
3429
}
3530
}
31+
#endif

Tests/Shared/TestHelper.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ import AppKit
99
struct TestHelper {
1010
static func data(_ length : Int) -> Data {
1111
let buffer = [UInt8](repeating: 0, count: length)
12-
return Data(bytes: buffer)
12+
return Data(buffer)
1313
}
1414

1515
static func triggerApplicationEvents() {
1616
#if (iOS)
1717
NotificationCenter.default.post(name: UIApplication.didEnterBackgroundNotification, object: nil)
1818
NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil)
1919
#elseif os(tvOS)
20-
NotificationCenter.default.post(name: Notification.Name.UIApplicationDidEnterBackground, object: nil)
21-
NotificationCenter.default.post(name: Notification.Name.UIApplicationWillTerminate, object: nil)
20+
NotificationCenter.default.post(name: UIApplication.didEnterBackgroundNotification, object: nil)
21+
NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil)
2222
#else
23-
NotificationCenter.default.post(name: NSApplication.willTerminateNotification, object: nil)
24-
NotificationCenter.default.post(name: NSApplication.didResignActiveNotification, object: nil)
23+
NotificationCenter.default.post(name: NSApplication.willTerminateNotification, object: nil)
24+
NotificationCenter.default.post(name: NSApplication.didResignActiveNotification, object: nil)
2525
#endif
2626
}
2727
}

0 commit comments

Comments
 (0)