Skip to content

Commit 04ee20c

Browse files
authored
Merge pull request #1 from arasu01/swift5
swift 5.
2 parents 64fc636 + 74baebb commit 04ee20c

7 files changed

Lines changed: 233 additions & 25 deletions

File tree

ATAlertController/ATAlertController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import UIKit
1313
///Use Alert or ActionSheet instead
1414
public class ATAlertController {
1515
///UIAlertActions callback
16-
public typealias actionHandler = (UIAlertAction!) -> Void
16+
public typealias actionHandler = (UIAlertAction?) -> Void
1717

1818
///Internal alert controller to present to the user
1919
internal var alertController: UIAlertController

ATAlertControllerDemo/ATAlertControllerDemo.xcodeproj/project.pbxproj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,16 @@
205205
TargetAttributes = {
206206
1975561C222A765500000146 = {
207207
CreatedOnToolsVersion = 10.1;
208+
LastSwiftMigration = 1100;
208209
};
209210
19755630222A765700000146 = {
210211
CreatedOnToolsVersion = 10.1;
212+
LastSwiftMigration = 1100;
211213
TestTargetID = 1975561C222A765500000146;
212214
};
213215
1975563B222A765700000146 = {
214216
CreatedOnToolsVersion = 10.1;
217+
LastSwiftMigration = 1100;
215218
TestTargetID = 1975561C222A765500000146;
216219
};
217220
};
@@ -455,7 +458,7 @@
455458
PRODUCT_BUNDLE_IDENTIFIER = com.demo.alertcontroller;
456459
PRODUCT_NAME = "$(TARGET_NAME)";
457460
PROVISIONING_PROFILE_SPECIFIER = "";
458-
SWIFT_VERSION = 4.2;
461+
SWIFT_VERSION = 5.0;
459462
TARGETED_DEVICE_FAMILY = "1,2";
460463
};
461464
name = Debug;
@@ -474,7 +477,7 @@
474477
PRODUCT_BUNDLE_IDENTIFIER = com.demo.alertcontroller;
475478
PRODUCT_NAME = "$(TARGET_NAME)";
476479
PROVISIONING_PROFILE_SPECIFIER = "";
477-
SWIFT_VERSION = 4.2;
480+
SWIFT_VERSION = 5.0;
478481
TARGETED_DEVICE_FAMILY = "1,2";
479482
};
480483
name = Release;
@@ -493,7 +496,7 @@
493496
);
494497
PRODUCT_BUNDLE_IDENTIFIER = com.demo.alertcontroller.ATAlertControllerDemoTests;
495498
PRODUCT_NAME = "$(TARGET_NAME)";
496-
SWIFT_VERSION = 4.2;
499+
SWIFT_VERSION = 5.0;
497500
TARGETED_DEVICE_FAMILY = "1,2";
498501
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ATAlertControllerDemo.app/ATAlertControllerDemo";
499502
};
@@ -513,7 +516,7 @@
513516
);
514517
PRODUCT_BUNDLE_IDENTIFIER = com.demo.alertcontroller.ATAlertControllerDemoTests;
515518
PRODUCT_NAME = "$(TARGET_NAME)";
516-
SWIFT_VERSION = 4.2;
519+
SWIFT_VERSION = 5.0;
517520
TARGETED_DEVICE_FAMILY = "1,2";
518521
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ATAlertControllerDemo.app/ATAlertControllerDemo";
519522
};
@@ -532,7 +535,7 @@
532535
);
533536
PRODUCT_BUNDLE_IDENTIFIER = com.demo.alertcontroller.ATAlertControllerDemoUITests;
534537
PRODUCT_NAME = "$(TARGET_NAME)";
535-
SWIFT_VERSION = 4.2;
538+
SWIFT_VERSION = 5.0;
536539
TARGETED_DEVICE_FAMILY = "1,2";
537540
TEST_TARGET_NAME = ATAlertControllerDemo;
538541
};
@@ -551,7 +554,7 @@
551554
);
552555
PRODUCT_BUNDLE_IDENTIFIER = com.demo.alertcontroller.ATAlertControllerDemoUITests;
553556
PRODUCT_NAME = "$(TARGET_NAME)";
554-
SWIFT_VERSION = 4.2;
557+
SWIFT_VERSION = 5.0;
555558
TARGETED_DEVICE_FAMILY = "1,2";
556559
TEST_TARGET_NAME = ATAlertControllerDemo;
557560
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "1.000",
13+
"alpha" : "1.000",
14+
"blue" : "1.000",
15+
"green" : "1.000"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "light"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "1.000",
31+
"alpha" : "1.000",
32+
"blue" : "1.000",
33+
"green" : "1.000"
34+
}
35+
}
36+
},
37+
{
38+
"idiom" : "universal",
39+
"appearances" : [
40+
{
41+
"appearance" : "luminosity",
42+
"value" : "dark"
43+
}
44+
],
45+
"color" : {
46+
"color-space" : "srgb",
47+
"components" : {
48+
"red" : "0.000",
49+
"alpha" : "1.000",
50+
"blue" : "0.000",
51+
"green" : "0.000"
52+
}
53+
}
54+
}
55+
]
56+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "1.000",
13+
"alpha" : "1.000",
14+
"blue" : "1.000",
15+
"green" : "1.000"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "light"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "0x4B",
31+
"alpha" : "1.000",
32+
"blue" : "0x6E",
33+
"green" : "0x57"
34+
}
35+
}
36+
},
37+
{
38+
"idiom" : "universal",
39+
"appearances" : [
40+
{
41+
"appearance" : "luminosity",
42+
"value" : "dark"
43+
}
44+
],
45+
"color" : {
46+
"color-space" : "srgb",
47+
"components" : {
48+
"red" : "1.000",
49+
"alpha" : "1.000",
50+
"blue" : "1.000",
51+
"green" : "1.000"
52+
}
53+
}
54+
}
55+
]
56+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "1.000",
13+
"alpha" : "1.000",
14+
"blue" : "1.000",
15+
"green" : "1.000"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "light"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "1.000",
31+
"alpha" : "1.000",
32+
"blue" : "1.000",
33+
"green" : "1.000"
34+
}
35+
}
36+
},
37+
{
38+
"idiom" : "universal",
39+
"appearances" : [
40+
{
41+
"appearance" : "luminosity",
42+
"value" : "dark"
43+
}
44+
],
45+
"color" : {
46+
"color-space" : "srgb",
47+
"components" : {
48+
"red" : "0.000",
49+
"alpha" : "1.000",
50+
"blue" : "0.000",
51+
"green" : "0.000"
52+
}
53+
}
54+
}
55+
]
56+
}
Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
7+
<capability name="Named colors" minToolsVersion="9.0"/>
98
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
109
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1110
</dependencies>
@@ -19,63 +18,63 @@
1918
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2019
<subviews>
2120
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dfc-1a-QQN">
22-
<rect key="frame" x="30" y="120" width="315" height="50"/>
23-
<color key="backgroundColor" red="0.29411764709999999" green="0.3411764706" blue="0.43137254899999999" alpha="1" colorSpace="calibratedRGB"/>
21+
<rect key="frame" x="30" y="100" width="315" height="50"/>
22+
<color key="backgroundColor" name="ButtonColor"/>
2423
<constraints>
2524
<constraint firstAttribute="height" constant="50" id="V4q-Jm-HMf"/>
2625
</constraints>
2726
<fontDescription key="fontDescription" type="system" pointSize="17"/>
2827
<state key="normal" title="Single Buttom">
29-
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
28+
<color key="titleColor" name="TextColor"/>
3029
</state>
3130
<connections>
3231
<action selector="oneButtonAlertPressed" destination="BYZ-38-t0r" eventType="touchUpInside" id="IBP-EK-lar"/>
3332
</connections>
3433
</button>
3534
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lBO-Eb-b4w">
36-
<rect key="frame" x="30" y="220" width="315" height="50"/>
37-
<color key="backgroundColor" red="0.29411764709999999" green="0.3411764706" blue="0.43137254899999999" alpha="1" colorSpace="calibratedRGB"/>
35+
<rect key="frame" x="30" y="200" width="315" height="50"/>
36+
<color key="backgroundColor" name="ButtonColor"/>
3837
<constraints>
3938
<constraint firstAttribute="height" constant="50" id="Gdi-0s-36U"/>
4039
</constraints>
4140
<fontDescription key="fontDescription" type="system" pointSize="17"/>
4241
<state key="normal" title="Multiple Button">
43-
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
42+
<color key="titleColor" name="TextColor"/>
4443
</state>
4544
<connections>
4645
<action selector="multipleButtonAlertPressed" destination="BYZ-38-t0r" eventType="touchUpInside" id="KLe-C5-4rh"/>
4746
</connections>
4847
</button>
4948
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pc1-e0-4mC">
50-
<rect key="frame" x="30" y="320" width="315" height="50"/>
51-
<color key="backgroundColor" red="0.29411764709999999" green="0.3411764706" blue="0.43137254899999999" alpha="1" colorSpace="calibratedRGB"/>
49+
<rect key="frame" x="30" y="300" width="315" height="50"/>
50+
<color key="backgroundColor" name="ButtonColor"/>
5251
<constraints>
5352
<constraint firstAttribute="height" constant="50" id="KCz-4h-dcP"/>
5453
</constraints>
5554
<fontDescription key="fontDescription" type="system" pointSize="17"/>
5655
<state key="normal" title="Alert + TextField">
57-
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
56+
<color key="titleColor" name="TextColor"/>
5857
</state>
5958
<connections>
6059
<action selector="alertWithTextFieldPressed" destination="BYZ-38-t0r" eventType="touchUpInside" id="kz8-qL-vcI"/>
6160
</connections>
6261
</button>
6362
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oNv-3X-D4F">
64-
<rect key="frame" x="30" y="420" width="315" height="50"/>
65-
<color key="backgroundColor" red="0.29411764709999999" green="0.3411764706" blue="0.43137254899999999" alpha="1" colorSpace="calibratedRGB"/>
63+
<rect key="frame" x="30" y="400" width="315" height="50"/>
64+
<color key="backgroundColor" name="ButtonColor"/>
6665
<constraints>
6766
<constraint firstAttribute="height" constant="50" id="ExJ-nz-PO9"/>
6867
</constraints>
6968
<fontDescription key="fontDescription" type="system" pointSize="17"/>
7069
<state key="normal" title="Action">
71-
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
70+
<color key="titleColor" name="TextColor"/>
7271
</state>
7372
<connections>
7473
<action selector="actionPressed" destination="BYZ-38-t0r" eventType="touchUpInside" id="lZe-hs-Mam"/>
7574
</connections>
7675
</button>
7776
</subviews>
78-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
77+
<color key="backgroundColor" name="BackgroundColor"/>
7978
<constraints>
8079
<constraint firstItem="lBO-Eb-b4w" firstAttribute="top" secondItem="dfc-1a-QQN" secondAttribute="bottom" constant="50" id="2et-mw-Pko"/>
8180
<constraint firstItem="pc1-e0-4mC" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="30" id="Fzy-LV-Qhh"/>
@@ -95,6 +94,18 @@
9594
</viewController>
9695
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
9796
</objects>
97+
<point key="canvasLocation" x="138" y="123"/>
9898
</scene>
9999
</scenes>
100+
<resources>
101+
<namedColor name="BackgroundColor">
102+
<color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
103+
</namedColor>
104+
<namedColor name="ButtonColor">
105+
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
106+
</namedColor>
107+
<namedColor name="TextColor">
108+
<color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
109+
</namedColor>
110+
</resources>
100111
</document>

