Skip to content

Commit

Permalink
Update testables.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mioke committed Jun 7, 2022
1 parent 5f60a2a commit 2a599f8
Show file tree
Hide file tree
Showing 32 changed files with 564 additions and 516 deletions.
10 changes: 8 additions & 2 deletions MIOSwiftyArchitecture.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Pod::Spec.new do |s|
s.author = { 'Mioke Klein' => '[email protected]' }
s.source = { :git => 'https://github.com/Mioke/SwiftArchitectureWithPOP.git', :tag => s.version.to_s }

s.ios.deployment_target = '11.0'
s.ios.deployment_target = '13.0'
s.swift_versions = '5.0'

# s.frameworks = 'UIKit', 'Foundation'
Expand Down Expand Up @@ -58,6 +58,7 @@ Pod::Spec.new do |s|
ss.source_files = 'SwiftyArchitecture/Base/AppDocker/**/*.swift'
ss.dependency 'MIOSwiftyArchitecture/Assistance'
ss.dependency 'MIOSwiftyArchitecture/Networking'
ss.dependency 'MIOSwiftyArchitecture/RxExtension'
ss.dependency 'RxSwift', '~> 6.2'
ss.dependency 'RxRealm', '~> 5.0'
ss.dependency 'RealmSwift', '~> 10.20.0'
Expand All @@ -66,14 +67,16 @@ Pod::Spec.new do |s|

s.subspec 'Componentize' do |ss|
ss.source_files = 'SwiftyArchitecture/Base/Componentize/**/*.swift'
ss.dependency 'Swinject', '~> 2.8'
ss.dependency 'MIOSwiftyArchitecture/Assistance'
ss.dependency 'Swinject', '~> 2.8'
ss.dependency 'RxSwift', '~> 6.2'
end

s.subspec 'Testable' do |ss|
ss.source_files = 'SwiftyArchitecture/Base/Testable/**/*.swift'
ss.dependency 'MIOSwiftyArchitecture/Assistance'
ss.dependency 'MIOSwiftyArchitecture/Networking'
ss.dependency 'MIOSwiftyArchitecture/RxExtension'
ss.dependency 'MIOSwiftyArchitecture/AppDocker'
ss.dependency 'MIOSwiftyArchitecture/Componentize'
end
Expand All @@ -83,9 +86,12 @@ Pod::Spec.new do |s|
# test_spec.dependency 'OCMock' # This dependency will only be linked with your tests.
test_spec.dependency 'MIOSwiftyArchitecture/Assistance'
test_spec.dependency 'MIOSwiftyArchitecture/Networking'
test_spec.dependency 'MIOSwiftyArchitecture/RxExtension'
test_spec.dependency 'MIOSwiftyArchitecture/AppDocker'
test_spec.dependency 'MIOSwiftyArchitecture/Componentize'
test_spec.dependency 'MIOSwiftyArchitecture/Testable'

test_spec.dependency 'RxSwift', '~> 6.2'
end

# s.xcconfig = { "SWIFT_OBJC_BRIDGING_HEADER" => "SwiftyArchitecture/Resource/swiftArchitecture-Bridging-Header.h" }
Expand Down
8 changes: 1 addition & 7 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '15.0'
use_frameworks!
install! 'cocoapods', :preserve_pod_file_structure => true

target "SAD" do
# networking
Expand All @@ -21,13 +22,6 @@ target "SAD" do
pod 'MIOSwiftyArchitecture/Testable', :path => './'


# kits for demo
# pod 'YYModel'

# pod 'ReactiveCocoa'
# pod "AFNetworking"

# pod "KMCache"

