Skip to content

Commit c39b272

Browse files
Merge pull request #1 from matthewcheok/master
Merge
2 parents 6408a99 + ba15212 commit c39b272

30 files changed

+766
-406
lines changed

JSONCodable.playground/Contents.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ We'll add conformance to `JSONEncodable`. You may also add conformance to `JSONC
3131
*/
3232

3333
extension User: JSONEncodable {
34-
func toJSON() throws -> AnyObject {
34+
func toJSON() throws -> Any {
3535
return try JSONEncoder.create({ (encoder) -> Void in
3636
try encoder.encode(id, key: "id")
3737
try encoder.encode(name, key: "full_name")
@@ -83,7 +83,7 @@ You can open the console and see the output using `CMD + SHIFT + Y` or ⇧⌘Y.
8383
Let's work with an incoming JSON Dictionary:
8484
*/
8585

86-
let JSON = [
86+
let JSON: [String: Any] = [
8787
"id": 24,
8888
"full_name": "John Appleseed",
8989
"email": "[email protected]",
@@ -114,5 +114,7 @@ And encode it to JSON using one of the provided methods:
114114
- `func JSONString() throws -> String`
115115
*/
116116

117+
try! 1.toJSON()
118+
117119
let dict = try! user.toJSON()
118120
print("Encoded: \n\(dict as! JSONObject)\n\n")

JSONCodable.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'JSONCodable'
3-
s.version = '2.1'
3+
s.version = '3.0.1'
44
s.ios.deployment_target = '8.0'
55
s.osx.deployment_target = '10.10'
66
s.license = { :type => 'MIT', :file => 'LICENSE' }

JSONCodable.xcodeproj/project.pbxproj

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
520B867D1DCEA60900885504 /* ArrayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520B867C1DCEA60900885504 /* ArrayTests.swift */; };
11+
520B867F1DCEB6A300885504 /* PropertyCompany.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520B867E1DCEB6A300885504 /* PropertyCompany.swift */; };
1012
5211CD0A1CE2EBFB0097F255 /* NestItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5211CD091CE2EBFB0097F255 /* NestItem.swift */; };
1113
52E8F44F1C9087D200F40F7F /* UtilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52E8F44E1C9087D200F40F7F /* UtilityTests.swift */; };
1214
9E455BFA1BCE185B00070A4F /* EnumTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E455BF91BCE185B00070A4F /* EnumTests.swift */; };
@@ -37,6 +39,9 @@
3739
A1B71C7E1D37E90B006DA33A /* MirrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B71C7D1D37E90B006DA33A /* MirrorTests.swift */; };
3840
A1B71C801D37E982006DA33A /* ClassInheritance.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B71C7F1D37E982006DA33A /* ClassInheritance.swift */; };
3941
A1B71C811D37EA92006DA33A /* JSONEncodable+Mirror.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B71C7B1D37E6BD006DA33A /* JSONEncodable+Mirror.swift */; };
42+
BD885BBE1D17358E00CA767A /* EncodeNestingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD885BBD1D17358E00CA767A /* EncodeNestingTests.swift */; };
43+
BD885BC01D173A0700CA767A /* PropertyItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD885BBF1D173A0700CA767A /* PropertyItem.swift */; };
44+
BDD667CC1D1F3572003F94D7 /* Messages.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDD667CB1D1F3572003F94D7 /* Messages.swift */; };
4045
/* End PBXBuildFile section */
4146

4247
/* Begin PBXContainerItemProxy section */
@@ -50,6 +55,8 @@
5055
/* End PBXContainerItemProxy section */
5156

5257
/* Begin PBXFileReference section */
58+
520B867C1DCEA60900885504 /* ArrayTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrayTests.swift; sourceTree = "<group>"; };
59+
520B867E1DCEB6A300885504 /* PropertyCompany.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PropertyCompany.swift; sourceTree = "<group>"; };
5360
5211CD091CE2EBFB0097F255 /* NestItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NestItem.swift; sourceTree = "<group>"; };
5461
52E8F44E1C9087D200F40F7F /* UtilityTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UtilityTests.swift; sourceTree = "<group>"; };
5562
9E455BF71BCE185B00070A4F /* JSONCodableTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JSONCodableTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -76,6 +83,9 @@
7683
A1B71C7B1D37E6BD006DA33A /* JSONEncodable+Mirror.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "JSONEncodable+Mirror.swift"; sourceTree = "<group>"; };
7784
A1B71C7D1D37E90B006DA33A /* MirrorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MirrorTests.swift; sourceTree = "<group>"; };
7885
A1B71C7F1D37E982006DA33A /* ClassInheritance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClassInheritance.swift; sourceTree = "<group>"; };
86+
BD885BBD1D17358E00CA767A /* EncodeNestingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EncodeNestingTests.swift; sourceTree = "<group>"; };
87+
BD885BBF1D173A0700CA767A /* PropertyItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PropertyItem.swift; sourceTree = "<group>"; };
88+
BDD667CB1D1F3572003F94D7 /* Messages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Messages.swift; sourceTree = "<group>"; };
7989
/* End PBXFileReference section */
8090

