Skip to content

Commit

Permalink
Merge branch 'release/4.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
heyzooi committed Oct 2, 2019
2 parents f192b69 + 0eba688 commit f6495e3
Show file tree
Hide file tree
Showing 40 changed files with 578 additions and 387 deletions.
15 changes: 11 additions & 4 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
task:
name: macOS
osx_instance:
image: mojave-xcode-10.2
download_dependencies_script: make travisci-cache
image: mojave-xcode-11
download_dependencies_script: make cache
brew_update_script: brew update
install_carthage_script: brew install carthage
xcode_version_script: xcodebuild -version
Expand All @@ -11,10 +11,17 @@ task:
task:
name: iOS
osx_instance:
image: mojave-xcode-10.2
download_dependencies_script: make travisci-cache
image: mojave-xcode-11
download_dependencies_script: make cache
brew_update_script: brew update
install_carthage_script: brew install carthage
xcode_version_script: xcodebuild -version
xcode_show_destinations_script: make show-destinations
test_ios_script: make test-ios

task:
name: macOS SPM
osx_instance:
image: mojave-xcode-11
swift_version_script: swift --version
build_script: swift build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ Carthage
!Carthage/Checkouts/NSPredicate-MongoDB-Adaptor/Sources/MongoDBPredicateAdaptor/*.swift
Kinvey.framework.zip
scripts/RealtimeSend/Rome
Package.resolved
Kinvey.xcodeproj
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode10.2
osx_image: xcode10.3
cache:
directories:
- Carthage
Expand All @@ -24,7 +24,7 @@ before_script:
- carthage version
- xcpretty --version
- if [ ! -d $( md5 Cartfile.resolved | awk '{ print "Carthage/" $4 ".zip" }' ) ]; then
make travisci-cache;
make cache;
fi
- if [ ! -d "Carthage/Checkouts/CwlPreconditionTesting" ] || [ ! -d "Carthage/Checkouts/KeychainAccess" ] || [ ! -d "Carthage/Checkouts/KIF" ] || [ ! -d "Carthage/Checkouts/ObjectMapper" ] || [ ! -d "Carthage/Checkouts/PromiseKit" ] || [ ! -d "Carthage/Checkouts/realm-cocoa" ]; then
carthage checkout;
Expand Down Expand Up @@ -87,4 +87,4 @@ env:
- secure: nawAGSUbPzyAH/SllDj9q6IOLGaF91DQsudQYx4AJs+swwFhAvAe3hM6vWdGVuDLxqVHQ4+4AAQFecXq/mDi5WtRISPbGHWVtOx7Q6szL8Y54uZKVmKV06wnAo4nrwu8pp1+TbRLYwG+/oJIfabW2yuMgNn7nWFm5SdE0GuduVI7Ho9p0/SeaE7DCtaNKgyCLfspAA8svCYMK0N9NzBVhkTPzWRiIF174k5VE28lZox/fjN5x4j1aaMBUhElkJELjcWKdTX11MnCyybWjJZ1YTMK/A4vBtZCFmHIFuhtQiqWCQIWxeo8axRDBZEMzZ5U+9zSfaz0w0wovWI/cvtRFS0j/7UQ4o6alO7EOMdhH5rRl8atOxSS+Rl81Oz1kZiLhjJa/feAN5QGQ423L4CyfDeEBV6t1D8Cmb1jlficswFeX2rQw82qFnI2ua9p8HrpUJydDsGR6AoOI+KUamwi53OC+hsG/M1sA4MOAPEJoMGT6dyER5UVE63JB45All9TDJWV2EZz+11FQIp6P/62/QXJBQhqxu+W0u/3q7KqoSgmxFx/QSbv8hpK9aJWDQNf5cv02bT+vJnMv4Lrf+XcSVOWH0TwpL5nVcRJXyq2A6FCGdE2S0Xa0+KkgZdF7p3qk4jN32CryHImRp8T3qbkA6Q9nNdxATt7P9OjYl/XqDA=
matrix:
- PLATFORM=Mac PLATFORM_ALIAS=osx
- PLATFORM=iOS PLATFORM_ALIAS=ios
- PLATFORM=iOS PLATFORM_ALIAS=ios DESTINATION_OS=12.4 DESTINATION_NAME="iPhone X"
8 changes: 4 additions & 4 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
github "Hearst-DD/ObjectMapper" "3.5.1"
github "Quick/Nimble" "v8.0.4"
github "Quick/Quick" "v2.1.0"
github "SwiftyBeaver/SwiftyBeaver" "1.7.1"
github "Quick/Quick" "v2.2.0"
github "SwiftyBeaver/SwiftyBeaver" "1.8.1"
github "httpswift/swifter" "70355c4e414e93a0589a0d5d4ade342534bbab38"
github "kif-framework/KIF" "v3.7.8"
github "kishikawakatsumi/KeychainAccess" "v3.2.0"
github "mxcl/PromiseKit" "6.11.0"
github "pubnub/objective-c" "v4.10.1"
github "realm/realm-cocoa" "v3.17.3"
github "tjboneman/NSPredicate-MongoDB-Adaptor" "4541dc76f9a24d69416544072e07ac945a40bf9a"
github "realm/realm-cocoa" "v3.19.0"
github "tjboneman/NSPredicate-MongoDB-Adaptor" "fce0cd01913bd4393db0c3dd33404cb7e9ebec88"
github "weichsel/ZIPFoundation" "0.9.9"
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ extension NSPredicate {

extension NSComparisonPredicate {

var keyPathConstantTuple: (keyPathExpression: NSExpression, constantValueExpression: NSExpression)? {
public var keyPathConstantTuple: (keyPathExpression: NSExpression, constantValueExpression: NSExpression)? {
switch leftExpression.expressionType {
case .keyPath:
switch rightExpression.expressionType {
Expand Down
6 changes: 3 additions & 3 deletions Kinvey.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "Kinvey"
s.version = "4.0.0"
s.version = "4.1.0"
s.summary = "Kinvey iOS SDK"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -67,9 +67,9 @@ Pod::Spec.new do |s|
# s.platform = :ios, "9.0"

# When using multiple platforms
s.ios.deployment_target = "10.0"
s.ios.deployment_target = "11.0"
s.osx.deployment_target = "10.12"
s.tvos.deployment_target = "10.0"
s.tvos.deployment_target = "11.0"
s.watchos.deployment_target = "4.0"


Expand Down
16 changes: 4 additions & 12 deletions Kinvey/Kinvey.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@
578B80721EE746EF004D92A6 /* SyncStoreTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5753BB3B1C23F29000EB9D3A /* SyncStoreTests.swift */; };
578B80741EE74E46004D92A6 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57E6BD001EC51F80000E5C52 /* PubNub.framework */; };
578B80761EE876C5004D92A6 /* UserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57E1C3AC1C17EC9500578974 /* UserTests.swift */; };
578D9152233190BF0001152E /* Book.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572005C91D342B2800AE9AC5 /* Book.swift */; };
578D9153233190C20001152E /* Book.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572005C91D342B2800AE9AC5 /* Book.swift */; };
578D9FE41E8DE53900C2B280 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57BEAE2E1C98805E00479206 /* QuartzCore.framework */; };
578D9FE51E8DE53900C2B280 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57BEAE2C1C98805600479206 /* CoreGraphics.framework */; };
578D9FE61E8DE53900C2B280 /* Kinvey.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57A27C811C178F17000DF951 /* Kinvey.framework */; };
Expand Down Expand Up @@ -922,7 +924,6 @@
5706FEC21C1F9A6D0037E7D0 /* StoreTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoreTestCase.swift; sourceTree = "<group>"; };
57089DD61D5CE80D00A36035 /* PullOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullOperation.swift; sourceTree = "<group>"; };
570BD2FC1E845E7A000341C9 /* AggregateOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AggregateOperation.swift; sourceTree = "<group>"; };
5711C46C1C74F52F00073806 /* SaveOperationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveOperationTest.swift; sourceTree = "<group>"; };
57136F621D5D23BF00731DDB /* MockKinveyBackend.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockKinveyBackend.swift; sourceTree = "<group>"; };
5714EBAF1CCECE35001E3ECF /* AclTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AclTestCase.swift; sourceTree = "<group>"; };
5714EBB11CCEEAF9001E3ECF /* RemoveByIdOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoveByIdOperation.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -967,7 +968,6 @@
57373ABE1ECE1849002842CE /* LogTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogTestCase.swift; sourceTree = "<group>"; };
57375F8F1E3FD71D0015A241 /* UploadAndPlayVideoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UploadAndPlayVideoViewController.swift; sourceTree = "<group>"; };
57379DA41C72AAA900E240E9 /* Operation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operation.swift; sourceTree = "<group>"; };
57379DA61C72AE7F00E240E9 /* GetOperationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetOperationTest.swift; sourceTree = "<group>"; };
573851AB1D47C7EB00E4712A /* FileCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileCache.swift; sourceTree = "<group>"; };
573851AD1D47C7F800E4712A /* RealmFileCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmFileCache.swift; sourceTree = "<group>"; };
573CC99C20D19AB900BDF726 /* CacheMigrationTestCaseData.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = CacheMigrationTestCaseData.zip; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1826,8 +1826,6 @@
57882EBF219BF5CA005ECCA3 /* AutoStoreTests.swift */,
57CDF45D22653DBC006596A7 /* AutoDataStoreSpec.swift */,
57A2ED951C4D5F74006D26A9 /* Media.xcassets */,
57379DA61C72AE7F00E240E9 /* GetOperationTest.swift */,
5711C46C1C74F52F00073806 /* SaveOperationTest.swift */,
5781D1301CE3ADBC00369F40 /* ErrorTestCase.swift */,
571BA2601F55D9E600DE1886 /* MyFile.swift */,
5781D1351CE3D0BA00369F40 /* FileTestCase.swift */,
Expand Down Expand Up @@ -3342,6 +3340,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
578D9153233190C20001152E /* Book.swift in Sources */,
57529845226FB1AD002FA614 /* Person.swift in Sources */,
57529847226FB1E4002FA614 /* KinveyTestCase.swift in Sources */,
57529846226FB1C6002FA614 /* KinveyURLProtocol.swift in Sources */,
Expand All @@ -3356,6 +3355,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
578D9152233190BF0001152E /* Book.swift in Sources */,
5752988E226FBADB002FA614 /* MockKinveyBackend.swift in Sources */,
5752988F226FBAFC002FA614 /* KinveyURLProtocol.swift in Sources */,
576B08DA22AEEE8800C22C95 /* MultiInsertSpec.swift in Sources */,
Expand Down Expand Up @@ -4871,18 +4871,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TVOS_DEPLOYMENT_TARGET = 10.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Debug;
};
Expand Down Expand Up @@ -4927,18 +4923,14 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TVOS_DEPLOYMENT_TARGET = 10.0;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Release;
};
Expand Down
106 changes: 85 additions & 21 deletions Kinvey/Kinvey/HttpRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,43 @@ import Foundation
import WatchKit
#endif

