Skip to content

Commit

Permalink
Migrating from Zip to ZIPFoundation & preparing for 2.6.3 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
rnine committed Feb 3, 2021
1 parent 667f7f1 commit 292621a
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 65 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Change Log
==========

Version 2.6.3 *(2021-02-03)*
----------------------------

- Updated dependency on `FilestackSDK` to 2.6.2.
- Migrated from `Zip` to `ZIPFoundation`.

Version 2.6.2 *(2021-02-03)*
----------------------------

Expand Down
30 changes: 13 additions & 17 deletions Filestack.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
450FE2D02539AEC40035D67C /* Zip+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 450FE2CF2539AEC40035D67C /* Zip+Extensions.swift */; };
4540BB322535CF860053CDBB /* CloudSourceBarTabScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4540BA9E2535CF860053CDBB /* CloudSourceBarTabScene.swift */; };
4540BB332535CF860053CDBB /* PickerNavigationScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4540BA9F2535CF860053CDBB /* PickerNavigationScene.swift */; };
4540BB342535CF860053CDBB /* PhotoPickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4540BAA12535CF860053CDBB /* PhotoPickerController.swift */; };
Expand Down Expand Up @@ -117,9 +116,9 @@
4540BB9C2535CF860053CDBB /* Client+ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4540BB2F2535CF860053CDBB /* Client+ObjC.swift */; };
4540BB9D2535CF860053CDBB /* Client+Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4540BB302535CF860053CDBB /* Client+Deprecated.swift */; };
45453E8D2535E3540090F78D /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45453E8C2535E3540090F78D /* Bundle.swift */; };
4564B9112535B3E70045A3C7 /* Zip in Frameworks */ = {isa = PBXBuildFile; productRef = 4564B9102535B3E70045A3C7 /* Zip */; };
4581FF55253869260019B70F /* URL+Move.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581FF54253869260019B70F /* URL+Move.swift */; };
4581FF5D25388EBD0019B70F /* PhotosPickerFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4581FF5C25388EBD0019B70F /* PhotosPickerFilter.swift */; };
458DE82E25CAEF5F00A39149 /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 458DE82D25CAEF5F00A39149 /* ZIPFoundation */; };
45CEFC4425C44A9100A8C165 /* FilestackSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 45CEFC4325C44A9100A8C165 /* FilestackSDK */; settings = {ATTRIBUTES = (Required, ); }; };
45CEFC4525C44A9100A8C165 /* FilestackSDK in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 45CEFC4325C44A9100A8C165 /* FilestackSDK */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
/* End PBXBuildFile section */
Expand All @@ -139,7 +138,6 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
450FE2CF2539AEC40035D67C /* Zip+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Zip+Extensions.swift"; sourceTree = "<group>"; };
4518BDF51FC6DE0400FB7D9D /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
4540BA9E2535CF860053CDBB /* CloudSourceBarTabScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CloudSourceBarTabScene.swift; sourceTree = "<group>"; };
4540BA9F2535CF860053CDBB /* PickerNavigationScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickerNavigationScene.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -266,7 +264,7 @@
buildActionMask = 2147483647;
files = (
45CEFC4425C44A9100A8C165 /* FilestackSDK in Frameworks */,
4564B9112535B3E70045A3C7 /* Zip in Frameworks */,
458DE82E25CAEF5F00A39149 /* ZIPFoundation in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -630,7 +628,6 @@
4540BB022535CF860053CDBB /* URL+Copy.swift */,
4540BB072535CF860053CDBB /* URL+IsDirectory.swift */,
4581FF54253869260019B70F /* URL+Move.swift */,
450FE2CF2539AEC40035D67C /* Zip+Extensions.swift */,
4540BB0A2535CF860053CDBB /* ImageEdition */,
);
path = Extensions;
Expand Down Expand Up @@ -797,8 +794,8 @@
);
name = Filestack;
packageProductDependencies = (
4564B9102535B3E70045A3C7 /* Zip */,
45CEFC4325C44A9100A8C165 /* FilestackSDK */,
458DE82D25CAEF5F00A39149 /* ZIPFoundation */,
);
productName = Filestack;
productReference = 457084FF1F975C6C00991340 /* Filestack.framework */;
Expand Down Expand Up @@ -831,9 +828,9 @@
);
mainGroup = 457084F51F975C6B00991340;
packageReferences = (
4564B90F2535B3E70045A3C7 /* XCRemoteSwiftPackageReference "Zip" */,
4564B91A2535B4670045A3C7 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */,
45CEFC3C25C44A6D00A8C165 /* XCRemoteSwiftPackageReference "filestack-swift" */,
458DE82C25CAEF5F00A39149 /* XCRemoteSwiftPackageReference "ZIPFoundation" */,
);
productRefGroup = 457085001F975C6C00991340 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -905,7 +902,6 @@
4540BB572535CF860053CDBB /* Uploadable.swift in Sources */,
4540BB8C2535CF860053CDBB /* UploadableExtractor.swift in Sources */,
4540BB932535CF860053CDBB /* ImageURLExportPreset.swift in Sources */,
450FE2D02539AEC40035D67C /* Zip+Extensions.swift in Sources */,
4540BB912535CF860053CDBB /* CompletionHandlers.swift in Sources */,
4540BB4A2535CF860053CDBB /* CloudSourceCollectionViewController.swift in Sources */,
4540BB882535CF860053CDBB /* LogoutRequest.swift in Sources */,
Expand Down Expand Up @@ -1193,20 +1189,20 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
4564B90F2535B3E70045A3C7 /* XCRemoteSwiftPackageReference "Zip" */ = {
4564B91A2535B4670045A3C7 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/marmelroy/Zip.git";
repositoryURL = "https://github.com/AliSoftware/OHHTTPStubs.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.1.1;
minimumVersion = 9.0.0;
};
};
4564B91A2535B4670045A3C7 /* XCRemoteSwiftPackageReference "OHHTTPStubs" */ = {
458DE82C25CAEF5F00A39149 /* XCRemoteSwiftPackageReference "ZIPFoundation" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/AliSoftware/OHHTTPStubs.git";
repositoryURL = "https://github.com/weichsel/ZIPFoundation";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 9.0.0;
minimumVersion = 0.9.11;
};
};
45CEFC3C25C44A6D00A8C165 /* XCRemoteSwiftPackageReference "filestack-swift" */ = {
Expand All @@ -1220,10 +1216,10 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
4564B9102535B3E70045A3C7 /* Zip */ = {
458DE82D25CAEF5F00A39149 /* ZIPFoundation */ = {
isa = XCSwiftPackageProductDependency;
package = 4564B90F2535B3E70045A3C7 /* XCRemoteSwiftPackageReference "Zip" */;
productName = Zip;
package = 458DE82C25CAEF5F00A39149 /* XCRemoteSwiftPackageReference "ZIPFoundation" */;
productName = ZIPFoundation;
};
45CEFC4325C44A9100A8C165 /* FilestackSDK */ = {
isa = XCSwiftPackageProductDependency;
Expand Down
12 changes: 6 additions & 6 deletions Filestack.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/filestack/filestack-swift.git",
"state": {
"branch": null,
"revision": "d5819a500c1b58179f1fadcea5171260d93e4089",
"version": "2.6.0"
"revision": "1fef475f23ccf3cf6f71bf023ef3106c388dd49d",
"version": "2.6.2"
}
},
{
Expand All @@ -20,12 +20,12 @@
}
},
{
"package": "Zip",
"repositoryURL": "https://github.com/marmelroy/Zip.git",
"package": "ZIPFoundation",
"repositoryURL": "https://github.com/weichsel/ZIPFoundation",
"state": {
"branch": null,
"revision": "bd19d974e8a38cc8d3a88c90c8a107386c3b8ccf",
"version": "2.1.1"
"revision": "ec32d62d412578542c0ffb7a6ce34d3e64b43b94",
"version": "0.9.11"
}
}
]
Expand Down
10 changes: 5 additions & 5 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"repositoryURL": "https://github.com/filestack/filestack-swift",
"state": {
"branch": null,
"revision": "494c1a163a686ba69128583b23de862240630444",
"revision": "1fef475f23ccf3cf6f71bf023ef3106c388dd49d",
"version": "2.6.2"
}
},
{
"package": "Zip",
"repositoryURL": "https://github.com/marmelroy/Zip",
"package": "ZIPFoundation",
"repositoryURL": "https://github.com/weichsel/ZIPFoundation.git",
"state": {
"branch": null,
"revision": "bd19d974e8a38cc8d3a88c90c8a107386c3b8ccf",
"version": "2.1.1"
"revision": "ec32d62d412578542c0ffb7a6ce34d3e64b43b94",
"version": "0.9.11"
}
}
]
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ let package = Package(
),
],
dependencies: [
.package(name: "FilestackSDK", url: "https://github.com/filestack/filestack-swift", .upToNextMajor(from: Version(2, 6, 2))),
.package(url: "https://github.com/marmelroy/Zip", .upToNextMajor(from: Version(2, 1, 0)))
.package(name: "FilestackSDK", url: "https://github.com/filestack/filestack-swift", .upToNextMajor(from: Version(2, 6, 0))),
.package(url: "https://github.com/weichsel/ZIPFoundation.git", .upToNextMajor(from: Version(0, 9, 0)))
],
targets: [
.target(
name: "Filestack",
dependencies: ["FilestackSDK", "Zip"],
dependencies: ["FilestackSDK", "ZIPFoundation"],
exclude: ["Filestack.h", "Info.plist"],
resources: [
.copy("VERSION")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ platform :ios, '11.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Filestack', '~> 2.6.2'
pod 'Filestack', '~> 2.6.3'
end
```

Expand All @@ -52,7 +52,7 @@ $ brew install carthage

To integrate Filestack into your Xcode project using Carthage, specify it in your `Cartfile`:

`github "filestack/filestack-ios" ~> 2.6.2`
`github "filestack/filestack-ios" ~> 2.6.3`

Run `carthage update` to build the framework and drag the built `Filestack.framework` into your Xcode project. Additionally, add `Filestack.framework`, `FilestackSDK.framework`, and `Zip.framework` to the embedded frameworks build phase of your app's target.

Expand All @@ -64,7 +64,7 @@ Alternatively, if you are adding `Filestack` to your own Swift Package, declare

```swift
dependencies: [
.package(name: "Filestack", url: "https://github.com/filestack/filestack-ios.git", .upToNextMajor(from: "2.6.2"))
.package(name: "Filestack", url: "https://github.com/filestack/filestack-ios.git", .upToNextMajor(from: "2.6.3"))
]
```

Expand Down
18 changes: 0 additions & 18 deletions Sources/Filestack/Internal/Extensions/Zip+Extensions.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import FilestackSDK
import UIKit
import Zip
import ZIPFoundation

class DocumentPickerUploadController: NSObject, Cancellable, Monitorizable {
let uploader: Uploader & DeferredAdd
Expand All @@ -17,6 +17,7 @@ class DocumentPickerUploadController: NSObject, Cancellable, Monitorizable {
let config: Config

private let trackingProgress = TrackingProgress()
private var observers: [NSKeyValueObservation] = []

var progress: Progress { trackingProgress }

Expand All @@ -37,6 +38,8 @@ class DocumentPickerUploadController: NSObject, Cancellable, Monitorizable {

@discardableResult
func cancel() -> Bool {
observers.removeAll()

return uploader.cancel()
}
}
Expand Down Expand Up @@ -67,21 +70,27 @@ extension DocumentPickerUploadController {
for (idx, url) in urls.enumerated() {
dispatchGroup.enter()

uploadableURL(from: url) { (url) in
let fileProgress = Progress()

observers.append(fileProgress.observe(\.fractionCompleted, options: [.new]) { (progress, change) in
individualProgress[idx] = progress.fractionCompleted
progress.completedUnitCount = Int64(individualProgress.values.reduce(0, +) * 100)
})

uploadableURL(from: url, progress: progress) { (url) in
if let url = url {
uploadables.append(url)
}

updateProgress()
dispatchGroup.leave()
} progress: { (completed) in
individualProgress[idx] = completed
progress.completedUnitCount = Int64(individualProgress.values.reduce(0, +) * 100)
}
}

dispatchGroup.wait()

observers.removeAll()

guard !uploadables.isEmpty else {
cancel()
return
Expand All @@ -100,25 +109,34 @@ extension DocumentPickerUploadController {
}
}

private func uploadableURL(from url: URL, completion: (URL?) -> (), progress: @escaping ((_ progress: Double) -> ())) {
private func uploadableURL(from url: URL, progress: Progress, completion: (URL?) -> ()) {
if url.isDirectory {
completion(zipURL(from: url, progress: progress))
} else {
completion(url)
}
}

private func zipURL(from url: URL, progress: @escaping ((_ progress: Double) -> ())) -> URL? {
let zippedURL = try? Zip.quickZipFiles([url],
directory: FileManager.default.temporaryDirectory,
fileName: url.lastPathComponent,
progress: progress)
private func zipURL(from url: URL, progress: Progress) -> URL? {
let destinationURL = FileManager.default.temporaryDirectory
.appendingPathComponent(url.lastPathComponent)
.appendingPathExtension("zip")

do {
try FileManager.default.zipItem(at: url,
to: destinationURL,
shouldKeepParent: true,
compressionMethod: .deflate,
progress: progress)
} catch {
return nil
}

if url.path.starts(with: FileManager.default.temporaryDirectory.path) {
try? FileManager.default.removeItem(at: url)
}

return zippedURL
return destinationURL
}
}

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.2
2.6.3

0 comments on commit 292621a

Please sign in to comment.