Skip to content
This repository was archived by the owner on Sep 11, 2022. It is now read-only.

Commit 0cc701b

Browse files
authored
Features/swift package manager (#5)
* just return httpResponse * Refactor, added URLSessionConfiguration as initializer parameter and added RawResponse model. * update Example * update gitignore for swift * added swift package manager support * update Example * just ignore the swift package test for now * update .travis
1 parent a42cd68 commit 0cc701b

File tree

19 files changed

+161
-56
lines changed

19 files changed

+161
-56
lines changed

.gitignore

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# OS X
22
.DS_Store
3-
43
# Xcode
4+
#
5+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
6+
7+
## Build generated
58
build/
9+
DerivedData/
10+
11+
## Various settings
612
*.pbxuser
713
!default.pbxuser
814
*.mode1v3
@@ -12,22 +18,54 @@ build/
1218
*.perspectivev3
1319
!default.perspectivev3
1420
xcuserdata/
15-
*.xccheckout
16-
profile
21+
22+
## Other
1723
*.moved-aside
18-
DerivedData
24+
*.xccheckout
25+
*.xcscmblueprint
26+
27+
## Obj-C/Swift specific
1928
*.hmap
2029
*.ipa
30+
*.dSYM.zip
31+
*.dSYM
2132

22-
# Bundler
23-
.bundle
33+
## Playgrounds
34+
timeline.xctimeline
35+
playground.xcworkspace
2436

25-
Carthage
37+
# Swift Package Manager
38+
#
39+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
40+
# Packages/
41+
# Package.pins
42+
# Package.resolved
43+
.build/
44+
45+
# CocoaPods
46+
#
2647
# We recommend against adding the Pods directory to your .gitignore. However
2748
# you should judge for yourself, the pros and cons are mentioned at:
28-
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
29-
#
30-
# Note: if you ignore the Pods directory, make sure to uncomment
31-
# `pod install` in .travis.yml
49+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
50+
#
51+
# Pods/
52+
53+
# Carthage
3254
#
55+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
56+
# Carthage/Checkouts
57+
58+
Carthage/Build
59+
60+
# fastlane
61+
#
62+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
63+
# screenshots whenever they are needed.
64+
# For more information about the recommended setup visit:
65+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
66+
67+
fastlane/report.xml
68+
fastlane/Preview.html
69+
fastlane/screenshots
70+
fastlane/test_output
3371
Example/Pods/

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
- cd Example
1010
- pod install
1111
- xcodebuild test -workspace RxRetroSwift.xcworkspace -scheme RxRetroSwift-Example -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8' -quiet
12+
- stage: swift package manager
13+
script:
14+
- swift build
1215
- stage: deploy to cocoapods
1316
before_install:
1417
- echo $TRAVIS_TAG

Example/RxRetroSwift.xcodeproj/project.pbxproj

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
607FACD21AFB9204008FA782 /* Example for RxRetroSwift */ = {
106106
isa = PBXGroup;
107107
children = (
108-
A60A3D071FFEA30600A2B078 /* Protocols */,
109108
A60A3D051FFEA2A900A2B078 /* Models */,
110109
A60A3D041FFEA2A300A2B078 /* Services */,
111110
A60A3D031FFEA29900A2B078 /* Extensions */,
@@ -189,13 +188,6 @@
189188
path = Models;
190189
sourceTree = "<group>";
191190
};
192-
A60A3D071FFEA30600A2B078 /* Protocols */ = {
193-
isa = PBXGroup;
194-
children = (
195-
);
196-
path = Protocols;
197-
sourceTree = "<group>";
198-
};
199191
A60A3D131FFFC36D00A2B078 /* RxRetroSwift_Tests */ = {
200192
isa = PBXGroup;
201193
children = (
@@ -318,16 +310,12 @@
318310
);
319311
inputPaths = (
320312
"${SRCROOT}/Pods/Target Support Files/Pods-RxRetroSwift_Example/Pods-RxRetroSwift_Example-frameworks.sh",
321-
"${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework",
322-
"${BUILT_PRODUCTS_DIR}/ObjectMapper/ObjectMapper.framework",
323313
"${BUILT_PRODUCTS_DIR}/RxCocoa/RxCocoa.framework",
324314
"${BUILT_PRODUCTS_DIR}/RxRetroSwift/RxRetroSwift.framework",
325315
"${BUILT_PRODUCTS_DIR}/RxSwift/RxSwift.framework",
326316
);
327317
name = "[CP] Embed Pods Frameworks";
328318
outputPaths = (
329-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework",
330-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectMapper.framework",
331319
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxCocoa.framework",
332320
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxRetroSwift.framework",
333321
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RxSwift.framework",

Example/RxRetroSwift/Services/APIClient.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ fileprivate extension Encodable {
2424
class APIClient {
2525

2626
static var shared = APIClient()
27-
var caller = RequestCaller.shared
27+
28+
lazy var caller:RequestCaller = {
29+
let config = URLSessionConfiguration.default
30+
if #available(iOS 11.0, *) {
31+
config.waitsForConnectivity = true
32+
}
33+
return RequestCaller(config: config)
34+
}()
2835

2936
private init() {
3037

@@ -96,13 +103,14 @@ class APIClient {
96103
return caller.call(request)
97104
}
98105

99-
func isExist(user userId: Int) -> Observable<Result<Bool, ErrorModel>> {
106+
func deleteUser(userId:Int) -> Observable<Result<RawResponse,ErrorModel>> {
100107

101108
let request = RequestModel(
102-
httpMethod: .get,
109+
httpMethod: .delete,
103110
path: "users/\(userId)")
104111
.asURLRequest()
105-
return caller.execute(request)
112+
113+
return caller.call(request)
106114
}
107115
}
108116

Example/RxRetroSwift_Tests/RxRetroSwift_Tests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@ class TestAPIClient:QuickSpec {
6767
let observable = apiClient.fetchUsers()
6868
expect(observable.map { $0.value!.count }).first == 10
6969
}
70-
71-
it("Check a user is exist."){
72-
let observable = apiClient.isExist(user: 1)
73-
expect(observable.map { $0.value! }).first == true
74-
}
75-
76-
it("Check a user is not exist."){
77-
let observable = apiClient.isExist(user: 1010101)
78-
expect(observable.map { $0.error!.errorCode }).first == 404
79-
}
8070
}
8171
}
8272
}

Package.resolved

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version:4.0
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "RxRetroSwift",
8+
products: [
9+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
10+
.library(
11+
name: "RxRetroSwift",
12+
targets: ["RxRetroSwift"]),
13+
],
14+
dependencies: [
15+
// Dependencies declare other packages that this package depends on.
16+
.package(url: "https://github.com/ReactiveX/RxSwift.git", "4.0.0" ..< "5.0.0")
17+
],
18+
targets: [
19+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
21+
.target(
22+
name: "RxRetroSwift",
23+
dependencies: ["RxSwift", "RxCocoa"]),
24+
.testTarget(
25+
name: "RxRetroSwiftTests",
26+
dependencies: ["RxRetroSwift"]),
27+
]
28+
)

RxRetroSwift.podspec

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,8 @@ Pod::Spec.new do |s|
2929
s.author = { 'Michael Henry Pantaleon' => 'me@iamkel.net' }
3030
s.source = { :git => 'https://github.com/michaelhenry/RxRetroSwift.git', :tag => s.version.to_s }
3131
s.social_media_url = 'https://twitter.com/michaelhenry119'
32-
33-
s.ios.deployment_target = '8.0'
34-
35-
s.source_files = 'RxRetroSwift/Classes/**/*'
36-
37-
# s.resource_bundles = {
38-
# 'RxRetroSwift' => ['RxRetroSwift/Assets/*.png']
39-
# }
40-
41-
# s.public_header_files = 'Pod/Classes/**/*.h'
42-
# s.frameworks = 'UIKit', 'MapKit'
43-
# s.dependency 'AFNetworking', '~> 2.3'
32+
s.ios.deployment_target = '9.0'
33+
s.source_files = 'Sources/RxRetroSwift/**/*'
4434
s.dependency 'RxSwift', '~> 4.0'
4535
s.dependency 'RxCocoa', '~> 4.0'
4636
end

RxRetroSwift/Assets/.gitkeep

Whitespace-only changes.

RxRetroSwift/Classes/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)