# componentize
pod 'Application', :path => './ComponentizeDemo/Application'
Expand Down
43 changes: 25 additions & 18 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PODS:
- ApplicationProtocol (0.0.1):
- MIOSwiftyArchitecture
- Auth (0.0.1):
- ApplicationProtocol
- AuthProtocol
- MIOSwiftyArchitecture
- AuthProtocol (0.0.1):
Expand All @@ -15,45 +16,51 @@ PODS:
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- MIOSwiftyArchitecture (1.0.2):
- MIOSwiftyArchitecture/AppDocker (= 1.0.2)
- MIOSwiftyArchitecture/Assistance (= 1.0.2)
- MIOSwiftyArchitecture/Componentize (= 1.0.2)
- MIOSwiftyArchitecture/Networking (= 1.0.2)
- MIOSwiftyArchitecture/Persistance (= 1.0.2)
- MIOSwiftyArchitecture/RxExtension (= 1.0.2)
- MIOSwiftyArchitecture/AppDocker (1.0.2):
- MIOSwiftyArchitecture (2.0.0):
- MIOSwiftyArchitecture/AppDocker (= 2.0.0)
- MIOSwiftyArchitecture/Assistance (= 2.0.0)
- MIOSwiftyArchitecture/Componentize (= 2.0.0)
- MIOSwiftyArchitecture/Networking (= 2.0.0)
- MIOSwiftyArchitecture/Persistance (= 2.0.0)
- MIOSwiftyArchitecture/RxExtension (= 2.0.0)
- MIOSwiftyArchitecture/AppDocker (2.0.0):
- MIOSwiftyArchitecture/Assistance
- MIOSwiftyArchitecture/Networking
- MIOSwiftyArchitecture/RxExtension
- Realm (~> 10.20.0)
- RealmSwift (~> 10.20.0)
- RxRealm (~> 5.0)
- RxSwift (~> 6.2)
- MIOSwiftyArchitecture/Assistance (1.0.2)
- MIOSwiftyArchitecture/Componentize (1.0.2):
- MIOSwiftyArchitecture/Assistance (2.0.0)
- MIOSwiftyArchitecture/Componentize (2.0.0):
- MIOSwiftyArchitecture/Assistance
- RxSwift (~> 6.2)
- Swinject (~> 2.8)
- MIOSwiftyArchitecture/Networking (1.0.2):
- MIOSwiftyArchitecture/Networking (2.0.0):
- Alamofire (~> 5.4)
- MIOSwiftyArchitecture/Assistance
- ObjectMapper (~> 4.2)
- MIOSwiftyArchitecture/Persistance (1.0.2):
- MIOSwiftyArchitecture/Persistance (2.0.0):
- FMDB
- MIOSwiftyArchitecture/Assistance
- MIOSwiftyArchitecture/RxExtension (1.0.2):
- MIOSwiftyArchitecture/RxExtension (2.0.0):
- MIOSwiftyArchitecture/Assistance
- MIOSwiftyArchitecture/Networking
- RxSwift (~> 6.2)
- MIOSwiftyArchitecture/Testable (1.0.2):
- MIOSwiftyArchitecture/Testable (2.0.0):
- MIOSwiftyArchitecture/AppDocker
- MIOSwiftyArchitecture/Assistance
- MIOSwiftyArchitecture/Componentize
- MIOSwiftyArchitecture/Networking
- MIOSwiftyArchitecture/Tests (1.0.2):
- MIOSwiftyArchitecture/RxExtension
- MIOSwiftyArchitecture/Tests (2.0.0):
- MIOSwiftyArchitecture/AppDocker
- MIOSwiftyArchitecture/Assistance
- MIOSwiftyArchitecture/Componentize
- MIOSwiftyArchitecture/Networking
- MIOSwiftyArchitecture/RxExtension
- MIOSwiftyArchitecture/Testable
- RxSwift (~> 6.2)
- ObjectMapper (4.2.0)
- Realm (10.20.1):
- Realm/Headers (= 10.20.1)
Expand Down Expand Up @@ -128,11 +135,11 @@ SPEC CHECKSUMS:
Alamofire: 1c4fb5369c3fe93d2857c780d8bbe09f06f97e7c
Application: dd4fd31f4118552d2623f56cb55ab79f4db07853
ApplicationProtocol: 3270de550fcbb5ad68ebdf9b42245159d51b0e77
Auth: fe82b6cdf4397decf9672755ede649caa9aef67e
Auth: 5659f3a716fb6e046dac47c6b0000c259233eb4e
AuthProtocol: 699414ec99eb060731d49ec1092901fc1ae55e3e
Differentiator: e8497ceab83c1b10ca233716d547b9af21b9344d
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
MIOSwiftyArchitecture: 04be5fdfbd1794ef2f9789f03756d8c535d4a407
MIOSwiftyArchitecture: 013b955874684ff4ec74401c6400746b29a5b96a
ObjectMapper: 1eb41f610210777375fa806bf161dc39fb832b81
Realm: fac5ecd031fcb81171627b74944c885662d4b266
RealmSwift: 9b02d25acb46a14756bde9893abb99e2e3675923
Expand All @@ -144,6 +151,6 @@ SPEC CHECKSUMS:
Swinject: 97112918bd7e0785dc2df7036213f3c8cbba6586
SwinjectAutoregistration: 330f5012642a8b5c89a8a4adb0c5e52df07382c0

PODFILE CHECKSUM: 66466cf7b78a70dd1be8410a106ee79e9058df94
PODFILE CHECKSUM: 23aa4b542c2b826493aa87894612c1f3f494821c

COCOAPODS: 1.11.3
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,28 @@ Download `.zip` package and copy the `SwiftyArchitecture/Base` folder into you p

- **Server**

