Skip to content

Commit a6f50aa

Browse files
Add some tests to check simulator and ipad.
1 parent 1e9ff2f commit a6f50aa

5 files changed

Lines changed: 205 additions & 5 deletions

File tree

DeviceIdentificator.xcodeproj/project.pbxproj

Lines changed: 129 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,41 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
E2566523212614270061CCF7 /* DeviceIdentificatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2566522212614270061CCF7 /* DeviceIdentificatorTests.swift */; };
11+
E2566525212614270061CCF7 /* DeviceIdentificator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2A364F6200D104900668DF9 /* DeviceIdentificator.framework */; };
1012
E2A36507200D104900668DF9 /* DeviceIdentificator.h in Headers */ = {isa = PBXBuildFile; fileRef = E2A364F9200D104900668DF9 /* DeviceIdentificator.h */; settings = {ATTRIBUTES = (Public, ); }; };
1113
E2A36511200D10DA00668DF9 /* UIDeviceExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2A36510200D10DA00668DF9 /* UIDeviceExtensions.swift */; };
1214
/* End PBXBuildFile section */
1315

16+
/* Begin PBXContainerItemProxy section */
17+
E2566526212614270061CCF7 /* PBXContainerItemProxy */ = {
18+
isa = PBXContainerItemProxy;
19+
containerPortal = E2A364ED200D104900668DF9 /* Project object */;
20+
proxyType = 1;
21+
remoteGlobalIDString = E2A364F5200D104900668DF9;
22+
remoteInfo = DeviceIdentificator;
23+
};
24+
/* End PBXContainerItemProxy section */
25+
1426
/* Begin PBXFileReference section */
27+
E2566520212614270061CCF7 /* DeviceIdentificatorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DeviceIdentificatorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
28+
E2566522212614270061CCF7 /* DeviceIdentificatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceIdentificatorTests.swift; sourceTree = "<group>"; };
29+
E2566524212614270061CCF7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1530
E2A364F6200D104900668DF9 /* DeviceIdentificator.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DeviceIdentificator.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1631
E2A364F9200D104900668DF9 /* DeviceIdentificator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeviceIdentificator.h; sourceTree = "<group>"; };
1732
E2A364FA200D104900668DF9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1833
E2A36510200D10DA00668DF9 /* UIDeviceExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIDeviceExtensions.swift; sourceTree = "<group>"; };
1934
/* End PBXFileReference section */
2035

