Skip to content

Commit f0cf55b

Browse files
authored
Update project to more modern swift
2 parents ff17691 + 2ca4fba commit f0cf55b

File tree

49 files changed

+177
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+177
-179
lines changed

ProfileKit/.swiftlint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ disabled_rules:
2222
#- empty_parameters
2323
#- empty_parentheses_with_trailing_closure
2424
#- fallthrough
25-
#- file_length
25+
- file_length
2626
#- for_where
2727
- force_cast
2828
#- force_try
@@ -133,7 +133,7 @@ file_header: # Correct syntax for the file headers
133133
required_pattern: |
134134
\/\/
135135
\/\/ .*?\.swift
136-
\/\/ Profiles
136+
\/\/ ProfileKit
137137
\/\/
138138
\/\/ Created by .[A-Za-z -]*?\.
139139
\/\/ Copyright © \d{4} .[A-Za-z -]*?\. All rights reserved\.

ProfileKit/ProfileKit.xcodeproj/project.pbxproj

Lines changed: 72 additions & 61 deletions
Large diffs are not rendered by default.

ProfileKit/ProfileKit.xcodeproj/xcshareddata/xcschemes/ProfileKit.xcscheme

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1020"
3+
LastUpgradeVersion = "1500"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -29,8 +29,6 @@
2929
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
3131
</Testables>
32-
<AdditionalOptions>
33-
</AdditionalOptions>
3432
</TestAction>
3533
<LaunchAction
3634
buildConfiguration = "Debug"
@@ -51,8 +49,6 @@
5149
ReferencedContainer = "container:ProfileKit.xcodeproj">
5250
</BuildableReference>
5351
</MacroExpansion>
54-
<AdditionalOptions>
55-
</AdditionalOptions>
5652
</LaunchAction>
5753
<ProfileAction
5854
buildConfiguration = "Release"

ProfileKit/ProfileKit/Extensions/Data.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Data.swift
3-
// Profiles
3+
// ProfileKit
44
//
55
// Created by Erik Berglund.
66
// Copyright © 2019 Erik Berglund. All rights reserved.
@@ -11,18 +11,18 @@ import Foundation
1111
extension Data {
1212

1313
// Modified version from https://stackoverflow.com/a/26503955
14-
init(withHexString hexString: String) {
15-
self.init()
16-
var hex = hexString
17-
while !hex.isEmpty {
18-
let subIndex = hex.index(hex.startIndex, offsetBy: 2)
19-
let c = String(hex[..<subIndex])
20-
hex = String(hex[subIndex...])
21-
var ch: UInt32 = 0
22-
Scanner(string: c).scanHexInt32(&ch)
23-
var char = UInt8(ch)
24-
self.append(&char, count: 1)
14+
init?(withHexString hexString: String) {
15+
guard hexString.count.isMultiple(of: 2) else {
16+
return nil
2517
}
18+
19+
let chars = Array(hexString)
20+
let bytes = stride(from: 0, to: chars.count, by: 2)
21+
.map { String(chars[$0]) + String(chars[$0 + 1]) }
22+
.compactMap { UInt8($0, radix: 16) }
23+
24+
guard hexString.count / bytes.count == 2 else { return nil }
25+
self.init(bytes)
2626
}
2727

2828
func plist() throws -> [String: Any] {

ProfileKit/ProfileKit/Extensions/Dictionary.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Dictionary.swift
3-
// Profiles
3+
// ProfileKit
44
//
55
// Created by Erik Berglund.
66
// Copyright © 2019 Erik Berglund. All rights reserved.

ProfileKit/ProfileKit/Extensions/FileManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// FileManager.swift
33
// ProfileKit
44
//
5-
// Created by Erik Berglund on 2019-06-17.
5+
// Created by Erik Berglund.
66
// Copyright © 2019 Erik Berglund. All rights reserved.
77
//
88

ProfileKit/ProfileKit/Extensions/KeyedDecodingContainerProtocol.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// KeyedDecodingContainerProtocol.swift
3-
// Profiles
3+
// ProfileKit
44
//
55
// Created by Erik Berglund.
66
// Copyright © 2019 Erik Berglund. All rights reserved.
@@ -88,11 +88,9 @@ public extension KeyedDecodingContainerProtocol {
8888
func decodeMap<T>(_ type: T.Type, excludedKeys: Set<Self.Key>) throws -> [Self.Key: T] where T: Decodable {
8989
var map: [Self.Key: T] = [:]
9090

91-
for key in allKeys {
92-
if !excludedKeys.contains(key) {
93-
let value = try decode(T.self, forKey: key)
94-
map[key] = value
95-
}
91+
for key in allKeys where !excludedKeys.contains(key) {
92+
let value = try decode(T.self, forKey: key)
93+
map[key] = value
9694
}
9795

9896
return map

ProfileKit/ProfileKit/Extensions/KeyedEncodingContainerProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// KeyedEncodingContainerProtocol.swift
33
// ProfileKit
44
//
5-
// Created by Erik Berglund on 2019-06-12.
5+
// Created by Erik Berglund.
66
// Copyright © 2019 Erik Berglund. All rights reserved.
77
//
88

ProfileKit/ProfileKit/Extensions/Manifest.Category.swift renamed to ProfileKit/ProfileKit/Extensions/Manifest+Category.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
2-
// Manifest.Category.swift
2+
// Manifest+Category.swift
33
// ProfileKit
44
//
5-
// Created by Erik Berglund on 2019-06-14.
5+
// Created by Erik Berglund.
66
// Copyright © 2019 Erik Berglund. All rights reserved.
77
//
88

ProfileKit/ProfileKit/Extensions/Manifest.Interaction.swift renamed to ProfileKit/ProfileKit/Extensions/Manifest+Interaction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
2-
// Manifest.Interaction.swift
2+
// Manifest+Interaction.swift
33
// ProfileKit
44
//
5-
// Created by Erik Berglund on 2019-06-14.
5+
// Created by Erik Berglund.
66
// Copyright © 2019 Erik Berglund. All rights reserved.
77
//
88

0 commit comments

Comments
 (0)