Skip to content

Commit 6ac8494

Browse files
committed
Moved test configuration to .plist file
1 parent b06c29e commit 6ac8494

File tree

6 files changed

+219
-109
lines changed

6 files changed

+219
-109
lines changed

SwiftyAPNS.xcodeproj/project.pbxproj

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
/* End PBXAggregateTarget section */
2222

2323
/* Begin PBXBuildFile section */
24+
DBF082DC24DDEB1400C0D01C /* CustomPayloads.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF082DB24DDEB1400C0D01C /* CustomPayloads.swift */; };
25+
DBF082E624DE0F1600C0D01C /* CertificateConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = DBF082E024DE09C300C0D01C /* CertificateConfig.plist */; };
26+
DBFE5C2724DF7B8200BDBB8B /* CommonCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBFE5C2624DF7B7700BDBB8B /* CommonCode.swift */; };
2427
OBJ_30 /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* Error.swift */; };
2528
OBJ_31 /* Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_10 /* Notification.swift */; };
2629
OBJ_32 /* NotificationOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_11 /* NotificationOptions.swift */; };
@@ -51,6 +54,9 @@
5154
/* End PBXContainerItemProxy section */
5255

5356
/* Begin PBXFileReference section */
57+
DBF082DB24DDEB1400C0D01C /* CustomPayloads.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPayloads.swift; sourceTree = "<group>"; };
58+
DBF082E024DE09C300C0D01C /* CertificateConfig.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = CertificateConfig.plist; sourceTree = "<group>"; };
59+
DBFE5C2624DF7B7700BDBB8B /* CommonCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonCode.swift; sourceTree = "<group>"; };
5460
OBJ_10 /* Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notification.swift; sourceTree = "<group>"; };
5561
OBJ_11 /* NotificationOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationOptions.swift; sourceTree = "<group>"; };
5662
OBJ_12 /* Payload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Payload.swift; sourceTree = "<group>"; };
@@ -63,8 +69,8 @@
6369
OBJ_24 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
6470
OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
6571
OBJ_9 /* Error.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Error.swift; sourceTree = "<group>"; };
66-
"SwiftyAPNS::SwiftyAPNS::Product" /* SwiftyAPNS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SwiftyAPNS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
67-
"SwiftyAPNS::SwiftyAPNSTests::Product" /* SwiftyAPNSTests.xctest */ = {isa = PBXFileReference; lastKnownFileType = file; path = SwiftyAPNSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
72+
"SwiftyAPNS::SwiftyAPNS::Product" /* SwiftyAPNS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SwiftyAPNS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
73+
"SwiftyAPNS::SwiftyAPNSTests::Product" /* SwiftyAPNSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; path = SwiftyAPNSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6874
/* End PBXFileReference section */
6975

7076
/* Begin PBXFrameworksBuildPhase section */
@@ -97,7 +103,10 @@
97103
isa = PBXGroup;
98104
children = (
99105
OBJ_18 /* SwiftyAPNSTests.swift */,
106+
DBF082DB24DDEB1400C0D01C /* CustomPayloads.swift */,
107+
DBFE5C2624DF7B7700BDBB8B /* CommonCode.swift */,
100108
OBJ_19 /* XCTestManifests.swift */,
109+
DBF082E024DE09C300C0D01C /* CertificateConfig.plist */,
101110
);
102111
name = SwiftyAPNSTests;
103112
path = Tests/SwiftyAPNSTests;
@@ -186,6 +195,7 @@
186195
buildPhases = (
187196
OBJ_53 /* Sources */,
188197
OBJ_56 /* Frameworks */,
198+
DBF082E524DE0F0E00C0D01C /* Resources */,
189199
);
190200
buildRules = (
191201
);
@@ -226,6 +236,17 @@
226236
};
227237
/* End PBXProject section */
228238

