Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #13 from bricklife/spm
Browse files Browse the repository at this point in the history
Swift Package Manager
  • Loading branch information
Shinichiro Oba authored Jan 18, 2018
2 parents 82e32fc + 3bdb477 commit 2ddb6c8
Show file tree
Hide file tree
Showing 26 changed files with 182 additions and 59 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ DerivedData
# Carthage/Checkouts

Carthage/Build

# Swift Package Manager

.build
46 changes: 40 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
language: objective-c
osx_image: xcode7.3

env:
global:
- LC_CTYPE=en_US.UTF-8

branches:
only:
- master

script:
- xcodebuild test -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit-iOS -sdk iphonesimulator | xcpretty -c
- xcodebuild build -workspace JSONRPCKit.xcworkspace -scheme Example -sdk iphonesimulator | xcpretty -c
matrix:
include:
- os: osx
osx_image: xcode9
language: objective-c
env:
- JOB=Xcode
script:
- set -o pipefail
- xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit | xcpretty -c
- xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk iphonesimulator -destination "name=iPhone SE" | xcpretty -c
- xcodebuild build-for-testing test-without-building -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk appletvsimulator -destination "name=Apple TV 1080p" | xcpretty -c
- xcodebuild build -workspace JSONRPCKit.xcworkspace -scheme JSONRPCKit -sdk watchsimulator | xcpretty -c
- pod lib lint
- os: osx
osx_image: xcode9
language: generic
env:
- JOB=SPM
script:
- swift --version
- swift build
- swift test
- os: linux
language: generic
env:
- JOB=Linux
- SWIFT_VERSION=4.0.3
script:
- swift --version
- swift build
- swift test
sudo: required
dist: trusty
install:
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"

notifications:
email: false
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "antitypical/Result" ~> 3.2
github "antitypical/Result" ~> 3.2.0
2 changes: 1 addition & 1 deletion Cartfile.private
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "ishkawa/APIKit" ~> 3.2
github "ishkawa/APIKit" ~> 3.2.0
4 changes: 2 additions & 2 deletions Example/Example/SingleRequestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import JSONRPCKit