ATAlertControllerDemo/ATAlertControllerDemoUITests/ATAlertControllerDemoUITests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,32 @@ class ATAlertControllerDemoUITests: XCTestCase {
2929
func testExample() {
3030
// Use recording to get started writing UI tests.
3131
// Use XCTAssert and related functions to verify your tests produce the correct results.
32+
33+
let app = XCUIApplication()
34+
app/*@START_MENU_TOKEN@*/.staticTexts["Single Buttom"]/*[[".buttons[\"Single Buttom\"].staticTexts[\"Single Buttom\"]",".staticTexts[\"Single Buttom\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
35+
36+
let elementsQuery = app.alerts["Title"].scrollViews.otherElements
37+
elementsQuery.buttons["OK"].tap()
38+
app.buttons["Multiple Button"].tap()
39+
elementsQuery.buttons["Accept"].tap()
40+
app/*@START_MENU_TOKEN@*/.staticTexts["Multiple Button"]/*[[".buttons[\"Multiple Button\"].staticTexts[\"Multiple Button\"]",".staticTexts[\"Multiple Button\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
41+
42+
let cancelButton = elementsQuery.buttons["Cancel"]
43+
cancelButton.tap()
44+
app/*@START_MENU_TOKEN@*/.staticTexts["Alert + TextField"]/*[[".buttons[\"Alert + TextField\"].staticTexts[\"Alert + TextField\"]",".staticTexts[\"Alert + TextField\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
45+
cancelButton.tap()
46+
47+
let actionButton = app.buttons["Action"]
48+
actionButton.tap()
49+
50+
let elementsQuery2 = app.sheets["Title"].scrollViews.otherElements
51+
elementsQuery2.buttons["Google Maps"].tap()
52+
actionButton.tap()
53+
elementsQuery2.buttons["Apple Maps"].tap()
54+
actionButton.tap()
55+
elementsQuery2.buttons["Cancel"].tap()
56+
57+
3258
}
3359

3460
}

0 commit comments

Comments
 (0)