Skip to content

Commit 1f85ad7

Browse files
Add swiftlint and solve first warnings
1 parent 24db8b9 commit 1f85ad7

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

DeviceIdentificator.xcodeproj/project.pbxproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
isa = PBXNativeTarget;
126126
buildConfigurationList = E2A3650A200D104900668DF9 /* Build configuration list for PBXNativeTarget "DeviceIdentificator" */;
127127
buildPhases = (
128+
E20BA6072138AFCB005BA13B /* Swiftlint */,
128129
E2A364F1200D104900668DF9 /* Sources */,
129130
E2A364F2200D104900668DF9 /* Frameworks */,
130131
E2A364F3200D104900668DF9 /* Headers */,
@@ -195,6 +196,23 @@
195196
};
196197
/* End PBXResourcesBuildPhase section */
197198

199+
/* Begin PBXShellScriptBuildPhase section */
200+
E20BA6072138AFCB005BA13B /* Swiftlint */ = {
201+
isa = PBXShellScriptBuildPhase;
202+
buildActionMask = 2147483647;
203+
files = (
204+
);
205+
inputPaths = (
206+
);
207+
name = Swiftlint;
208+
outputPaths = (
209+
);
210+
runOnlyForDeploymentPostprocessing = 0;
211+
shellPath = /bin/sh;
212+
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, run: brew install swiftlint\"\nfi";
213+
};
214+
/* End PBXShellScriptBuildPhase section */
215+
198216
/* Begin PBXSourcesBuildPhase section */
199217
E256651C212614270061CCF7 /* Sources */ = {
200218
isa = PBXSourcesBuildPhase;

Source/UIDeviceExtensions.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public extension UIDevice {
1818

1919
return parseDeviceModel(identifier)
2020
}
21-
21+
2222
@objc
2323
var deviceModelName: NSString {
2424
return deviceModel.name as NSString
2525
}
26-
26+
2727
@objc
2828
var isSimulator: Bool {
2929
switch deviceModel {
@@ -33,7 +33,7 @@ public extension UIDevice {
3333
return false
3434
}
3535
}
36-
36+
3737
@objc
3838
public var isIpad: Bool {
3939
return deviceModel.name.contains("iPad")
@@ -136,15 +136,15 @@ public enum DeviceModel {
136136
case .iPadSimulator: return "iPad Simulator"
137137
case .iPhoneSimulator: return "iPhone Simulator"
138138

139-
case .iPhoneUnknown(let id): return "Unknown iPhone (\(id))"
140-
case .iPadUnknown(let id): return "Unknown iPad (\(id))"
141-
case .iPodUnknown(let id): return "Unknown iPod (\(id))"
142-
case .unknown(let id): return "Unknown iOS device (\(id))"
139+
case .iPhoneUnknown(let model): return "Unknown iPhone (\(model))"
140+
case .iPadUnknown(let model): return "Unknown iPad (\(model))"
141+
case .iPodUnknown(let model): return "Unknown iPod (\(model))"
142+
case .unknown(let model): return "Unknown iOS device (\(model))"
143143
}
144144
}
145145
}
146146

147-
fileprivate func parseDeviceModel(_ identifier: String) -> DeviceModel {
147+
private func parseDeviceModel(_ identifier: String) -> DeviceModel {
148148

149149
if identifier == "i386" || identifier == "x86_64" {
150150
let smallerScreen = UIScreen.main.bounds.size.width < 768

Tests/DeviceIdentificatorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class DeviceIdentificatorTests: XCTestCase {
1111
XCTAssertFalse(UIDevice.current.isSimulator)
1212
#endif
1313
}
14-
14+
1515
func testIsIpad() {
1616
switch UI_USER_INTERFACE_IDIOM() {
1717
case .pad:

0 commit comments

Comments
 (0)