public struct StringIdGenerator: IdGenerator {

fileprivate var currentId = 1
private var currentId = 1

public mutating func next() -> Id {
defer {
Expand All @@ -29,7 +29,7 @@ class SingleRequestViewController: UIViewController {
@IBOutlet weak var secondTextField: UITextField!
@IBOutlet weak var subtractAnswerLabel: UILabel!

let batchFactory = BatchFactory()
let batchFactory = BatchFactory(idGenerator: StringIdGenerator())

func subtract(_ first: Int, _ second: Int) {
let divideRequest = Divide(
Expand Down
6 changes: 3 additions & 3 deletions JSONRPCKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "JSONRPCKit"
s.version = "2.0.1"
s.version = "3.0.0"
s.summary = "JSONRPCKit is a JSON-RPC 2.0 library purely written in Swift."
s.homepage = "https://github.com/bricklife/JSONRPCKit"

Expand All @@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.watchos.deployment_target = "2.0"
s.tvos.deployment_target = "9.0"

s.source_files = "JSONRPCKit/*.{swift,h,m}"
s.source_files = "Sources/JSONRPCKit/*.{swift,h,m}"
s.source = {
:git => "https://github.com/bricklife/JSONRPCKit.git",
:tag => "#{s.version}",
Expand All @@ -28,6 +28,6 @@ Pod::Spec.new do |s|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LICENSE
}
s.dependency "Result", "~> 3.2"
s.dependency "Result", "~> 3.2.0"

end
59 changes: 39 additions & 20 deletions JSONRPCKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
7FC654F81D48B6CB004C390C /* Batch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FC654F61D48B6CB004C390C /* Batch.swift */; };
7FC654F91D48B6CB004C390C /* BatchElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FC654F71D48B6CB004C390C /* BatchElement.swift */; };
7FC654FB1D49DF27004C390C /* BatchFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FC654FA1D49DF27004C390C /* BatchFactory.swift */; };
7FC655051D49EA19004C390C /* JSONRPCKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CBB0C34E1BF0B1D6006A7D41 /* JSONRPCKit.framework */; };
7FC6550C1D49FA20004C390C /* TestRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FC6550B1D49FA20004C390C /* TestRequest.swift */; };
7FD0A33D1D4B4024007C9EAB /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB31EFB91CF6E8FE00DD13DD /* Result.framework */; };
CB31EFBA1CF6E8FE00DD13DD /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB31EFB91CF6E8FE00DD13DD /* Result.framework */; };
Expand Down Expand Up @@ -40,7 +39,7 @@
7FC654F61D48B6CB004C390C /* Batch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Batch.swift; sourceTree = "<group>"; };
7FC654F71D48B6CB004C390C /* BatchElement.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BatchElement.swift; sourceTree = "<group>"; };
7FC654FA1D49DF27004C390C /* BatchFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BatchFactory.swift; sourceTree = "<group>"; };
7FC655001D49EA19004C390C /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7FC655001D49EA19004C390C /* JSONRPCKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JSONRPCKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7FC655041D49EA19004C390C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7FC6550B1D49FA20004C390C /* TestRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestRequest.swift; sourceTree = "<group>"; };
CB31EFB91CF6E8FE00DD13DD /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Result.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -60,7 +59,6 @@
buildActionMask = 2147483647;
files = (
7FD0A33D1D4B4024007C9EAB /* Result.framework in Frameworks */,
7FC655051D49EA19004C390C /* JSONRPCKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -75,15 +73,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
7FC655011D49EA19004C390C /* Tests */ = {
7FC655011D49EA19004C390C /* JSONRPCKitTests */ = {
isa = PBXGroup;
children = (
7FC6550B1D49FA20004C390C /* TestRequest.swift */,
7F359B751D4B1A1100032E8D /* BatchElementTests.swift */,
7F359B771D4B1B0500032E8D /* BatchFactoryTests.swift */,
7FC655041D49EA19004C390C /* Info.plist */,
);
path = Tests;
path = JSONRPCKitTests;
sourceTree = "<group>";
};
CB63E2391CE22F7E00E22B5C /* Frameworks */ = {
Expand All @@ -94,11 +92,27 @@
name = Frameworks;
sourceTree = "<group>";
};
CBB0C3441BF0B1D5006A7D41 = {
CB7B4D4F2010BB1800AEB6FF /* Sources */ = {
isa = PBXGroup;
children = (
CBB0C3501BF0B1D6006A7D41 /* JSONRPCKit */,
7FC655011D49EA19004C390C /* Tests */,
);
path = Sources;
sourceTree = "<group>";
};
CB7B4D502010BB4400AEB6FF /* Tests */ = {
isa = PBXGroup;
children = (
7FC655011D49EA19004C390C /* JSONRPCKitTests */,
);
path = Tests;
sourceTree = "<group>";
};
CBB0C3441BF0B1D5006A7D41 = {
isa = PBXGroup;
children = (
CB7B4D4F2010BB1800AEB6FF /* Sources */,
CB7B4D502010BB4400AEB6FF /* Tests */,
CBB0C34F1BF0B1D6006A7D41 /* Products */,
CB63E2391CE22F7E00E22B5C /* Frameworks */,
);
Expand All @@ -108,7 +122,7 @@
isa = PBXGroup;
children = (
CBB0C34E1BF0B1D6006A7D41 /* JSONRPCKit.framework */,
7FC655001D49EA19004C390C /* Tests.xctest */,
7FC655001D49EA19004C390C /* JSONRPCKitTests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -144,9 +158,9 @@
/* End PBXHeadersBuildPhase section */

/* Begin PBXNativeTarget section */
7FC654FF1D49EA19004C390C /* Tests */ = {
7FC654FF1D49EA19004C390C /* JSONRPCKitTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 7FC655081D49EA19004C390C /* Build configuration list for PBXNativeTarget "Tests" */;
buildConfigurationList = 7FC655081D49EA19004C390C /* Build configuration list for PBXNativeTarget "JSONRPCKitTests" */;
buildPhases = (
7FC654FC1D49EA19004C390C /* Sources */,
7FC654FD1D49EA19004C390C /* Frameworks */,
Expand All @@ -157,9 +171,9 @@
dependencies = (
7FC655071D49EA19004C390C /* PBXTargetDependency */,
);
name = Tests;
name = JSONRPCKitTests;
productName = Tests;
productReference = 7FC655001D49EA19004C390C /* Tests.xctest */;
productReference = 7FC655001D49EA19004C390C /* JSONRPCKitTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
CBB0C34D1BF0B1D6006A7D41 /* JSONRPCKit */ = {
Expand Down Expand Up @@ -214,7 +228,7 @@
projectRoot = "";
targets = (
CBB0C34D1BF0B1D6006A7D41 /* JSONRPCKit */,
7FC654FF1D49EA19004C390C /* Tests */,
7FC654FF1D49EA19004C390C /* JSONRPCKitTests */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -277,8 +291,11 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
INFOPLIST_FILE = Tests/JSONRPCKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "";
"LD_RUNPATH_SEARCH_PATHS[sdk=appletv*]" = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=iphone*]" = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "-.Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
Expand All @@ -289,8 +306,10 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
INFOPLIST_FILE = Tests/JSONRPCKitTests/Info.plist;
"LD_RUNPATH_SEARCH_PATHS[sdk=appletv*]" = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=iphone*]" = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "-.Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
Expand Down Expand Up @@ -415,7 +434,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = JSONRPCKit/Info.plist;
INFOPLIST_FILE = Sources/JSONRPCKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=appletv*]" = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand All @@ -438,7 +457,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = JSONRPCKit/Info.plist;
INFOPLIST_FILE = Sources/JSONRPCKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=appletv*]" = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand All @@ -455,7 +474,7 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
7FC655081D49EA19004C390C /* Build configuration list for PBXNativeTarget "Tests" */ = {
7FC655081D49EA19004C390C /* Build configuration list for PBXNativeTarget "JSONRPCKitTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
7FC655091D49EA19004C390C /* Debug */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7FC654FF1D49EA19004C390C"
BuildableName = "Tests.xctest"
BlueprintName = "Tests"
BuildableName = "JSONRPCKitTests.xctest"
BlueprintName = "JSONRPCKitTests"
ReferencedContainer = "container:JSONRPCKit.xcodeproj">
</BuildableReference>
</TestableReference>
Expand Down
16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "Result",
"repositoryURL": "https://github.com/antitypical/Result.git",
"state": {
"branch": null,
"revision": "7477584259bfce2560a19e06ad9f71db441fff11",
"version": "3.2.4"
}
}
]
},
"version": 1
}
19 changes: 19 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "JSONRPCKit",
products: [
.library(name: "JSONRPCKit", targets: ["JSONRPCKit"]),
],
dependencies: [
.package(url: "https://github.com/antitypical/Result.git", from: "3.2.0"),
],
targets: [
.target(name: "JSONRPCKit", dependencies: ["Result"]),
.testTarget(name: "JSONRPCKitTests", dependencies: ["JSONRPCKit"]),
],
swiftLanguageVersions: [4]
)
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# JSONRPCKit

