Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
mbektchiev committed Apr 3, 2020
2 parents 2452bfc + e82e3f8 commit 17f39e5
Show file tree
Hide file tree
Showing 17 changed files with 425 additions and 173 deletions.
24 changes: 17 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
task:
name: macOS
osx_instance:
image: mojave-xcode-11
image: catalina-xcode-11.4
xcode_version_script:
- xcode-select -p
- sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
- xcodebuild -version
download_dependencies_script: make cache
brew_update_script: brew update
install_carthage_script: brew install carthage
xcode_version_script: xcodebuild -version
test_macos_script: make test-macos
test_macos_script: make test-macos || (echo System Log; tail -n 1000 /var/log/system.log; echo Simulator Logs; cat ~/Library/Logs/CoreSimulator/*/system.log; echo Xcode Crash Logs; find ~/Library/Developer/Xcode/DerivedData/ -iname *.crash -print -exec cat {} \;)

task:
name: iOS
osx_instance:
image: mojave-xcode-11
image: catalina-xcode-11.4
xcode_version_script:
- xcode-select -p
- sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
- xcodebuild -version
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
test_ios_script: DESTINATION_OS=13.4 DESTINATION_NAME="iPhone 11 Pro" make test-ios || (echo System Log; tail -n 1000 /var/log/system.log; echo Simulator Logs; cat ~/Library/Logs/CoreSimulator/*/system.log; echo Xcode Crash Logs; find ~/Library/Developer/Xcode/DerivedData/ -iname *.crash -print -exec cat {} \;)