2136
/* Begin PBXFrameworksBuildPhase section */
37+
E256651D212614270061CCF7 /* Frameworks */ = {
38+
isa = PBXFrameworksBuildPhase;
39+
buildActionMask = 2147483647;
40+
files = (
41+
E2566525212614270061CCF7 /* DeviceIdentificator.framework in Frameworks */,
42+
);
43+
runOnlyForDeploymentPostprocessing = 0;
44+
};
2245
E2A364F2200D104900668DF9 /* Frameworks */ = {
2346
isa = PBXFrameworksBuildPhase;
2447
buildActionMask = 2147483647;
@@ -29,10 +52,20 @@
2952
/* End PBXFrameworksBuildPhase section */
3053

3154
/* Begin PBXGroup section */
55+
E2566521212614270061CCF7 /* Tests */ = {
56+
isa = PBXGroup;
57+
children = (
58+
E2566522212614270061CCF7 /* DeviceIdentificatorTests.swift */,
59+
E2566524212614270061CCF7 /* Info.plist */,
60+
);
61+
path = Tests;
62+
sourceTree = "<group>";
63+
};
3264
E2A364EC200D104900668DF9 = {
3365
isa = PBXGroup;
3466
children = (
3567
E2A364F8200D104900668DF9 /* Source */,
68+
E2566521212614270061CCF7 /* Tests */,
3669
E2A364F7200D104900668DF9 /* Products */,
3770
);
3871
sourceTree = "<group>";
@@ -41,6 +74,7 @@
4174
isa = PBXGroup;
4275
children = (
4376
E2A364F6200D104900668DF9 /* DeviceIdentificator.framework */,
77+
E2566520212614270061CCF7 /* DeviceIdentificatorTests.xctest */,
4478
);
4579
name = Products;
4680
sourceTree = "<group>";
@@ -69,6 +103,24 @@
69103
/* End PBXHeadersBuildPhase section */
70104

71105
/* Begin PBXNativeTarget section */
106+
E256651F212614270061CCF7 /* DeviceIdentificatorTests */ = {
107+
isa = PBXNativeTarget;
108+
buildConfigurationList = E256652A212614270061CCF7 /* Build configuration list for PBXNativeTarget "DeviceIdentificatorTests" */;
109+
buildPhases = (
110+
E256651C212614270061CCF7 /* Sources */,
111+
E256651D212614270061CCF7 /* Frameworks */,
112+
E256651E212614270061CCF7 /* Resources */,
113+
);
114+
buildRules = (
115+
);
116+
dependencies = (
117+
E2566527212614270061CCF7 /* PBXTargetDependency */,
118+
);
119+
name = DeviceIdentificatorTests;
120+
productName = DeviceIdentificatorTests;
121+
productReference = E2566520212614270061CCF7 /* DeviceIdentificatorTests.xctest */;
122+
productType = "com.apple.product-type.bundle.unit-test";
123+
};
72124
E2A364F5200D104900668DF9 /* DeviceIdentificator */ = {
73125
isa = PBXNativeTarget;
74126
buildConfigurationList = E2A3650A200D104900668DF9 /* Build configuration list for PBXNativeTarget "DeviceIdentificator" */;
@@ -93,10 +145,14 @@
93145
E2A364ED200D104900668DF9 /* Project object */ = {
94146
isa = PBXProject;
95147
attributes = {
96-
LastSwiftUpdateCheck = 0920;
97-
LastUpgradeCheck = 0920;
148+
LastSwiftUpdateCheck = 0940;
149+
LastUpgradeCheck = 0940;
98150
ORGANIZATIONNAME = "Sebastián Varela";
99151
TargetAttributes = {
152+
E256651F212614270061CCF7 = {
153+
CreatedOnToolsVersion = 9.4.1;
154+
ProvisioningStyle = Automatic;
155+
};
100156
E2A364F5200D104900668DF9 = {
101157
CreatedOnToolsVersion = 9.2;
102158
LastSwiftMigration = 0920;
@@ -117,11 +173,19 @@
117173
projectRoot = "";
118174
targets = (
119175
E2A364F5200D104900668DF9 /* DeviceIdentificator */,
176+
E256651F212614270061CCF7 /* DeviceIdentificatorTests */,
120177
);
121178
};
122179
/* End PBXProject section */
123180

124181
/* Begin PBXResourcesBuildPhase section */
182+
E256651E212614270061CCF7 /* Resources */ = {
183+
isa = PBXResourcesBuildPhase;
184+
buildActionMask = 2147483647;
185+
files = (
186+
);
187+
runOnlyForDeploymentPostprocessing = 0;
188+
};
125189
E2A364F4200D104900668DF9 /* Resources */ = {
126190
isa = PBXResourcesBuildPhase;
127191
buildActionMask = 2147483647;
@@ -132,6 +196,14 @@
132196
/* End PBXResourcesBuildPhase section */
133197

134198
/* Begin PBXSourcesBuildPhase section */
199+
E256651C212614270061CCF7 /* Sources */ = {
200+
isa = PBXSourcesBuildPhase;
201+
buildActionMask = 2147483647;
202+
files = (
203+
E2566523212614270061CCF7 /* DeviceIdentificatorTests.swift in Sources */,
204+
);
205+
runOnlyForDeploymentPostprocessing = 0;
206+
};
135207
E2A364F1200D104900668DF9 /* Sources */ = {
136208
isa = PBXSourcesBuildPhase;
137209
buildActionMask = 2147483647;
@@ -142,7 +214,49 @@
142214
};
143215
/* End PBXSourcesBuildPhase section */
144216

217+
/* Begin PBXTargetDependency section */
218+
E2566527212614270061CCF7 /* PBXTargetDependency */ = {
219+
isa = PBXTargetDependency;
220+
target = E2A364F5200D104900668DF9 /* DeviceIdentificator */;
221+
targetProxy = E2566526212614270061CCF7 /* PBXContainerItemProxy */;
222+
};
223+
/* End PBXTargetDependency section */
224+
145225
/* Begin XCBuildConfiguration section */
226+
E2566528212614270061CCF7 /* Debug */ = {
227+
isa = XCBuildConfiguration;
228+
buildSettings = {
229+
CLANG_ENABLE_OBJC_WEAK = YES;
230+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
231+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
232+
CODE_SIGN_STYLE = Automatic;
233+
INFOPLIST_FILE = Tests/Info.plist;
234+
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
235+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
236+
PRODUCT_BUNDLE_IDENTIFIER = net.s3ba.DeviceIdentificatorTests;
237+
PRODUCT_NAME = "$(TARGET_NAME)";
238+
SWIFT_VERSION = 4.0;
239+
TARGETED_DEVICE_FAMILY = "1,2";
240+
};
241+
name = Debug;
242+
};
243+
E2566529212614270061CCF7 /* Release */ = {
244+
isa = XCBuildConfiguration;
245+
buildSettings = {
246+
CLANG_ENABLE_OBJC_WEAK = YES;
247+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
248+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
249+
CODE_SIGN_STYLE = Automatic;
250+
INFOPLIST_FILE = Tests/Info.plist;
251+
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
252+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
253+
PRODUCT_BUNDLE_IDENTIFIER = net.s3ba.DeviceIdentificatorTests;
254+
PRODUCT_NAME = "$(TARGET_NAME)";
255+
SWIFT_VERSION = 4.0;
256+
TARGETED_DEVICE_FAMILY = "1,2";
257+
};
258+
name = Release;
259+
};
146260
E2A36508200D104900668DF9 /* Debug */ = {
147261
isa = XCBuildConfiguration;
148262
buildSettings = {
@@ -157,13 +271,15 @@
157271
CLANG_WARN_BOOL_CONVERSION = YES;
158272
CLANG_WARN_COMMA = YES;
159273
CLANG_WARN_CONSTANT_CONVERSION = YES;
274+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
160275
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
161276
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
162277
CLANG_WARN_EMPTY_BODY = YES;
163278
CLANG_WARN_ENUM_CONVERSION = YES;
164279
CLANG_WARN_INFINITE_RECURSION = YES;
165280
CLANG_WARN_INT_CONVERSION = YES;
166281
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
282+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
167283
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
168284
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
169285
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -217,13 +333,15 @@
217333
CLANG_WARN_BOOL_CONVERSION = YES;
218334
CLANG_WARN_COMMA = YES;
219335
CLANG_WARN_CONSTANT_CONVERSION = YES;
336+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
220337
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
221338
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
222339
CLANG_WARN_EMPTY_BODY = YES;
223340
CLANG_WARN_ENUM_CONVERSION = YES;
224341
CLANG_WARN_INFINITE_RECURSION = YES;
225342
CLANG_WARN_INT_CONVERSION = YES;
226343
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
344+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
227345
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
228346
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
229347
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -302,6 +420,15 @@
302420
/* End XCBuildConfiguration section */
303421

304422
/* Begin XCConfigurationList section */
423+
E256652A212614270061CCF7 /* Build configuration list for PBXNativeTarget "DeviceIdentificatorTests" */ = {
424+
isa = XCConfigurationList;
425+
buildConfigurations = (
426+
E2566528212614270061CCF7 /* Debug */,
427+
E2566529212614270061CCF7 /* Release */,
428+
);
429+
defaultConfigurationIsVisible = 0;
430+
defaultConfigurationName = Release;
431+
};
305432
E2A364F0200D104900668DF9 /* Build configuration list for PBXProject "DeviceIdentificator" */ = {
306433
isa = XCConfigurationList;
307434
buildConfigurations = (
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

DeviceIdentificator.xcodeproj/xcshareddata/xcschemes/DeviceIdentificator.xcscheme

Lines changed: 21 additions & 3 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 = "0920"
3+
LastUpgradeVersion = "0940"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,18 +26,36 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
language = ""
29+
codeCoverageEnabled = "YES"
3030
shouldUseLaunchSchemeArgsEnv = "YES">
3131
<Testables>
32+
<TestableReference
33+
skipped = "NO">
34+
<BuildableReference
35+
BuildableIdentifier = "primary"
36+
BlueprintIdentifier = "E256651F212614270061CCF7"
37+
BuildableName = "DeviceIdentificatorTests.xctest"
38+
BlueprintName = "DeviceIdentificatorTests"
39+
ReferencedContainer = "container:DeviceIdentificator.xcodeproj">
40+
</BuildableReference>
41+
</TestableReference>
3242
</Testables>
43+
<MacroExpansion>
44+
<BuildableReference
45+
BuildableIdentifier = "primary"
46+
BlueprintIdentifier = "E2A364F5200D104900668DF9"
47+
BuildableName = "DeviceIdentificator.framework"
48+
BlueprintName = "DeviceIdentificator"
49+
ReferencedContainer = "container:DeviceIdentificator.xcodeproj">
50+
</BuildableReference>
51+
</MacroExpansion>
3352
<AdditionalOptions>
3453
</AdditionalOptions>
3554
</TestAction>
3655
<LaunchAction
3756
buildConfiguration = "Debug"
3857
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3958
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40-
language = ""
4159
launchStyle = "0"
4260
useCustomWorkingDirectory = "NO"
4361
ignoresPersistentStateOnLaunch = "NO"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@testable import DeviceIdentificator
2+
import XCTest
3+
4+
class DeviceIdentificatorTests: XCTestCase {
5+
6+
func testIsSimulator() {
7+
#if targetEnvironment(simulator)
8+
XCTAssertTrue(UIDevice.current.isSimulator)
9+
XCTAssertTrue(UIDevice.current.deviceModelName.lowercased.contains("simulator"))
10+
#else
11+
XCTAssertFalse(UIDevice.current.isSimulator)
12+
#endif
13+
}
14+
15+
func testIsIpad() {
16+
switch UI_USER_INTERFACE_IDIOM() {
17+
case .pad:
18+
XCTAssertTrue(UIDevice.current.isIpad)
19+
case .phone:
20+
XCTAssertFalse(UIDevice.current.isIpad)
21+
default:
22+
XCTFail("not supported yet")
23+
}
24+
}
25+
}

Tests/Info.plist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>BNDL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
</dict>
22+
</plist>

0 commit comments

Comments
 (0)