Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 42e09b3

Browse files
committed
Merge branch 'release/3.7.1'
2 parents d17b225 + 10c84a4 commit 42e09b3

13 files changed

+189
-29
lines changed

.codeclimate.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
engines:
3+
tailor:
4+
enabled: true
5+
fixme:
6+
enabled: true
7+
ratings:
8+
paths:
9+
- "**.swift"
10+
exclude_paths:
11+
- "Kinvey/KinveyTests/"
12+
- "Kinvey/KinveyApp/"
13+
- "Kinvey/RealtimeSender/"
14+
- "devtools/"
15+
- "Tools/"
16+
- "scripts/"
17+
- "DocTemplates/"

Kinvey.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "Kinvey"
19-
s.version = "3.7.0"
19+
s.version = "3.7.1"
2020
s.summary = "Kinvey iOS SDK"
2121

2222
# This description is used to generate tags and improve search results.

Kinvey/Kinvey.xcodeproj/project.pbxproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
572005CA1D342B2800AE9AC5 /* Book.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572005C91D342B2800AE9AC5 /* Book.swift */; };
3535
5726321E1EE99C940082A1A8 /* SongRecommendation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5726321D1EE99C940082A1A8 /* SongRecommendation.swift */; };
3636
572632251EE9A2A10082A1A8 /* SongRecommendation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5726321D1EE99C940082A1A8 /* SongRecommendation.swift */; };
37+
572709B11F50BD70002DE5A4 /* RealtimeAclTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572709B01F50BD70002DE5A4 /* RealtimeAclTestCase.swift */; };
38+
572709B21F50BD78002DE5A4 /* RealtimeAclTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572709B01F50BD70002DE5A4 /* RealtimeAclTestCase.swift */; };
3739
5728212D1C63E0F500373EC8 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5728212C1C63E0F500373EC8 /* File.swift */; };
3840
5728212F1C63E10700373EC8 /* FileStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5728212E1C63E10700373EC8 /* FileStore.swift */; };
3941
5728213B1C6482C000373EC8 /* URLSessionTaskRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5728213A1C6482C000373EC8 /* URLSessionTaskRequest.swift */; };
@@ -81,9 +83,9 @@
8183
5765B8641C97751000080FFA /* Kinvey.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57A27C811C178F17000DF951 /* Kinvey.framework */; };
8284
576A1D361CCA92CA006B261E /* DataTypeTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 576A1D351CCA92CA006B261E /* DataTypeTestCase.swift */; };
8385
576E95A41C1FB10700258CC3 /* DataStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 576E95A31C1FB10700258CC3 /* DataStore.swift */; };
86+
576F1E821F1958E600C854CE /* PerformanceTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5706231F1F1825CA00B7FAE9 /* PerformanceTest.swift */; };
8487
57711A921F27BD730044C533 /* KinveyTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57A27C901C178F18000DF951 /* KinveyTestCase.swift */; };
8588
57711A931F27BF650044C533 /* MockKinveyBackend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57136F621D5D23BF00731DDB /* MockKinveyBackend.swift */; };
86-
576F1E821F1958E600C854CE /* PerformanceTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5706231F1F1825CA00B7FAE9 /* PerformanceTest.swift */; };
8789
577155511CA0F1D200C91B4B /* StoreTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5706FEC21C1F9A6D0037E7D0 /* StoreTestCase.swift */; };
8890
577155521CA0F1D400C91B4B /* FindOperationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5765B8351C92365700080FFA /* FindOperationTest.swift */; };
8991
577155BB1CA21CC200C91B4B /* Migration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 577155BA1CA21CC200C91B4B /* Migration.swift */; };
@@ -718,6 +720,7 @@
718720
571991081CB45EEE00070CDA /* Person.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Person.swift; sourceTree = "<group>"; };
719721
572005C91D342B2800AE9AC5 /* Book.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Book.swift; sourceTree = "<group>"; };
720722
5726321D1EE99C940082A1A8 /* SongRecommendation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SongRecommendation.swift; sourceTree = "<group>"; };
723+
572709B01F50BD70002DE5A4 /* RealtimeAclTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealtimeAclTestCase.swift; sourceTree = "<group>"; };
721724
5728212C1C63E0F500373EC8 /* File.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
722725
5728212E1C63E10700373EC8 /* FileStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileStore.swift; sourceTree = "<group>"; };
723726
5728213A1C6482C000373EC8 /* URLSessionTaskRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLSessionTaskRequest.swift; sourceTree = "<group>"; };
@@ -1456,6 +1459,7 @@
14561459
5771CD741ECFE9B60057E505 /* MetadataTestCase.swift */,
14571460
5754DDBC1EAEBC4A00122A7A /* DateTestCase.swift */,
14581461
57E6BD451EC64D1D000E5C52 /* RealtimeTestCase.swift */,
1462+
572709B01F50BD70002DE5A4 /* RealtimeAclTestCase.swift */,
14591463
);
14601464
path = KinveyTests;
14611465
sourceTree = "<group>";
@@ -2557,6 +2561,7 @@
25572561
578B80651EE74613004D92A6 /* FindOperationTest.swift in Sources */,
25582562
578B80721EE746EF004D92A6 /* SyncStoreTests.swift in Sources */,
25592563
578B80601EE74355004D92A6 /* URLProtocols.swift in Sources */,
2564+
572709B21F50BD78002DE5A4 /* RealtimeAclTestCase.swift in Sources */,
25602565
578B806E1EE746CB004D92A6 /* PersistableTestCase.swift in Sources */,
25612566
578B80691EE746B2004D92A6 /* LogTestCase.swift in Sources */,
25622567
578B80681EE74677004D92A6 /* RefProject.swift in Sources */,
@@ -2814,6 +2819,7 @@
28142819
571991071CB45EC400070CDA /* SyncStoreTests.swift in Sources */,
28152820
578F5C931C99EED100B20F17 /* KIF.swift in Sources */,
28162821
57E516391E9C3BE600A2AAD3 /* ClientTestCase.swift in Sources */,
2822+
572709B11F50BD70002DE5A4 /* RealtimeAclTestCase.swift in Sources */,
28172823
577155521CA0F1D400C91B4B /* FindOperationTest.swift in Sources */,
28182824
575465A41E66405D0063B4B6 /* PerformanceProductTestCase.swift in Sources */,
28192825
5796B3E71DEE8EC900209C9F /* CacheStoreTests.swift in Sources */,

