Skip to content

Commit 57418a0

Browse files
authored
Update for Swift 5.0 (MobileNativeFoundation#55)
* Update for Swift 5.0
1 parent fd57b4f commit 57418a0

File tree

6 files changed

+50
-23
lines changed

6 files changed

+50
-23
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ matrix:
1010
env: ACTION=tvOS
1111

1212
language: objective-c
13-
osx_image: xcode10
13+
osx_image: xcode10.2
1414

1515
script:
1616
- make install-$ACTION && make test-$ACTION

Kronos.xcodeproj/project.pbxproj

+31-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 47;
6+
objectVersion = 51;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -193,19 +193,20 @@
193193
TargetAttributes = {
194194
C20174821BD5509D00E4FE18 = {
195195
CreatedOnToolsVersion = 7.0;
196-
LastSwiftMigration = 1000;
196+
LastSwiftMigration = 1020;
197197
};
198198
C201748C1BD5509D00E4FE18 = {
199199
CreatedOnToolsVersion = 7.0;
200-
LastSwiftMigration = 1000;
200+
LastSwiftMigration = 1020;
201201
};
202202
};
203203
};
204204
buildConfigurationList = C201747D1BD5509D00E4FE18 /* Build configuration list for PBXProject "Kronos" */;
205-
compatibilityVersion = "Xcode 6.3";
205+
compatibilityVersion = "Xcode 10.0";
206206
developmentRegion = English;
207207
hasScannedForEncodings = 0;
208208
knownRegions = (
209+
English,
209210
en,
210211
);
211212
mainGroup = C20174791BD5509D00E4FE18;
@@ -354,7 +355,8 @@
354355
GCC_WARN_UNUSED_VARIABLE = YES;
355356
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
356357
MTL_ENABLE_DEBUG_INFO = NO;
357-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
358+
SWIFT_COMPILATION_MODE = wholemodule;
359+
SWIFT_OPTIMIZATION_LEVEL = "-O";
358360
TARGETED_DEVICE_FAMILY = "1,2";
359361
VALIDATE_PRODUCT = YES;
360362
VERSIONING_SYSTEM = "apple-generic";
@@ -376,12 +378,16 @@
376378
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
377379
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
378380
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
379-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
381+
LD_RUNPATH_SEARCH_PATHS = (
382+
"$(inherited)",
383+
"@executable_path/Frameworks",
384+
"@loader_path/Frameworks",
385+
);
380386
PRODUCT_BUNDLE_IDENTIFIER = com.Lyft.Kronos;
381387
PRODUCT_NAME = Kronos;
382388
SKIP_INSTALL = YES;
383389
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
384-
SWIFT_VERSION = 4.2;
390+
SWIFT_VERSION = 5.0;
385391
TVOS_DEPLOYMENT_TARGET = 9.0;
386392
};
387393
name = Debug;
@@ -400,11 +406,15 @@
400406
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
401407
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
402408
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
403-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
409+
LD_RUNPATH_SEARCH_PATHS = (
410+
"$(inherited)",
411+
"@executable_path/Frameworks",
412+
"@loader_path/Frameworks",
413+
);
404414
PRODUCT_BUNDLE_IDENTIFIER = com.Lyft.Kronos;
405415
PRODUCT_NAME = Kronos;
406416
SKIP_INSTALL = YES;
407-
SWIFT_VERSION = 4.2;
417+
SWIFT_VERSION = 5.0;
408418
TVOS_DEPLOYMENT_TARGET = 9.0;
409419
};
410420
name = Release;
@@ -415,11 +425,15 @@
415425
buildSettings = {
416426
CLANG_ENABLE_MODULES = YES;
417427
COMBINE_HIDPI_IMAGES = YES;
418-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
428+
LD_RUNPATH_SEARCH_PATHS = (
429+
"$(inherited)",
430+
"@executable_path/Frameworks",
431+
"@loader_path/Frameworks",
432+
);
419433
PRODUCT_BUNDLE_IDENTIFIER = com.Lyft.KronosTests;
420434
PRODUCT_NAME = "$(TARGET_NAME)";
421435
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
422-
SWIFT_VERSION = 4.2;
436+
SWIFT_VERSION = 5.0;
423437
};
424438
name = Debug;
425439
};
@@ -429,10 +443,14 @@
429443
buildSettings = {
430444
CLANG_ENABLE_MODULES = YES;
431445
COMBINE_HIDPI_IMAGES = YES;
432-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
446+
LD_RUNPATH_SEARCH_PATHS = (
447+
"$(inherited)",
448+
"@executable_path/Frameworks",
449+
"@loader_path/Frameworks",
450+
);
433451
PRODUCT_BUNDLE_IDENTIFIER = com.Lyft.KronosTests;
434452
PRODUCT_NAME = "$(TARGET_NAME)";
435-
SWIFT_VERSION = 4.2;
453+
SWIFT_VERSION = 5.0;
436454
};
437455
name = Release;
438456
};

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ test-tvOS:
4040
xcodebuild \
4141
-project Kronos.xcodeproj \
4242
-scheme Kronos \
43-
-destination "platform=tvOS Simulator,name=Apple TV,OS=12.0" \
43+
-destination "platform=tvOS Simulator,name=Apple TV,OS=12.2" \
4444
test \
4545
| xcpretty -ct

