Skip to content

Commit

Permalink
Merge branch 'swift3.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	Zip/ZipUtilities.swift
  • Loading branch information
marmelroy committed Sep 18, 2016
2 parents 7437d31 + bcb5d05 commit 92d6f8e
Show file tree
Hide file tree
Showing 24 changed files with 306 additions and 341 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# MacOS
.DS_Store
# Xcode
#
build/
Expand Down
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
osx_image: xcode7.2
osx_image: xcode8
language: objective-c
env:
global:
- LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8
before_install:
- brew update || brew update
- brew outdated xctool || brew upgrade xctool
- gem install cocoapods
- xcrun simctl list
- gem install cocoapods --pre
install: echo "<3"
env:
- MODE=framework
Expand Down
21 changes: 1 addition & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
![Zip - Zip and unzip files in Swift](https://cloud.githubusercontent.com/assets/889949/12374908/252373d0-bcac-11e5-8ece-6933aeae8222.png)

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

# Zip
A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of [minizip](https://github.com/nmoinvaz/minizip).
Expand Down Expand Up @@ -58,26 +57,8 @@ Zip supports '.zip' and '.cbz' files out of the box. To support additional zip-d
Zip.addCustomFileExtension("file-extension-here")
```


### Setting up with Carthage

[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with [Homebrew](http://brew.sh/) using the following command:

```bash
$ brew update
$ brew install carthage
```

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

```ogdl
github "marmelroy/Zip"
```

### Setting up with [CocoaPods](http://cocoapods.org/?q=Zip)
```ruby
source 'https://github.com/CocoaPods/Specs.git'
pod 'Zip', '~> 0.4'
pod 'Zip', '~> 0.5', :submodules => true
```
26 changes: 0 additions & 26 deletions Zip copy-Info.plist

This file was deleted.

2 changes: 1 addition & 1 deletion Zip.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "Zip"
s.version = "0.4.3"
s.version = "0.5"
s.summary = "Zip and unzip files in Swift."

# This description is used to generate tags and improve search results.
Expand Down
36 changes: 21 additions & 15 deletions Zip.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@

/* Begin PBXFileReference section */
342545B51CE525B200336074 /* Zip.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Zip.framework; sourceTree = BUILT_PRODUCTS_DIR; };
342545B61CE525B300336074 /* Zip copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Zip copy-Info.plist"; path = "/Users/marmelroy/Documents/Projects/OpenSource/Zip/Zip copy-Info.plist"; sourceTree = "<absolute>"; };
342FC0D21C5044DC0023A3C3 /* aes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aes.h; sourceTree = "<group>"; };
342FC0D31C5044DC0023A3C3 /* aes_via_ace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aes_via_ace.h; sourceTree = "<group>"; };
342FC0D41C5044DC0023A3C3 /* aescrypt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = aescrypt.c; sourceTree = "<group>"; };
Expand Down Expand Up @@ -275,7 +274,6 @@
347E3A761C1DFFB500A11FD3 /* Zip */,
347E3A821C1DFFB500A11FD3 /* ZipTests */,
347E3A751C1DFFB500A11FD3 /* Products */,
342545B61CE525B300336074 /* Zip copy-Info.plist */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -493,7 +491,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Roy Marmelstein";
TargetAttributes = {
343F50FE1C8DAEEC0028C434 = {
Expand All @@ -504,9 +502,11 @@
};
347E3A731C1DFFB500A11FD3 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
347E3A7D1C1DFFB500A11FD3 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -677,9 +677,9 @@
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 7;
DYLIB_CURRENT_VERSION = 8;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Zip copy-Info.plist";
INFOPLIST_FILE = "Zip/Info-tvOS.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
Expand All @@ -702,9 +702,9 @@
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 7;
DYLIB_CURRENT_VERSION = 8;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Zip copy-Info.plist";
INFOPLIST_FILE = "Zip/Info-tvOS.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
Expand All @@ -714,6 +714,7 @@
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Zip/minizip/**";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -724,10 +725,10 @@
buildSettings = {
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 7;
DYLIB_CURRENT_VERSION = 8;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = Zip/Info.plist;
Expand All @@ -747,10 +748,10 @@
buildSettings = {
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 7;
DYLIB_CURRENT_VERSION = 8;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = Zip/Info.plist;
Expand All @@ -762,6 +763,7 @@
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Zip/minizip/**";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand Down Expand Up @@ -812,7 +814,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand All @@ -835,6 +837,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -860,7 +863,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -875,6 +878,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -889,7 +893,7 @@
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 7;
DYLIB_CURRENT_VERSION = 8;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Zip/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -911,7 +915,7 @@
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 7;
DYLIB_CURRENT_VERSION = 8;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Zip/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -922,6 +926,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Zip/minizip/**";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand All @@ -942,6 +947,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.roymarmelstein.ZipTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Zip.xcodeproj/xcshareddata/xcschemes/Zip OSX.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Zip.xcodeproj/xcshareddata/xcschemes/Zip tvOS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Zip.xcodeproj/xcshareddata/xcschemes/Zip.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Zip.xcodeproj/xcshareddata/xcschemes/ZipTests.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions Zip/Info-tvOS.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.4.1</string>
<string>0.5.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>6</string>
<string>8</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
4 changes: 2 additions & 2 deletions Zip/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.4.3</string>
<string>0.5.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>7</string>
<string>8</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
37 changes: 21 additions & 16 deletions Zip/QuickZip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public class func quickUnzipFile(path: NSURL) throws -> NSURL {
public class func quickUnzipFile(_ path: URL) throws -> URL {
return try quickUnzipFile(path, progress: nil)
}

Expand All @@ -37,16 +37,21 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public class func quickUnzipFile(path: NSURL, progress: ((progress: Double) -> ())?) throws -> NSURL {
let fileManager = NSFileManager.defaultManager()
guard let fileExtension = path.pathExtension, let fileName = path.lastPathComponent else {
throw ZipError.UnzipFail
public class func quickUnzipFile(_ path: URL, progress: ((_ progress: Double) -> ())?) throws -> URL {
let fileManager = FileManager.default

let fileExtension = path.pathExtension
let fileName = path.lastPathComponent

let directoryName = fileName.replacingOccurrences(of: ".\(fileExtension)", with: "")
let documentsUrl = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0] as URL
do {
let destinationUrl = documentsUrl.appendingPathComponent(directoryName, isDirectory: true)
try self.unzipFile(path, destination: destinationUrl, overwrite: true, password: nil, progress: progress)
return destinationUrl
}catch{
throw(ZipError.unzipFail)
}
let directoryName = fileName.stringByReplacingOccurrencesOfString(".\(fileExtension)", withString: "")
let documentsUrl = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL
let destinationUrl = documentsUrl.URLByAppendingPathComponent(directoryName, isDirectory: true)
try self.unzipFile(path, destination: destinationUrl, overwrite: true, password: nil, progress: progress)
return destinationUrl
}

//MARK: Quick Zip
Expand All @@ -63,7 +68,7 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public class func quickZipFiles(paths: [NSURL], fileName: String) throws -> NSURL {
public class func quickZipFiles(_ paths: [URL], fileName: String) throws -> URL {
return try quickZipFiles(paths, fileName: fileName, progress: nil)
}

Expand All @@ -80,13 +85,13 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public class func quickZipFiles(paths: [NSURL], fileName: String, progress: ((progress: Double) -> ())?) throws -> NSURL {
let fileManager = NSFileManager.defaultManager()
let documentsUrl = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as NSURL
let destinationUrl = documentsUrl.URLByAppendingPathComponent("\(fileName).zip")
public class func quickZipFiles(_ paths: [URL], fileName: String, progress: ((_ progress: Double) -> ())?) throws -> URL {
let fileManager = FileManager.default
let documentsUrl = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0] as URL
let destinationUrl = documentsUrl.appendingPathComponent("\(fileName).zip")
try self.zipFiles(paths, zipFilePath: destinationUrl, password: nil, progress: progress)
return destinationUrl
}


}
}
Loading

0 comments on commit 92d6f8e

Please sign in to comment.