Kinvey/Kinvey/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.7.0</string>
18+
<string>3.7.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Kinvey/Kinvey/ObjCRuntime.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ internal class ObjCRuntime: NSObject {
2828
let property = class_getProperty(cls, propertyName)
2929
let attributeValueCString = property_copyAttributeValue(property, "T")
3030
defer { free(attributeValueCString) }
31-
if let attributeValue = String(validatingUTF8: attributeValueCString!),
31+
if let attributeValueCString = attributeValueCString,
32+
let attributeValue = String(validatingUTF8: attributeValueCString),
3233
let textCheckingResult = regexClassName.matches(in: attributeValue, range: NSMakeRange(0, attributeValue.characters.count)).first
3334
{
3435
let attributeValueNSString = attributeValue as NSString

Kinvey/Kinvey/Persistable.swift

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,11 @@ class ListValueTransform<T: RealmSwift.Object>: TransformOf<List<T>, [JsonDictio
191191

192192
/// Overload operator for `List` values
193193
public func <-<T: BaseMappable>(lhs: List<T>, rhs: (String, Map)) {
194-
let (_, map) = rhs
194+
let (right, map) = rhs
195195
var list = lhs
196-
switch map.mappingType {
197-
case .fromJSON:
198-
list <- (map, ListValueTransform<T>(list))
199-
case .toJSON:
200-
list <- (map, ListValueTransform<T>(list))
201-
}
196+
let transform = ListValueTransform<T>(list)
197+
kinveyMappingType(left: right, right: map.currentKey!, transform: transform)
198+
list <- (map, transform)
202199
}
203200

204201
// MARK: String Value Transform
@@ -226,13 +223,14 @@ class StringValueTransform: TransformOf<List<StringValue>, [String]> {
226223
/// Override operator used during the `propertyMapping(_:)` method.
227224
public func <- (left: List<StringValue>, right: (String, Map)) {
228225
let (right, map) = right
229-
kinveyMappingType(left: right, right: map.currentKey!)
226+
let transform = StringValueTransform()
227+
kinveyMappingType(left: right, right: map.currentKey!, transform: transform)
230228
var list = left
231229
switch map.mappingType {
232230
case .toJSON:
233-
list <- (map, StringValueTransform())
231+
list <- (map, transform)
234232
case .fromJSON:
235-
list <- (map, StringValueTransform())
233+
list <- (map, transform)
236234
left.removeAll()
237235
left.append(objectsIn: list)
238236
}
@@ -263,13 +261,14 @@ class IntValueTransform: TransformOf<List<IntValue>, [Int]> {
263261
/// Override operator used during the `propertyMapping(_:)` method.
264262
public func <- (left: List<IntValue>, right: (String, Map)) {
265263
let (right, map) = right
266-
kinveyMappingType(left: right, right: map.currentKey!)
264+
let transform = IntValueTransform()
265+
kinveyMappingType(left: right, right: map.currentKey!, transform: transform)
267266
var list = left
268267
switch map.mappingType {
269268
case .toJSON:
270-
list <- (map, IntValueTransform())
269+
list <- (map, transform)
271270
case .fromJSON:
272-
list <- (map, IntValueTransform())
271+
list <- (map, transform)
273272
left.removeAll()
274273
left.append(objectsIn: list)
275274
}
@@ -306,13 +305,14 @@ class FloatValueTransform: TransformOf<List<FloatValue>, [Float]> {
306305
/// Override operator used during the `propertyMapping(_:)` method.
307306
public func <- (left: List<FloatValue>, right: (String, Map)) {
308307
let (right, map) = right
309-
kinveyMappingType(left: right, right: map.currentKey!)
308+
let transform = FloatValueTransform()
309+
kinveyMappingType(left: right, right: map.currentKey!, transform: transform)
310310
var list = left
311311
switch map.mappingType {
312312
case .toJSON:
313-
list <- (map, FloatValueTransform())
313+
list <- (map, transform)
314314
case .fromJSON:
315-
list <- (map, FloatValueTransform())
315+
list <- (map, transform)
316316
left.removeAll()
317317
left.append(objectsIn: list)
318318
}
@@ -343,13 +343,14 @@ class DoubleValueTransform: TransformOf<List<DoubleValue>, [Double]> {
343343
/// Override operator used during the `propertyMapping(_:)` method.
344344
public func <- (left: List<DoubleValue>, right: (String, Map)) {
345345
let (right, map) = right
346-
kinveyMappingType(left: right, right: map.currentKey!)
346+
let transform = DoubleValueTransform()
347+
kinveyMappingType(left: right, right: map.currentKey!, transform: transform)
347348
var list = left
348349
switch map.mappingType {
349350
case .toJSON:
350-
list <- (map, DoubleValueTransform())
351+
list <- (map, transform)
351352
case .fromJSON:
352-
list <- (map, DoubleValueTransform())
353+
list <- (map, transform)
353354
left.removeAll()
354355
left.append(objectsIn: list)
355356
}
@@ -380,13 +381,14 @@ class BoolValueTransform: TransformOf<List<BoolValue>, [Bool]> {
380381
/// Override operator used during the `propertyMapping(_:)` method.
381382
public func <- (left: List<BoolValue>, right: (String, Map)) {
382383
let (right, map) = right
383-
kinveyMappingType(left: right, right: map.currentKey!)
384+
let transform = BoolValueTransform()
385+
kinveyMappingType(left: right, right: map.currentKey!, transform: transform)
384386
var list = left
385387
switch map.mappingType {
386388
case .toJSON:
387-
list <- (map, BoolValueTransform())
389+
list <- (map, transform)
388390
case .fromJSON:
389-
list <- (map, BoolValueTransform())
391+
list <- (map, transform)
390392
left.removeAll()
391393
left.append(objectsIn: list)
392394
}

Kinvey/Kinvey/RealmCache.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ extension RealmCache: DynamicCacheType {
513513
if let transform = transform,
514514
let value = transform.transformFromJSON(entity[key]) as? NSObject,
515515
let property = properties[translatedKey],
516+
property.type != .array,
516517
let objectClassName = property.objectClassName,
517518
let schema = realm.schema[objectClassName]
518519
{

Kinvey/Kinvey/Realtime.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,18 @@ public struct LiveStreamAcl: StaticMappable {
360360
/// Group Acl
361361
public var groups = LiveStreamAclGroups()
362362

363+
public init(subscribers: [String]? = nil, publishers: [String]? = nil, groups: LiveStreamAclGroups? = nil) {
364+
if let subscribers = subscribers {
365+
self.subscribers = subscribers
366+
}
367+
if let publishers = publishers {
368+
self.publishers = publishers
369+
}
370+
if let groups = groups {
371+
self.groups = groups
372+
}
373+
}
374+
363375
public static func objectForMapping(map: Map) -> BaseMappable? {
364376
return LiveStreamAcl()
365377
}

Kinvey/KinveyTests/DataTypeTestCase.swift

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,66 @@ class DataTypeTestCase: StoreTestCase {
199199
XCTAssertEqual(transform.transformToJSON(Date(timeIntervalSince1970: 1479114355.787)), "2016-11-14T09:05:55.787Z")
200200
}
201201

202+
func testPropertyMapping() {
203+
let propertyMapping = Book.propertyMapping()
204+
var entityId = false,
205+
metadata = false,
206+
acl = false,
207+
title = false,
208+
authorNames = false,
209+
editions = false,
210+
editionsYear = false,
211+
editionsRetailPrice = false,
212+
editionsRating = false,
213+
editionsAvailable = false
214+
for (left, (right, _)) in propertyMapping {
215+
switch left {
216+
case "entityId":
217+
XCTAssertEqual(right, "_id")
218+
entityId = true
219+
case "metadata":
220+
XCTAssertEqual(right, "_kmd")
221+
metadata = true
222+
case "acl":
223+
XCTAssertEqual(right, "_acl")
224+
acl = true
225+
case "title":
226+
XCTAssertEqual(right, "title")
227+
title = true
228+
case "authorNames":
229+
XCTAssertEqual(right, "authorNames")
230+
authorNames = true
231+
case "editions":
232+
XCTAssertEqual(right, "editions")
233+
editions = true
234+
case "editionsYear":
235+
XCTAssertEqual(right, "editionsYear")
236+
editionsYear = true
237+
case "editionsRetailPrice":
238+
XCTAssertEqual(right, "editionsRetailPrice")
239+
editionsRetailPrice = true
240+
case "editionsRating":
241+
XCTAssertEqual(right, "editionsRating")
242+
editionsRating = true
243+
case "editionsAvailable":
244+
XCTAssertEqual(right, "editionsAvailable")
245+
editionsAvailable = true
246+
default:
247+
XCTFail()
248+
}
249+
}
250+
XCTAssertTrue(entityId)
251+
XCTAssertTrue(metadata)
252+
XCTAssertTrue(acl)
253+
XCTAssertTrue(title)
254+
XCTAssertTrue(authorNames)
255+
XCTAssertTrue(editions)
256+
XCTAssertTrue(editionsYear)
257+
XCTAssertTrue(editionsRetailPrice)
258+
XCTAssertTrue(editionsRating)
259+
XCTAssertTrue(editionsAvailable)
260+
}
261+
202262
}
203263

204264
class EntityWithDate : Entity {

Kinvey/KinveyTests/KinveyTestCase.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ extension XCTestCase {
246246
setURLProtocol(MockURLProtocol.self)
247247
}
248248

249-
func mockResponse(completionHandler: @escaping (URLRequest) -> HttpResponse) {
249+
func mockResponse(client: Client = sharedClient, completionHandler: @escaping (URLRequest) -> HttpResponse) {
250250
MockURLProtocol.completionHandler = completionHandler
251-
setURLProtocol(MockURLProtocol.self)
251+
setURLProtocol(MockURLProtocol.self, client: client)
252252
}
253253

254254
}

Kinvey/KinveyTests/QueryTest.swift

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,48 @@ class QueryTest: XCTestCase {
5353
func testQueryEq() {
5454
XCTAssertEqual(encodeQuery(Query(format: "age == %@", 30)), "query=\(encodeURL(["age" : 30]))")
5555
XCTAssertEqual(encodeQuery(Query(format: "age = %@", 30)), "query=\(encodeURL(["age" : 30]))")
56+
XCTAssertEqual(encodeQuery(Query(format: "obj._id == %@", 30)), "query=\(encodeURL(["obj._id" : 30]))")
57+
58+
do {
59+
let client = Client(
60+
appKey: UUID().uuidString,
61+
appSecret: UUID().uuidString
62+
)
63+
64+
var mockReached = false
65+
mockResponse(client: client) { (request) -> HttpResponse in
66+
let components = URLComponents(url: request.url!, resolvingAgainstBaseURL: false)!
67+
let query = components.queryItems!.filter { $0.name == "query" }.first!.value!
68+
XCTAssertEqual(query, "{\"obj._id\":30}")
69+
mockReached = true
70+
return HttpResponse(json: [])
71+
}
72+
defer {
73+
setURLProtocol(nil)
74+
}
75+
76+
let dataStore = DataStore<Person>.collection(.network, client: client)
77+
let query = Query(format: "obj._id == %@", 30)
78+
79+
weak var expectationFind = expectation(description: "Find")
80+
81+
dataStore.find(query, options: Options(client: client)) { (result: Result<[Person], Swift.Error>) in
82+
switch result {
83+
case .success(let persons):
84+
XCTAssertEqual(persons.count, 0)
85+
case .failure(let error):
86+
XCTFail(error.localizedDescription)
87+
}
88+
89+
expectationFind?.fulfill()
90+
}
91+
92+
waitForExpectations(timeout: 30) { (error) in
93+
expectationFind = nil
94+
}
95+
96+
XCTAssertTrue(mockReached)
97+
}
5698
}
5799

58100
func testQueryGt() {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// RealtimeAclTestCase.swift
3+
// Kinvey
4+
//
5+
// Created by Victor Hugo on 2017-08-25.
6+
// Copyright © 2017 Kinvey. All rights reserved.
7+
//
8+
9+
import XCTest
10+
import Kinvey
11+
12+
class RealtimeAclTestCase: KinveyTestCase {
13+
14+
func testLiveStreamAclConsturctorNoParams() {
15+
let acl = LiveStreamAcl()
16+
XCTAssertNotNil(acl)
17+
}
18+
19+
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DEVCENTER_GIT_PROD=https://git.heroku.com/kinvey-devcenter-prod.git
88

99
all: build archive pack docs
1010

11-
deploy: deploy-git deploy-aws-s3 deploy-github deploy-cocoapods deploy-docs
11+
deploy: deploy-git deploy-aws-s3 deploy-github deploy-cocoapods deploy-docs deploy-devcenter
1212

1313
release: all deploy
1414

0 commit comments

Comments
 (0)