task:
name: macOS SPM
osx_instance:
image: mojave-xcode-11
image: catalina-xcode-11.3.1
xcode_version_script:
- xcode-select -p
- sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
- xcodebuild -version
swift_version_script: swift --version
build_script: swift build
18 changes: 15 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.3
osx_image: xcode11.3
cache:
directories:
- Carthage
Expand All @@ -19,9 +19,14 @@ before_script:
- brew update
- brew install swiftlint || brew upgrade swiftlint
- brew install tree || brew upgrade tree
# - brew upgrade carthage
- tree -L 2 -P '*.framework' -I '*.dSYM' Carthage/Build
- carthage version
# Workaround for error `Segmentation fault: 11` during `carthage checkout`
# downgrade carthage 0.34.0 to 0.33.0 (see issue and comment here: https://github.com/Carthage/Carthage/issues/2760#issuecomment-551499537)
- if carthage version | grep 0.34.0; then
brew uninstall carthage;
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d453dd956dbfc5b724b0fdaeb14f9480f461479d/Formula/carthage.rb;
fi
- xcpretty --version
- if [ ! -d $( md5 Cartfile.resolved | awk '{ print "Carthage/" $4 ".zip" }' ) ]; then
make cache;
Expand Down Expand Up @@ -78,6 +83,13 @@ script:
after_script:
- date
- security delete-keychain ios-build.keychain
after_failure:
- echo System Log
- tail -n 1000 /var/log/system.log
- echo Simulator Logs
- cat ~/Library/Logs/CoreSimulator/*/system.log"
- echo Xcode Crash Logs
- find ~/Library/Developer/Xcode/DerivedData/ -iname *.crash -exec echo "*****" \; -print -exec cat {} \;
after_success:
- bash <(curl -s https://codecov.io/bash) -J '^Kinvey$' -F $PLATFORM
env:
Expand All @@ -87,4 +99,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 DESTINATION_OS=12.4 DESTINATION_NAME="iPhone X"
- PLATFORM=iOS PLATFORM_ALIAS=ios DESTINATION_OS=13.3 DESTINATION_NAME="iPhone 11 Pro"
20 changes: 10 additions & 10 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 "Hearst-DD/ObjectMapper" "3.5.2"
github "Quick/Nimble" "v8.0.7"
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.19.0"
github "SwiftyBeaver/SwiftyBeaver" "1.9.0"
github "httpswift/swifter" "fbffd02ab42306be4748ec4b8ad58e6c77e09e84"
github "kif-framework/KIF" "v3.7.9"
github "kishikawakatsumi/KeychainAccess" "v3.2.1"
github "mxcl/PromiseKit" "6.13.1"
github "pubnub/objective-c" "v4.13.1"
github "realm/realm-cocoa" "v3.21.0"
github "tjboneman/NSPredicate-MongoDB-Adaptor" "fce0cd01913bd4393db0c3dd33404cb7e9ebec88"
github "weichsel/ZIPFoundation" "0.9.9"
github "weichsel/ZIPFoundation" "0.9.11"
22 changes: 11 additions & 11 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.1.1"
s.version = "4.1.2"
s.summary = "Kinvey iOS SDK"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -92,14 +92,14 @@ Pod::Spec.new do |s|
#

s.source_files = "Kinvey/Kinvey/**/*.{swift,h,m,mm}", "Carthage/Checkouts/NSPredicate-MongoDB-Adaptor/Sources/MongoDBPredicateAdaptor/*.{swift}"
# s.public_header_files =
# s.private_header_files =
# s.exclude_files =
# s.prefix_header_file =

# s.public_header_files =

# s.private_header_files =

# s.exclude_files =

# s.prefix_header_file =


# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand All @@ -126,7 +126,7 @@ Pod::Spec.new do |s|
s.frameworks = "CoreGraphics", "CoreLocation", "Security"
s.ios.frameworks = "MobileCoreServices", "WebKit"

# s.libraries =
# s.libraries =


# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand All @@ -138,7 +138,7 @@ Pod::Spec.new do |s|
s.requires_arc = true

s.swift_version = '5.0'

s.dependency "PromiseKit", "~> 6.0"
s.dependency "KeychainAccess", "~> 3.0"
s.dependency "Realm", "~> 3.17"
Expand Down
15 changes: 9 additions & 6 deletions Kinvey/Kinvey.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
3919CCFE243680ED009366D4 /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0C1DC1CDCE88900492D6C /* RealmSwift.framework */; };
3919CCFF243680F4009366D4 /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0C1DC1CDCE88900492D6C /* RealmSwift.framework */; };
570423F91F82EC3E00EE5CBD /* KinveyAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 570423F81F82EC3E00EE5CBD /* KinveyAppUITests.swift */; };
570424041F832C3600EE5CBD /* Swifter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570424021F832BF000EE5CBD /* Swifter.framework */; };
570424061F832C4100EE5CBD /* Swifter.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 570424021F832BF000EE5CBD /* Swifter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -60,7 +62,6 @@
5728212F1C63E10700373EC8 /* FileStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5728212E1C63E10700373EC8 /* FileStore.swift */; };
5728213B1C6482C000373EC8 /* URLSessionTaskRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5728213A1C6482C000373EC8 /* URLSessionTaskRequest.swift */; };
572B948020D235D000E23F59 /* ObjectMapper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B7687C1D10C01F0086AA38 /* ObjectMapper.framework */; };
572B948120D235DE00E23F59 /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0C1DC1CDCE88900492D6C /* RealmSwift.framework */; };
572B948220D235E300E23F59 /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0C1DA1CDCE88900492D6C /* Realm.framework */; };
572B948320D2A7ED00E23F59 /* PushTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57873DEB1DFF3FDC002C87BF /* PushTestCase.swift */; };
572C457B1C86690700A41935 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572C457A1C86690700A41935 /* Date.swift */; };
Expand Down Expand Up @@ -134,8 +135,6 @@
575465A41E66405D0063B4B6 /* PerformanceProductTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 575465A31E66405D0063B4B6 /* PerformanceProductTestCase.swift */; };
5754DDBD1EAEBC4A00122A7A /* DateTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5754DDBC1EAEBC4A00122A7A /* DateTestCase.swift */; };
5756FE861D136C330087141E /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0C1DC1CDCE88900492D6C /* RealmSwift.framework */; };
5756FE871D136C990087141E /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0C1E91CDCE88900492D6C /* RealmSwift.framework */; };
5756FE881D136C9C0087141E /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0C1E91CDCE88900492D6C /* RealmSwift.framework */; };
5756FE891D136CAF0087141E /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0C1DC1CDCE88900492D6C /* RealmSwift.framework */; };
575772861C4728E5001D56F5 /* TTL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 575772851C4728E5001D56F5 /* TTL.swift */; };
575792C01D412CD20065CC22 /* UserQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 575792BF1D412CD20065CC22 /* UserQuery.swift */; };
Expand Down Expand Up @@ -1437,21 +1436,20 @@
57D643041CA3268000F6D16E /* QuartzCore.framework in Frameworks */,
57D643051CA3268000F6D16E /* CoreGraphics.framework in Frameworks */,
57D643071CA3268000F6D16E /* Kinvey.framework in Frameworks */,
5756FE881D136C9C0087141E /* RealmSwift.framework in Frameworks */,
3919CCFE243680ED009366D4 /* RealmSwift.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
57D6432A1CA3268600F6D16E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3919CCFF243680F4009366D4 /* RealmSwift.framework in Frameworks */,
57D6432B1CA3268600F6D16E /* QuartzCore.framework in Frameworks */,
57D6432C1CA3268600F6D16E /* CoreGraphics.framework in Frameworks */,
572B948120D235DE00E23F59 /* RealmSwift.framework in Frameworks */,
572B948020D235D000E23F59 /* ObjectMapper.framework in Frameworks */,
572B948220D235E300E23F59 /* Realm.framework in Frameworks */,
57D6432E1CA3268600F6D16E /* Kinvey.framework in Frameworks */,
5756FE871D136C990087141E /* RealmSwift.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -4871,6 +4869,8 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -4915,6 +4915,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -4923,6 +4924,8 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand Down
81 changes: 75 additions & 6 deletions Kinvey/Kinvey/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import RealmSwift
import Realm

/// Class that represents a file in the backend holding all metadata of the file, but don't hold the data itself.
open class File: Object {
open class File: Object, JSONCodable {

/// `_id` property of the file.
@objc
open dynamic var fileId: String?
Expand Down Expand Up @@ -132,7 +132,9 @@ open class File: Object {
}

public enum FileCodingKeys: String, CodingKey {

case entityId = "_id"
case acl = "_acl"
case metadata = "_kmd"
case publicAccessible = "_public"
case fileName = "_filename"
case mimeType
Expand All @@ -143,12 +145,79 @@ open class File: Object {
case uploadHeaders = "_requiredHeaders"

}

public required init() {
super.init()
}

public required init(realm: RLMRealm, schema: RLMObjectSchema) {
super.init(realm: realm, schema: schema)
}

public required init(value: Any, schema: RLMSchema) {
super.init(value: value, schema: schema)
}

public init(from decoder: Decoder) throws {
super.init()

let container = try decoder.container(keyedBy: FileCodingKeys.self)
fileId = try container.decodeIfPresent(String.self, forKey: .entityId)
acl = try container.decodeIfPresent(Acl.self, forKey: .acl)
metadata = try container.decodeIfPresent(Metadata.self, forKey: .metadata)
publicAccessible = try container.decodeIfPresent(Bool.self, forKey: .publicAccessible) ?? false
fileName = try container.decodeIfPresent(String.self, forKey: .fileName)
mimeType = try container.decodeIfPresent(String.self, forKey: .mimeType)
size.value = try container.decodeIfPresent(Int64.self, forKey: .size)
upload = try container.decodeIfPresent(String.self, forKey: .upload)
download = try container.decodeIfPresent(String.self, forKey: .download)
expiresAt = try container.decodeIfPresent(Date.self, forKey: .expiresAt)
uploadHeaders = try container.decodeIfPresent([String : String].self, forKey: .uploadHeaders)
}

open func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: FileCodingKeys.self)

try container.encodeIfPresent(fileId, forKey: .entityId)
try container.encodeIfPresent(acl, forKey: .acl)
try container.encodeIfPresent(metadata, forKey: .metadata)
try container.encodeIfPresent(publicAccessible, forKey: .publicAccessible)
try container.encodeIfPresent(fileName, forKey: .fileName)
try container.encodeIfPresent(mimeType, forKey: .mimeType)
try container.encodeIfPresent(size, forKey: .size)
try container.encodeIfPresent(upload, forKey: .upload)
try container.encodeIfPresent(download, forKey: .download)
try container.encodeIfPresent(expiresAt, forKey: .expiresAt)
try container.encodeIfPresent(uploadHeaders, forKey: .uploadHeaders)

}

open class func decodeArray<T>(from data: Data) throws -> [T] where T : JSONDecodable {
return try decodeArrayJSONDecodable(from: data)
}

open class func decode<T>(from data: Data) throws -> T where T: JSONDecodable {
return try decodeJSONDecodable(from: data)
}

open class func decode<T>(from dictionary: [String : Any]) throws -> T where T : JSONDecodable {
return try decodeJSONDecodable(from: dictionary)
}

open func refresh(from dictionary: [String : Any]) throws {
var _self = self
try _self.refreshJSONDecodable(from: dictionary)
}

open func encode() throws -> [String : Any] {
return try encodeJSONEncodable()
}

@available(*, deprecated, message: "Deprecated in version 3.18.0. Please use Swift.Codable instead")
open func mapping(map: Map) {
fileId <- ("fileId", map[Entity.EntityCodingKeys.entityId])
acl <- ("acl", map[Entity.EntityCodingKeys.acl])
metadata <- ("metadata", map[Entity.EntityCodingKeys.metadata])
fileId <- ("fileId", map[FileCodingKeys.entityId])
acl <- ("acl", map[FileCodingKeys.acl])
metadata <- ("metadata", map[FileCodingKeys.metadata])
publicAccessible <- ("publicAccessible", map[FileCodingKeys.publicAccessible])
fileName <- ("fileName", map[FileCodingKeys.fileName])
mimeType <- ("mimeType", map[FileCodingKeys.mimeType])
Expand Down
43 changes: 24 additions & 19 deletions Kinvey/Kinvey/FileStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,21 @@ open class FileStore<FileType: File> {
)
let promise = Promise<FileType> { resolver in
request.execute() { (data, response, error) -> Void in
if let response = response, response.isOK,
let data = data,
let json = try? self.client.jsonParser.parseDictionary(from: data),
let newFile = FileType(JSON: json) {
newFile.path = file.path
if let cache = self.cache {
cache.save(newFile, beforeSave: nil)
do {
if let response = response, response.isOK,
let data = data {
let newFile : FileType = try self.client.jsonParser.parseObject(FileType.self, from: data)
newFile.path = file.path
if let cache = self.cache {
cache.save(newFile, beforeSave: nil)
}

resolver.fulfill(newFile)
} else {
resolver.reject(buildError(data, response, error, self.client))
}

resolver.fulfill(newFile)
} else {
resolver.reject(buildError(data, response, error, self.client))
} catch let err {
resolver.reject(buildError(data, response, err, self.client))
}
}
if let requests = requests {
Expand Down Expand Up @@ -516,14 +519,16 @@ open class FileStore<FileType: File> {
let request = self.client.networkRequestFactory.blob.buildBlobUploadFile(file, options: options)
requests += request
request.execute { (data, response, error) -> Void in
if let response = response, response.isOK,
let data = data,
let json = try? self.client.jsonParser.parseDictionary(from: data),
let newFile = FileType(JSON: json)
{
resolver.fulfill((file: newFile, skip: nil))
} else {
resolver.reject(buildError(data, response, error, self.client))
do {
if let response = response, response.isOK,
let data = data {
let newFile = try self.client.jsonParser.parseObject(FileType.self, from: data)
resolver.fulfill((file: newFile, skip: nil))
} else {
resolver.reject(buildError(data, response, error, self.client))
}
} catch let err {
resolver.reject(buildError(data, response, err, self.client))
}
}
}
Expand Down
Loading

0 comments on commit 17f39e5

Please sign in to comment.