239+
/* Begin PBXResourcesBuildPhase section */
240+
DBF082E524DE0F0E00C0D01C /* Resources */ = {
241+
isa = PBXResourcesBuildPhase;
242+
buildActionMask = 2147483647;
243+
files = (
244+
DBF082E624DE0F1600C0D01C /* CertificateConfig.plist in Resources */,
245+
);
246+
runOnlyForDeploymentPostprocessing = 0;
247+
};
248+
/* End PBXResourcesBuildPhase section */
249+
229250
/* Begin PBXSourcesBuildPhase section */
230251
OBJ_29 /* Sources */ = {
231252
isa = PBXSourcesBuildPhase;
@@ -255,6 +276,8 @@
255276
files = (
256277
OBJ_54 /* SwiftyAPNSTests.swift in Sources */,
257278
OBJ_55 /* XCTestManifests.swift in Sources */,
279+
DBF082DC24DDEB1400C0D01C /* CustomPayloads.swift in Sources */,
280+
DBFE5C2724DF7B8200BDBB8B /* CommonCode.swift in Sources */,
258281
);
259282
runOnlyForDeploymentPostprocessing = 0;
260283
};
@@ -293,7 +316,7 @@
293316
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
294317
SKIP_INSTALL = YES;
295318
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
296-
SWIFT_VERSION = 4.2;
319+
SWIFT_VERSION = 5.0;
297320
TARGET_NAME = SwiftyAPNS;
298321
};
299322
name = Debug;
@@ -317,7 +340,7 @@
317340
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
318341
SKIP_INSTALL = YES;
319342
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
320-
SWIFT_VERSION = 4.2;
343+
SWIFT_VERSION = 5.0;
321344
TARGET_NAME = SwiftyAPNS;
322345
};
323346
name = Release;
@@ -378,7 +401,7 @@
378401
buildSettings = {
379402
LD = /usr/bin/true;
380403
OTHER_SWIFT_FLAGS = "-swift-version 4.2 -I $(TOOLCHAIN_DIR)/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -package-description-version 4.2";
381-
SWIFT_VERSION = 4.2;
404+
SWIFT_VERSION = 5.0;
382405
};
383406
name = Debug;
384407
};
@@ -387,7 +410,7 @@
387410
buildSettings = {
388411
LD = /usr/bin/true;
389412
OTHER_SWIFT_FLAGS = "-swift-version 4.2 -I $(TOOLCHAIN_DIR)/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -package-description-version 4.2";
390-
SWIFT_VERSION = 4.2;
413+
SWIFT_VERSION = 5.0;
391414
};
392415
name = Release;
393416
};
@@ -419,7 +442,7 @@
419442
OTHER_LDFLAGS = "$(inherited)";
420443
OTHER_SWIFT_FLAGS = "$(inherited)";
421444
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
422-
SWIFT_VERSION = 4.2;
445+
SWIFT_VERSION = 5.0;
423446
TARGET_NAME = SwiftyAPNSTests;
424447
};
425448
name = Debug;
@@ -440,7 +463,7 @@
440463
OTHER_LDFLAGS = "$(inherited)";
441464
OTHER_SWIFT_FLAGS = "$(inherited)";
442465
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)";
443-
SWIFT_VERSION = 4.2;
466+
SWIFT_VERSION = 5.0;
444467
TARGET_NAME = SwiftyAPNSTests;
445468
};
446469
name = Release;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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>CERT_PATH</key>
6+
<string>/path/to/push_cert.p12</string>
7+
<key>CERT_PASS</key>
8+
<string>secure</string>
9+
<key>TOKEN</key>
10+
<string>86da0761d2f2b50e816109c0d9ac79b8efbcb9f33ea01248ed3d3aba3c59a224</string>
11+
<key>TOPIC</key>
12+
<string>com.push.example</string>
13+
</dict>
14+
</plist>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// CommonCode.swift
3+
// SwiftyAPNSTests
4+
//
5+
6+
import Foundation
7+
@testable import SwiftyAPNS
8+
9+
protocol StringEnum {
10+
var rawValue: String { get }
11+
}
12+
13+
extension Dictionary {
14+
subscript(enumKey: StringEnum) -> Value? {
15+
get {
16+
if let key = enumKey.rawValue as? Key {
17+
return self[key]
18+
}
19+
return nil
20+
}
21+
set {
22+
if let key = enumKey.rawValue as? Key {
23+
self[key] = newValue
24+
}
25+
}
26+
}
27+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
//
2+
// CustomPayloads.swift
3+
// SwiftyAPNSTests
4+
//
5+
6+
import Foundation
7+
@testable import SwiftyAPNS
8+
9+
public class CustomPayload1: Payload {
10+
11+
public let acme1: String
12+
public let acme2: Int
13+
14+
public init (alert: APSAlert?, badge: Int?, sound: String?, category: String?, acme1: String, acme2: Int) {
15+
self.acme1 = acme1
16+
self.acme2 = acme2
17+
super.init(alert: alert, badge: badge, sound: sound, contentAvailable: (alert == nil) ? 1 : nil, mutableContent: nil, category: category, threadId: nil)
18+
}
19+
20+
public init (acme1: String, acme2: Int) {
21+
self.acme1 = acme1
22+
self.acme2 = acme2
23+
super.init(alert: nil, badge: nil, sound: nil, contentAvailable: 1, mutableContent: nil, category: nil, threadId: nil)
24+
}
25+
26+
override public func encode(to encoder: Encoder) throws {
27+
try super.encode(to: encoder)
28+
var container = encoder.container(keyedBy: CodingKeys.self)
29+
try container.encode(acme1, forKey: .acme1)
30+
try container.encode(acme2, forKey: .acme2)
31+
}
32+
33+
private enum CodingKeys: String, CodingKey {
34+
case acme1
35+
case acme2
36+
}
37+
}
38+
39+
public class CustomPayload2: Payload {
40+
41+
public let acme1: [String]
42+
43+
public init (alert: APSAlert?, badge: Int?, sound: String?, category: String?, acme1: [String]) {
44+
self.acme1 = acme1
45+
super.init(alert: alert, badge: badge, sound: sound, contentAvailable: (alert == nil) ? 1 : nil, mutableContent: nil, category: category, threadId: nil)
46+
}
47+
48+
override public func encode(to encoder: Encoder) throws {
49+
try super.encode(to: encoder)
50+
var container = encoder.container(keyedBy: CodingKeys.self)
51+
try container.encode(acme1, forKey: .acme1)
52+
}
53+
54+
private enum CodingKeys: String, CodingKey {
55+
case acme1
56+
}
57+
}
58+
59+
public class CustomPayload3: Payload {
60+
61+
public let encrypted: String
62+
63+
public init (alert: APSAlert?, badge: Int?, sound: String?, category: String?, encrypted: String) {
64+
self.encrypted = encrypted
65+
super.init(alert: alert, badge: badge, sound: sound, contentAvailable: nil, mutableContent: 1, category: category, threadId: nil)
66+
}
67+
68+
override public func encode(to encoder: Encoder) throws {
69+
try super.encode(to: encoder)
70+
var container = encoder.container(keyedBy: CodingKeys.self)
71+
try container.encode(encrypted, forKey: .encrypted)
72+
}
73+
74+
private enum CodingKeys: String, CodingKey {
75+
case encrypted
76+
}
77+
}

0 commit comments

Comments
 (0)