Package.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.0
22
import PackageDescription
33

44
let package = Package(
@@ -9,6 +9,5 @@ let package = Package(
99
targets: [
1010
.target(name: "Kronos", path: "Sources"),
1111
.testTarget(name: "KronosTests", dependencies: ["Kronos"]),
12-
],
13-
swiftLanguageVersions: [.v4, .v4_2]
12+
]
1413
)

Sources/DNSResolver.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ final class DNSResolver {
3838
let IPs = (addresses.takeUnretainedValue() as NSArray)
3939
.compactMap { $0 as? Data }
4040
.compactMap { data -> InternetAddress? in
41-
return data.withUnsafeBytes { (pointer: UnsafePointer<sockaddr_storage>) in
42-
return InternetAddress(storage: pointer)
41+
return data.withUnsafeBytes { rawPointer in
42+
let pointer = rawPointer.bindMemory(to: sockaddr_storage.self).baseAddress
43+
return InternetAddress(storage: pointer!)
4344
}
4445
}
4546

Sources/Data+Bytes.swift

+12-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ extension Data {
3030
///
3131
/// - returns: The byte located at position `index`.
3232
func getByte(at index: Int) -> Int8 {
33-
let data: Int8 = self.subdata(in: index ..< (index + 1)).withUnsafeBytes { $0.pointee }
33+
let data: Int8 = self.subdata(in: index ..< (index + 1)).withUnsafeBytes { rawPointer in
34+
rawPointer.bindMemory(to: Int8.self).baseAddress!.pointee
35+
}
36+
3437
return data
3538
}
3639

@@ -41,7 +44,10 @@ extension Data {
4144
///
4245
/// - returns: The unsigned int located at position `index`.
4346
func getUnsignedInteger(at index: Int, bigEndian: Bool = true) -> UInt32 {
44-
let data: UInt32 = self.subdata(in: index ..< (index + 4)).withUnsafeBytes { $0.pointee }
47+
let data: UInt32 = self.subdata(in: index ..< (index + 4)).withUnsafeBytes { rawPointer in
48+
rawPointer.bindMemory(to: UInt32.self).baseAddress!.pointee
49+
}
50+
4551
return bigEndian ? data.bigEndian : data.littleEndian
4652
}
4753

@@ -52,7 +58,10 @@ extension Data {
5258
///
5359
/// - returns: The unsigned long integer located at position `index`.
5460
func getUnsignedLong(at index: Int, bigEndian: Bool = true) -> UInt64 {
55-
let data: UInt64 = self.subdata(in: index ..< (index + 8)).withUnsafeBytes { $0.pointee }
61+
let data: UInt64 = self.subdata(in: index ..< (index + 8)).withUnsafeBytes { rawPointer in
62+
rawPointer.bindMemory(to: UInt64.self).baseAddress!.pointee
63+
}
64+
5665
return bigEndian ? data.bigEndian : data.littleEndian
5766
}
5867

0 commit comments

Comments
 (0)