Provide some basic functionality of a server like onlieURL, offlineURL, isOnline etc. In test Mode, offline the server.
Provide some basic functionalities of a server like url configuation, environments switch etc. In test Mode, offline the server.
```swift
let server: Server = .init(live: cdn.config.liveURL,
customEnvironments: [
.custom("Dev"): cdn.config.devURL,
.custom("Staging"): cdn.config.stagingURL,
])
#if DEBUG
Server.online = false
server.switch(to: .custom("Dev"))
#endif
```

You can comstomize the operation of dealing response data now, just subclass from `Server` and conform to protocol `ServerDataProcessProtocol` like:
```swift
func handle(data: Any) throws -> Void {

if let dic = data as? [String: Any],
let errorCode = dic["error_code"] as? Int,
errorCode != 0 {
       throw NSError(domain: kYourErrorDomain, code: errorCode, userInfo: [NSLocalizedDescriptionKey: message])
if let dic = data as? [String: Any],
let errorCode = dic["error_code"] as? Int,
errorCode != 0 {
       throw NSError(domain: kYourErrorDomain,
code: errorCode,
userInfo: [NSLocalizedDescriptionKey: message])
   }
}
```
Expand All @@ -60,9 +67,11 @@ func handle(data: Any) throws -> Void {
var server: Server {
get { return mainServer }
}

typealias ResultType = _User
static var responseSerializer: MIOSwiftyArchitecture.ResponseSerializer<User> {
return MIOSwiftyArchitecture.JSONResponseSerializer<User>()

static var responseSerializer: ResponseSerializer<_User> {
return JSONResponseSerializer<_User>()
}
```
The API provide some basic method like:
Expand Down Expand Up @@ -326,7 +335,7 @@ So, this function should depend on the situation of your team. `;)`

- Custom extensions and categories.
- UI relevant class for easy accessing global UI settings.
- `SystemLog` can write log to files, and stored in sandbox.
- ~~`SystemLog` can write log to files, and stored in sandbox.~~ (Refactoring)

> Almost done `>w<!`
Expand Down
2 changes: 1 addition & 1 deletion SwiftyArchitecture/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// AFNetworkActivityIndicatorManager.sharedManager().enabled = true

#if DEBUG
Server.online = false
try? MioDemoServer.switch(to: "DEV")
#endif

let root = InternalTestVC()
Expand Down
7 changes: 3 additions & 4 deletions SwiftyArchitecture/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -37,7 +36,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="22" y="125"/>
<point key="canvasLocation" x="-662" y="66"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,15 @@

import Foundation

public let AppDockerDomain = "com.mioke.appdocker"

public struct AppDockerError {
struct Info {
let code: Int
let message: String
}
public extension Consts {
static let appDockerDomain = "com.mioke.swiftyarchitecture.appdocker"
}

extension AppDockerError {
public extension KitErrors {
private static var noDelegate: Info {
.init(code: 1, message: "The delegate of this function hasn't been set yet.")
.init(code: .noDelegate, message: "The delegate of this function hasn't been set yet.")
}
public static let noDelegateError: NSError = error(info: noDelegate)
static let noDelegateError: NSError = error(domain: Consts.appDockerDomain, info: noDelegate)
}

// MARK: - Convenience & Private

func error(info: AppDockerError.Info) -> NSError {
return .init(
domain: AppDockerDomain,
code: info.code,
userInfo: [NSLocalizedDescriptionKey: info.message]
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class AuthController: NSObject {

func auth(appContext: AppContext) throws -> Observable<Void> {
guard let delegate = delegate else {
throw AppDockerError.noDelegateError
throw KitErrors.noDelegateError
}
return delegate.authenticate().flatMapLatest {
return self.changeUserState(to: .authenticated, appContext: appContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ extension DataAccessObject where T: DataCenterManaged {

}

final public class Request<T: Object> : NSObject {
final public class Request<T: DataCenterManaged> : NSObject {

public var params: [String: Any]?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct RequestRecordNode {
let requestTime: CFAbsoluteTime
let freshness: RequestFreshness

var expirationtime: CFAbsoluteTime {
var expirationDate: CFAbsoluteTime {
guard case .seconds(let seconds) = freshness else {
return 0
}
Expand Down Expand Up @@ -53,7 +53,7 @@ internal class RequestRecords: NSObject {
guard let info = self.last(ofRequest: request) else {
return true
}
let should = info.node.expirationtime < CFAbsoluteTimeGetCurrent()
let should = info.node.expirationDate < CFAbsoluteTimeGetCurrent()
if should {
map[info.key] = nil
}
Expand Down

This file was deleted.

Loading

0 comments on commit 2a599f8

Please sign in to comment.