8191
/* Begin PBXFrameworksBuildPhase section */
@@ -118,6 +128,9 @@
118128
isa = PBXGroup;
119129
children = (
120130
5211CD091CE2EBFB0097F255 /* NestItem.swift */,
131+
520B867E1DCEB6A300885504 /* PropertyCompany.swift */,
132+
BDD667CB1D1F3572003F94D7 /* Messages.swift */,
133+
BD885BBF1D173A0700CA767A /* PropertyItem.swift */,
121134
9E455C021BCE1C1E00070A4F /* Fruit.swift */,
122135
9E8E07231BD3F15800F98421 /* Food.swift */,
123136
9E455C041BCE1D0700070A4F /* User.swift */,
@@ -132,8 +145,10 @@
132145
isa = PBXGroup;
133146
children = (
134147
9ECF00C31BCF82F5008D557C /* HelperTests.swift */,
148+
520B867C1DCEA60900885504 /* ArrayTests.swift */,
135149
52E8F44E1C9087D200F40F7F /* UtilityTests.swift */,
136150
9E455C0A1BCE1F0100070A4F /* RegularTests.swift */,
151+
BD885BBD1D17358E00CA767A /* EncodeNestingTests.swift */,
137152
9E455BF91BCE185B00070A4F /* EnumTests.swift */,
138153
9ECF00BF1BCE251B008D557C /* TransformerTests.swift */,
139154
A1B71C7D1D37E90B006DA33A /* MirrorTests.swift */,
@@ -266,7 +281,7 @@
266281
9EDF80101B59CFCE00E4A2D6 /* Project object */ = {
267282
isa = PBXProject;
268283
attributes = {
269-
LastUpgradeCheck = 0710;
284+
LastUpgradeCheck = 0810;
270285
TargetAttributes = {
271286
9E455BF61BCE185B00070A4F = {
272287
CreatedOnToolsVersion = 7.0.1;
@@ -276,6 +291,7 @@
276291
};
277292
9EDB39221B59D01D00C63019 = {
278293
CreatedOnToolsVersion = 7.0;
294+
LastSwiftMigration = 0800;
279295
};
280296
};
281297
};
@@ -333,12 +349,17 @@
333349
A1B71C7E1D37E90B006DA33A /* MirrorTests.swift in Sources */,
334350
9ECF00C41BCF82F5008D557C /* HelperTests.swift in Sources */,
335351
9ECF00C21BCF6E43008D557C /* ImageAsset.swift in Sources */,
352+
520B867D1DCEA60900885504 /* ArrayTests.swift in Sources */,
336353
9E455C031BCE1C1E00070A4F /* Fruit.swift in Sources */,
337354
9ECF00C01BCE251B008D557C /* TransformerTests.swift in Sources */,
355+
BDD667CC1D1F3572003F94D7 /* Messages.swift in Sources */,
338356
9E455BFA1BCE185B00070A4F /* EnumTests.swift in Sources */,
339357
9E8E07241BD3F15800F98421 /* Food.swift in Sources */,
358+
520B867F1DCEB6A300885504 /* PropertyCompany.swift in Sources */,
359+
BD885BBE1D17358E00CA767A /* EncodeNestingTests.swift in Sources */,
340360
9E455C0B1BCE1F0100070A4F /* RegularTests.swift in Sources */,
341361
9E455C051BCE1D0700070A4F /* User.swift in Sources */,
362+
BD885BC01D173A0700CA767A /* PropertyItem.swift in Sources */,
342363
9E455C091BCE1DE100070A4F /* Company.swift in Sources */,
343364
);
344365
runOnlyForDeploymentPostprocessing = 0;
@@ -427,6 +448,7 @@
427448
PRODUCT_NAME = "$(TARGET_NAME)";
428449
SDKROOT = macosx;
429450
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
451+
SWIFT_VERSION = 3.0;
430452
};
431453
name = Debug;
432454
};
@@ -467,6 +489,8 @@
467489
PRODUCT_BUNDLE_IDENTIFIER = com.matthewcheok.JSONCodableTests;
468490
PRODUCT_NAME = "$(TARGET_NAME)";
469491
SDKROOT = macosx;
492+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
493+
SWIFT_VERSION = 3.0;
470494
};
471495
name = Release;
472496
};
@@ -487,7 +511,7 @@
487511
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
488512
CLANG_WARN_UNREACHABLE_CODE = YES;
489513
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
490-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
514+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
491515
COPY_PHASE_STRIP = NO;
492516
CURRENT_PROJECT_VERSION = 1;
493517
DEBUG_INFORMATION_FORMAT = dwarf;
@@ -522,6 +546,7 @@
522546
SDKROOT = iphoneos;
523547
SKIP_INSTALL = YES;
524548
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
549+
SWIFT_VERSION = 3.0;
525550
TARGETED_DEVICE_FAMILY = "1,2";
526551
VERSIONING_SYSTEM = "apple-generic";
527552
VERSION_INFO_PREFIX = "";
@@ -546,7 +571,7 @@
546571
CLANG_WARN_UNREACHABLE_CODE = YES;
547572
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
548573
CODE_SIGN_IDENTITY = "iPhone Distribution";
549-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
574+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
550575
COPY_PHASE_STRIP = NO;
551576
CURRENT_PROJECT_VERSION = 1;
552577
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -573,6 +598,8 @@
573598
PRODUCT_NAME = JSONCodable;
574599
SDKROOT = iphoneos;
575600
SKIP_INSTALL = YES;
601+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
602+
SWIFT_VERSION = 3.0;
576603
TARGETED_DEVICE_FAMILY = "1,2";
577604
VALIDATE_PRODUCT = YES;
578605
VERSIONING_SYSTEM = "apple-generic";
@@ -633,6 +660,7 @@
633660
SDKROOT = macosx;
634661
SKIP_INSTALL = YES;
635662
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
663+
SWIFT_VERSION = 3.0;
636664
VERSIONING_SYSTEM = "apple-generic";
637665
VERSION_INFO_PREFIX = "";
638666
};
@@ -683,6 +711,8 @@
683711
PRODUCT_NAME = JSONCodable;
684712
SDKROOT = macosx;
685713
SKIP_INSTALL = YES;
714+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
715+
SWIFT_VERSION = 3.0;
686716
VERSIONING_SYSTEM = "apple-generic";
687717
VERSION_INFO_PREFIX = "";
688718
};
@@ -691,7 +721,24 @@
691721
9EDF80141B59CFCE00E4A2D6 /* Debug */ = {
692722
isa = XCBuildConfiguration;
693723
buildSettings = {
724+
CLANG_WARN_BOOL_CONVERSION = YES;
725+
CLANG_WARN_CONSTANT_CONVERSION = YES;
726+
CLANG_WARN_EMPTY_BODY = YES;
727+
CLANG_WARN_ENUM_CONVERSION = YES;
728+
CLANG_WARN_INFINITE_RECURSION = YES;
729+
CLANG_WARN_INT_CONVERSION = YES;
730+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
731+
CLANG_WARN_UNREACHABLE_CODE = YES;
732+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
733+
ENABLE_STRICT_OBJC_MSGSEND = YES;
694734
ENABLE_TESTABILITY = YES;
735+
GCC_NO_COMMON_BLOCKS = YES;
736+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
737+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
738+
GCC_WARN_UNDECLARED_SELECTOR = YES;
739+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
740+
GCC_WARN_UNUSED_FUNCTION = YES;
741+
GCC_WARN_UNUSED_VARIABLE = YES;
695742
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
696743
MACOSX_DEPLOYMENT_TARGET = 10.10;
697744
ONLY_ACTIVE_ARCH = YES;
@@ -701,6 +748,23 @@
701748
9EDF80151B59CFCE00E4A2D6 /* Release */ = {
702749
isa = XCBuildConfiguration;
703750
buildSettings = {
751+
CLANG_WARN_BOOL_CONVERSION = YES;
752+
CLANG_WARN_CONSTANT_CONVERSION = YES;
753+
CLANG_WARN_EMPTY_BODY = YES;
754+
CLANG_WARN_ENUM_CONVERSION = YES;
755+
CLANG_WARN_INFINITE_RECURSION = YES;
756+
CLANG_WARN_INT_CONVERSION = YES;
757+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
758+
CLANG_WARN_UNREACHABLE_CODE = YES;
759+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
760+
ENABLE_STRICT_OBJC_MSGSEND = YES;
761+
GCC_NO_COMMON_BLOCKS = YES;
762+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
763+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
764+
GCC_WARN_UNDECLARED_SELECTOR = YES;
765+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
766+
GCC_WARN_UNUSED_FUNCTION = YES;
767+
GCC_WARN_UNUSED_VARIABLE = YES;
704768
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
705769
MACOSX_DEPLOYMENT_TARGET = 10.10;
706770
};

JSONCodable.xcodeproj/xcshareddata/xcschemes/JSONCodable OSX.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0710"
3+
LastUpgradeVersion = "0810"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

JSONCodable.xcodeproj/xcshareddata/xcschemes/JSONCodable iOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0710"
3+
LastUpgradeVersion = "0810"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

JSONCodable/JSONCodable.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ extension Bool: JSONCompatible {}
2121
extension Int: JSONCompatible {}
2222

2323
extension JSONCompatible {
24-
public func toJSON() throws -> AnyObject {
25-
return self as! AnyObject
26-
}
24+
public func toJSON() throws -> Any {
25+
return self
26+
}
2727
}
28-
29-
// Swift 2 Shims
30-
31-
#if !swift(>=3.0)
32-
typealias ErrorProtocol = ErrorType
33-
#endif

0 commit comments

Comments
 (0)