Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
Update (#6)
Browse files Browse the repository at this point in the history
* Replace ReactiveCocoa with ReactiveSwift. Update dependencies.

* Upgrade to Swift 3.0 and get compiling.

* Remove redundant Response extensions.

* Rename API from map* to unbox(*:)

* Update README

* Use implicit RxSwift and ReactiveSwift dependencies from Moya.

* Update to recommended project settings.

* Add unboxing at key/keyPaths.

* Fix typo.

* Update README to include key path support.
  • Loading branch information
scottrhoyt authored and RyogaK committed Dec 2, 2016
1 parent 0730bac commit a0fe78f
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 109 deletions.
6 changes: 2 additions & 4 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
github "johnsundell/unbox" ~> 1.9.0
github "Moya/Moya" ~> 7.0.0
github "ReactiveCocoa/ReactiveCocoa" ~> 4.2.2
github "ReactiveX/RxSwift" ~> 2.6.0
github "johnsundell/unbox" ~> 2.0
github "Moya/Moya" ~> 8.0
12 changes: 6 additions & 6 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
github "Alamofire/Alamofire" "3.5.1"
github "antitypical/Result" "2.1.3"
github "ReactiveX/RxSwift" "2.6.0"
github "johnsundell/unbox" "1.9"
github "ReactiveCocoa/ReactiveCocoa" "v4.2.2"
github "Moya/Moya" "7.0.3"
github "Alamofire/Alamofire" "4.2.0"
github "antitypical/Result" "3.1.0"
github "ReactiveX/RxSwift" "3.0.1"
github "johnsundell/unbox" "2.2.1"
github "ReactiveCocoa/ReactiveSwift" "1.0.0-alpha.3"
github "Moya/Moya" "8.0.0-beta.5"
66 changes: 52 additions & 14 deletions Moya-Unbox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
295670261D880E4400D9D303 /* SignalProducer+Unbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F382741D878B4A0035054D /* SignalProducer+Unbox.swift */; };
2956702A1D880E4400D9D303 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29D6412E1D86BA3B00C4194A /* Alamofire.framework */; };
2956702C1D880E4400D9D303 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29D6412F1D86BA3B00C4194A /* Result.framework */; };
2956702E1D880E4400D9D303 /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29F382711D878B1B0035054D /* ReactiveCocoa.framework */; settings = {ATTRIBUTES = (Required, ); }; };
295670371D880ED400D9D303 /* RxMoya.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 295670361D880ED400D9D303 /* RxMoya.framework */; };
295670391D880EE200D9D303 /* ReactiveMoya.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 295670381D880EE200D9D303 /* ReactiveMoya.framework */; };
297A999B1D86BDF00074123C /* Response+Unbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297A999A1D86BDF00074123C /* Response+Unbox.swift */; };
29D641301D86BA3B00C4194A /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29D6412E1D86BA3B00C4194A /* Alamofire.framework */; };
29D641311D86BA3B00C4194A /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29D6412F1D86BA3B00C4194A /* Result.framework */; };
29D641351D86BC9000C4194A /* Moya.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29D641341D86BC9000C4194A /* Moya.framework */; };
3B6B846A1DEE988400AA37E1 /* ReactiveSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B6B84691DEE988400AA37E1 /* ReactiveSwift.framework */; };
3B6B846C1DEE9B3C00AA37E1 /* Response+Unbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297A999A1D86BDF00074123C /* Response+Unbox.swift */; };
3B6B846D1DEE9B3C00AA37E1 /* Response+Unbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 297A999A1D86BDF00074123C /* Response+Unbox.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -38,8 +40,8 @@
29D6412F1D86BA3B00C4194A /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/iOS/Result.framework; sourceTree = "<group>"; };
29D641321D86BC7D00C4194A /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = Carthage/Build/iOS/RxSwift.framework; sourceTree = "<group>"; };
29D641341D86BC9000C4194A /* Moya.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Moya.framework; path = Carthage/Build/iOS/Moya.framework; sourceTree = "<group>"; };
29F382711D878B1B0035054D /* ReactiveCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReactiveCocoa.framework; path = Carthage/Build/iOS/ReactiveCocoa.framework; sourceTree = "<group>"; };
29F382741D878B4A0035054D /* SignalProducer+Unbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SignalProducer+Unbox.swift"; sourceTree = "<group>"; };
3B6B84691DEE988400AA37E1 /* ReactiveSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReactiveSwift.framework; path = Carthage/Build/iOS/ReactiveSwift.framework; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -60,8 +62,8 @@
files = (
2956702A1D880E4400D9D303 /* Alamofire.framework in Frameworks */,
2956702C1D880E4400D9D303 /* Result.framework in Frameworks */,
2956702E1D880E4400D9D303 /* ReactiveCocoa.framework in Frameworks */,
295670391D880EE200D9D303 /* ReactiveMoya.framework in Frameworks */,
3B6B846A1DEE988400AA37E1 /* ReactiveSwift.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -92,13 +94,7 @@
29D6412A1D86B8B600C4194A /* Configs */,
29D641111D86B86F00C4194A /* Products */,
29D6412B1D86B8BD00C4194A /* Sources */,
29D6412E1D86BA3B00C4194A /* Alamofire.framework */,
29D641341D86BC9000C4194A /* Moya.framework */,
295670361D880ED400D9D303 /* RxMoya.framework */,
29F382711D878B1B0035054D /* ReactiveCocoa.framework */,
29D6412F1D86BA3B00C4194A /* Result.framework */,
295670381D880EE200D9D303 /* ReactiveMoya.framework */,
29D641321D86BC7D00C4194A /* RxSwift.framework */,
3B6B846B1DEE989F00AA37E1 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -125,19 +121,33 @@
29D6412B1D86B8BD00C4194A /* Sources */ = {
isa = PBXGroup;
children = (
29F382731D878B210035054D /* ReactiveCocoa */,
29F382731D878B210035054D /* ReactiveSwift */,
297A999C1D86C1100074123C /* RxSwift */,
297A999A1D86BDF00074123C /* Response+Unbox.swift */,
);
path = Sources;
sourceTree = "<group>";
};
29F382731D878B210035054D /* ReactiveCocoa */ = {
29F382731D878B210035054D /* ReactiveSwift */ = {
isa = PBXGroup;
children = (
29F382741D878B4A0035054D /* SignalProducer+Unbox.swift */,
);
path = ReactiveCocoa;
path = ReactiveSwift;
sourceTree = "<group>";
};
3B6B846B1DEE989F00AA37E1 /* Frameworks */ = {
isa = PBXGroup;
children = (
3B6B84691DEE988400AA37E1 /* ReactiveSwift.framework */,
29D6412E1D86BA3B00C4194A /* Alamofire.framework */,
29D641341D86BC9000C4194A /* Moya.framework */,
295670361D880ED400D9D303 /* RxMoya.framework */,
29D6412F1D86BA3B00C4194A /* Result.framework */,
295670381D880EE200D9D303 /* ReactiveMoya.framework */,
29D641321D86BC7D00C4194A /* RxSwift.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -228,11 +238,18 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0810;
ORGANIZATIONNAME = "Ryoga Kitagawa";
TargetAttributes = {
295670001D880E3B00D9D303 = {
LastSwiftMigration = 0810;
};
295670241D880E4400D9D303 = {
LastSwiftMigration = 0810;
};
29D6410F1D86B86F00C4194A = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0810;
};
};
};
Expand Down Expand Up @@ -285,6 +302,7 @@
buildActionMask = 2147483647;
files = (
295670031D880E3B00D9D303 /* Observable+Unbox.swift in Sources */,
3B6B846C1DEE9B3C00AA37E1 /* Response+Unbox.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -293,6 +311,7 @@
buildActionMask = 2147483647;
files = (
295670261D880E4400D9D303 /* SignalProducer+Unbox.swift in Sources */,
3B6B846D1DEE9B3C00AA37E1 /* Response+Unbox.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -311,6 +330,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -327,13 +347,15 @@
PRODUCT_NAME = RxMoya_Unbox;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
2956700F1D880E3B00D9D303 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -349,20 +371,23 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.moya-unbox.RxMoya-Unbox";
PRODUCT_NAME = RxMoya_Unbox;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
295670321D880E4400D9D303 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
INFOPLIST_FILE = "Configs/ReactiveMoya-Unbox-Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -372,20 +397,23 @@
PRODUCT_NAME = ReactiveMoya_Unbox;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
295670331D880E4400D9D303 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
INFOPLIST_FILE = "Configs/ReactiveMoya-Unbox-Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -394,6 +422,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.moya-unbox.ReactiveMoya-Unbox";
PRODUCT_NAME = ReactiveMoya_Unbox;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -411,8 +440,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -460,8 +491,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -481,6 +514,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -492,6 +526,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -508,13 +543,15 @@
PRODUCT_NAME = Moya_Unbox;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
29D641261D86B86F00C4194A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -530,6 +567,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.moya-unbox.Moya-Unbox";
PRODUCT_NAME = Moya_Unbox;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Moya-Unbox
compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)

[Unbox](https://github.com/JohnSundell/Unbox) bindings for [Moya](https://github.com/Moya/Moya) for fabulous JSON serialization.
Supports [RxSwift](https://github.com/ReactiveX/RxSwift/) and [ReactiveCocoa](https://github.com/ReactiveCocoa/ReactiveCocoa/) bindings as well.
Supports [RxSwift](https://github.com/ReactiveX/RxSwift/) and [ReactiveSwift](https://github.com/ReactiveCocoa/ReactiveSwift/) bindings as well.

# Installation

Expand All @@ -24,14 +24,14 @@ import Unbox

struct Repository: Unboxable {

let identifier: Int!
let identifier: Int
let language: String?
let url: String!
init(unboxer: Unboxer) {
identifier = unboxer.unbox("id")
let url: URL

init(unboxer: Unboxer) throws {
identifier = try unboxer.unbox("id")
language = unboxer.unbox("language")
url = unboxer.unbox("url")
url = try unboxer.unbox("url")
}
}
```
Expand All @@ -48,7 +48,7 @@ GitHubProvider.request(.UserRepositories(username), completion: { result in
switch result {
case let .Success(response):
do {
if let repos = try response.mapArray(Repository.self) {
if let repos = try response.unbox(array: Repository.self) {
self.repos = repos
} else {
success = false
Expand All @@ -72,7 +72,7 @@ GitHubProvider.request(.UserRepositories(username), completion: { result in

```swift
GitHubProvider.request(.UserRepositories(username))
.mapArray(Repository.self)
.unbox(array: Repository.self)
.subscribe { event -> Void in
switch event {
case .Next(let repos):
Expand All @@ -85,6 +85,12 @@ GitHubProvider.request(.UserRepositories(username))
}.addDisposableTo(disposeBag)
```

## Key Path Support

You can also `unbox` at specific keys and key paths by using the
`unbox(object:, atKey:)` and `unbox(object:, atKeyPath:)` functions (as well as
the `array` equivalents).

# Contributing

Feel free to make issues and pull requests!
Expand Down
Loading

0 comments on commit a0fe78f

Please sign in to comment.