struct HeaderField {
enum Encoding: String {

static let userAgent = "User-Agent"
case utf8 = "utf-8"

}

enum MimeType: String {

case applicationJson = "application/json"
case applicationXWWWFormURLEncoded = "application/x-www-form-urlencoded"

}

struct MimeTypeCharset {

let mimeType: MimeType
let encoding: Encoding

init(_ mimeType: MimeType) {
self.init(mimeType: mimeType)
}

init(mimeType: MimeType, encoding: Encoding = .utf8) {
self.mimeType = mimeType
self.encoding = encoding
}

var value: String {
return "\(mimeType.rawValue); charset=\(encoding.rawValue)"
}

}

enum HeaderField: String {

case userAgent = "User-Agent"
case contentType = "Content-Type"

}

Expand Down Expand Up @@ -106,7 +140,7 @@ enum HttpHeader {
case .requestId:
return KinveyHeaderField.requestId.rawValue
case .userAgent:
return HeaderField.userAgent
return HeaderField.userAgent.rawValue
case .deviceInfo:
return KinveyHeaderField.deviceInfo.rawValue
}
Expand All @@ -121,7 +155,7 @@ enum HttpHeader {
case .requestId(let requestId):
return requestId
case .userAgent:
return "Kinvey SDK \(Bundle(for: Client.self).infoDictionary!["CFBundleShortVersionString"]!) (Swift \(swiftVersion))"
return "Kinvey SDK \(Bundle(for: Client.self).infoDictionary?["CFBundleShortVersionString"] ?? "") (Swift \(swiftVersion))"
case .deviceInfo:
let data = try! jsonEncoder.encode(DeviceInfo())
return String(data: data, encoding: .utf8)
Expand Down Expand Up @@ -174,6 +208,46 @@ extension URLRequest {
addValue(value, forHTTPHeaderField: header.rawValue)
}

mutating func setValue<Header: RawRepresentable, Value: RawRepresentable>(_ value: Value?, forHTTPHeaderField header: Header) where Header.RawValue == String, Value.RawValue == String {
setValue(value?.rawValue, forHTTPHeaderField: header.rawValue)
}

mutating func addValue<Header: RawRepresentable, Value: RawRepresentable>(_ value: Value, forHTTPHeaderField header: Header) where Header.RawValue == String, Value.RawValue == String {
addValue(value.rawValue, forHTTPHeaderField: header.rawValue)
}

mutating func setValue(_ mimeType: MimeTypeCharset?) {
setValue(mimeType?.value, forHTTPHeaderField: HeaderField.contentType)
}

mutating func addValue(_ mimeType: MimeTypeCharset) {
addValue(mimeType.value, forHTTPHeaderField: HeaderField.contentType)
}

mutating func setBody(json: JsonDictionary) throws {
setValue(MimeTypeCharset(.applicationJson))
httpBody = try JSONSerialization.data(withJSONObject: json)
}

mutating func setBody(json: [JsonDictionary]) throws {
setValue(MimeTypeCharset(.applicationJson))
httpBody = try JSONSerialization.data(withJSONObject: json)
}

mutating func setBody(xWWWFormURLEncoded: [String : String]) {
setValue(MimeTypeCharset(.applicationXWWWFormURLEncoded))
var paramsKeyValue = [String]()
for (key, value) in xWWWFormURLEncoded {
if let key = key.stringByAddingPercentEncodingForFormData(),
let value = value.stringByAddingPercentEncodingForFormData()
{
paramsKeyValue.append("\(key)=\(value)")
}
}
let httpBody = paramsKeyValue.joined(separator: "&")
self.httpBody = httpBody.data(using: .utf8)
}

func value<Header: RawRepresentable>(forHTTPHeaderField header: Header) -> String? where Header.RawValue == String {
return value(forHTTPHeaderField: header.rawValue)
}
Expand Down Expand Up @@ -231,25 +305,17 @@ public var restApiVersion = defaultRestApiVersion
enum Body {

case json(json: JsonDictionary)
case jsonArray(json: [JsonDictionary])
case formUrlEncoded(params: [String : String])

func attachTo(request: inout URLRequest) {
switch self {
case .json(let json):
request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.httpBody = try! JSONSerialization.data(withJSONObject: json)
try! request.setBody(json: json)
case .jsonArray(let jsonArray):
try! request.setBody(json: jsonArray)
case .formUrlEncoded(let params):
request.setValue("application/x-www-form-urlencoded; charset=utf-8", forHTTPHeaderField: "Content-Type")
var paramsKeyValue = [String]()
for (key, value) in params {
if let key = key.stringByAddingPercentEncodingForFormData(),
let value = value.stringByAddingPercentEncodingForFormData()
{
paramsKeyValue.append("\(key)=\(value)")
}
}
let httpBody = paramsKeyValue.joined(separator: "&")
request.httpBody = httpBody.data(using: .utf8)
request.setBody(xWWWFormURLEncoded: params)
}
}

Expand Down Expand Up @@ -532,13 +598,11 @@ internal class HttpRequest<Result>: TaskProgressRequest, Request {
}

func setBody(json: [String : Any]) {
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try! JSONSerialization.data(withJSONObject: json)
try! request.setBody(json: json)
}

func setBody(json: [[String : Any]]) {
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try! JSONSerialization.data(withJSONObject: json)
try! request.setBody(json: json)
}

}
2 changes: 1 addition & 1 deletion Kinvey/Kinvey/HttpResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct HttpResponse: Response {
}

var contentTypeIsJson: Bool {
guard let contentType = allHeaderFields?["content-type"] as? String else {
guard let contentType = (allHeaderFields?["content-type"] as? String) ?? (allHeaderFields?["Content-Type"] as? String) else {
return false
}
return contentType == "application/json" || contentType.hasPrefix("application/json;")
Expand Down
2 changes: 1 addition & 1 deletion Kinvey/Kinvey/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>4.0.0</string>
<string>4.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 2 additions & 0 deletions Kinvey/Kinvey/Kinvey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ let groupId = "_group_"

#if swift(>=6)
let swiftVersion = "6 or above"
#elseif swift(>=5.1)
let swiftVersion = "5.1"
#elseif swift(>=5.0)
let swiftVersion = "5.0"
#elseif swift(>=4.2.4)
Expand Down
5 changes: 5 additions & 0 deletions Kinvey/Kinvey/Kinvey.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ FRAMEWORK_SEARCH_PATHS[sdk=appletvsimulator*] = $(inherited) $(PROJECT_DIR)/../C
FRAMEWORK_SEARCH_PATHS[sdk=watchos*] = $(inherited) $(PROJECT_DIR)/../Carthage/Build/watchOS
FRAMEWORK_SEARCH_PATHS[sdk=watchsimulator*] = $(inherited) $(PROJECT_DIR)/../Carthage/Build/watchOS

IPHONEOS_DEPLOYMENT_TARGET = 11.0
MACOSX_DEPLOYMENT_TARGET = 10.12
TVOS_DEPLOYMENT_TARGET = 11.0
WATCHOS_DEPLOYMENT_TARGET = 4.0

TARGETED_DEVICE_FAMILY = 1,2,3,4
4 changes: 4 additions & 0 deletions Kinvey/Kinvey/Query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import Foundation
import os
#endif

#if canImport(MongoDBPredicateAdaptor)
import MongoDBPredicateAdaptor
#endif

extension NSPredicate {

internal var asString: String {
Expand Down
Loading

0 comments on commit f6495e3

Please sign in to comment.