[![Build Status](https://travis-ci.org/bricklife/JSONRPCKit.svg?branch=master)](https://travis-ci.org/bricklife/JSONRPCKit)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![CocoaPods](https://img.shields.io/cocoapods/v/JSONRPCKit.svg)](https://cocoapods.org/)

JSONRPCKit is a [JSON-RPC 2.0](http://www.jsonrpc.org/specification) library purely written in Swift.

```swift
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,23 @@ public struct BatchElement<Request: JSONRPCKit.Request>: BatchElementProcotol {

public init(request: Request, version: String, id: Id) {
let id: Id? = request.isNotification ? nil : id

var body: [String: Any] = [
"jsonrpc": version as Any,
"method": request.method as Any,
"jsonrpc": version,
"method": request.method,
]

if let id = id {
body["id"] = id.value
}

if let parameters = request.parameters {
body["params"] = parameters
}

request.extendedFields?.forEach { key, value in

body["id"] = id?.value
body["params"] = request.parameters

request.extendedFields?.forEach { (key, value) in
body[key] = value
}

self.request = request
self.version = version
self.id = id
self.body = body as Any
self.body = body
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class BatchFactory {
public let version: String
public var idGenerator: IdGenerator

fileprivate let semaphore = DispatchSemaphore(value: 1)
private let semaphore = DispatchSemaphore(value: 1)

public init(version: String = "2.0", idGenerator: IdGenerator = NumberIdGenerator()) {
self.version = version
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion JSONRPCKit/Info.plist → Sources/JSONRPCKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0.1</string>
<string>3.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 2ddb6c8

Please sign in to comment.