Skip to content

Commit

Permalink
Merge pull request #99 from mikaoj/swift3
Browse files Browse the repository at this point in the history
Swift3
  • Loading branch information
mikaoj authored Sep 27, 2016
2 parents b23067c + 3fb8bc4 commit 4e647ed
Show file tree
Hide file tree
Showing 48 changed files with 730 additions and 1,454 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
8 changes: 4 additions & 4 deletions BSImagePicker.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "BSImagePicker"
s.version = "2.4.0"
s.version = "2.5.0"
s.summary = "BSImagePicker is a multiple image picker for iOS. UIImagePickerController replacement"
s.description = <<-DESC
A mix between the native iOS gallery and facebooks image picker. Allows you to preview and select multiple images.
Expand All @@ -14,7 +14,7 @@ Pod::Spec.new do |s|
s.platform = :ios, '8.0'
s.requires_arc = true

s.source_files = 'Pod/Classes/**/*'
s.source_files = 'Pod/Classes/**/*.swift'
s.resource_bundles = {
'BSImagePicker' => ['Pod/Assets/*.png',
'Pod/Assets/*.xib',
Expand All @@ -24,6 +24,6 @@ Pod::Spec.new do |s|
}

s.frameworks = 'UIKit', 'Photos'
s.dependency 'UIImageViewModeScaleAspect', '~> 1.3'
s.dependency 'BSGridCollectionViewLayout', '1.2.0-swift23'
s.dependency 'UIImageViewModeScaleAspect', '~> 1.5.0'
s.dependency 'BSGridCollectionViewLayout', '~> 1.2.0'
end
1 change: 1 addition & 0 deletions Example/.swift_version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
86 changes: 23 additions & 63 deletions Example/BSImagePicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
B92D980D4AE8D897DC396ADC /* Pods_BSImagePicker_UI_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 38C28900C4384278DFB9B277 /* Pods_BSImagePicker_UI_Tests.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -63,8 +62,6 @@
607FACE51AFB9204008FA782 /* BSImagePicker_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BSImagePicker_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
690A165A9AB26AE492C12989 /* Pods_BSImagePicker_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BSImagePicker_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
79C023538F5ED9DB966A1623 /* Pods-BSImagePicker_UI_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BSImagePicker_UI_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-BSImagePicker_UI_Tests/Pods-BSImagePicker_UI_Tests.debug.xcconfig"; sourceTree = "<group>"; };
8C347795EABAE858C7D731E7 /* Pods-BSImagePicker_UI_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BSImagePicker_UI_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-BSImagePicker_UI_Tests/Pods-BSImagePicker_UI_Tests.release.xcconfig"; sourceTree = "<group>"; };
8F60C161916125AAC467F7A3 /* Pods-BSImagePicker_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BSImagePicker_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-BSImagePicker_Tests/Pods-BSImagePicker_Tests.debug.xcconfig"; sourceTree = "<group>"; };
A7779C3B10543454F69844CF /* Pods-BSImagePicker_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BSImagePicker_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-BSImagePicker_Example/Pods-BSImagePicker_Example.release.xcconfig"; sourceTree = "<group>"; };
BFBB4164D5BE0D0DB1908A7E /* Pods-BSImagePicker_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BSImagePicker_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-BSImagePicker_Example/Pods-BSImagePicker_Example.debug.xcconfig"; sourceTree = "<group>"; };
Expand All @@ -77,7 +74,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B92D980D4AE8D897DC396ADC /* Pods_BSImagePicker_UI_Tests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -203,8 +199,6 @@
A7779C3B10543454F69844CF /* Pods-BSImagePicker_Example.release.xcconfig */,
8F60C161916125AAC467F7A3 /* Pods-BSImagePicker_Tests.debug.xcconfig */,
5E285F6115D57A6AB5B82652 /* Pods-BSImagePicker_Tests.release.xcconfig */,
79C023538F5ED9DB966A1623 /* Pods-BSImagePicker_UI_Tests.debug.xcconfig */,
8C347795EABAE858C7D731E7 /* Pods-BSImagePicker_UI_Tests.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
Expand All @@ -216,12 +210,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 55E273F11BE004F2006006A7 /* Build configuration list for PBXNativeTarget "BSImagePicker_UI_Tests" */;
buildPhases = (
4DFEC8E023A7EDF4353DCBB2 /* [CP] Check Pods Manifest.lock */,
55E273E41BE004F2006006A7 /* Sources */,
55E273E51BE004F2006006A7 /* Frameworks */,
55E273E61BE004F2006006A7 /* Resources */,
692B9704A0EDC899B4E72494 /* [CP] Embed Pods Frameworks */,
0FE0F470E8979605DB4AC3C6 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -281,12 +272,13 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0810;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
55E273E71BE004F2006006A7 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0800;
ProvisioningStyle = Manual;
TestTargetID = 607FACCF1AFB9204008FA782;
};
607FACCF1AFB9204008FA782 = {
Expand All @@ -297,6 +289,7 @@
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0800;
ProvisioningStyle = Manual;
};
};
};
Expand Down Expand Up @@ -363,36 +356,6 @@
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
0FE0F470E8979605DB4AC3C6 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BSImagePicker_UI_Tests/Pods-BSImagePicker_UI_Tests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
4DFEC8E023A7EDF4353DCBB2 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
583088E6CFD7C00D55C0AF18 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -423,21 +386,6 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BSImagePicker_Example/Pods-BSImagePicker_Example-resources.sh\"\n";
showEnvVarsInLog = 0;
};
692B9704A0EDC899B4E72494 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BSImagePicker_UI_Tests/Pods-BSImagePicker_UI_Tests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
6EEB134F4F15CF3B4525B9A6 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -551,30 +499,32 @@
/* Begin XCBuildConfiguration section */
55E273EF1BE004F2006006A7 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 79C023538F5ED9DB966A1623 /* Pods-BSImagePicker_UI_Tests.debug.xcconfig */;
buildSettings = {
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = BSImagePicker_UI_Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "se.backslashed.BSImagePicker-UI-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_VERSION = 3.0;
TEST_TARGET_NAME = BSImagePicker_Example;
USES_XCTRUNNER = YES;
};
name = Debug;
};
55E273F01BE004F2006006A7 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 8C347795EABAE858C7D731E7 /* Pods-BSImagePicker_UI_Tests.release.xcconfig */;
buildSettings = {
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = BSImagePicker_UI_Tests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "se.backslashed.BSImagePicker-UI-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_VERSION = 3.0;
TEST_TARGET_NAME = BSImagePicker_Example;
USES_XCTRUNNER = YES;
};
Expand Down Expand Up @@ -623,6 +573,8 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
Expand Down Expand Up @@ -662,6 +614,8 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -684,8 +638,9 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = se.backslashed.BSImagePickerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -705,7 +660,8 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = se.backslashed.BSImagePickerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -714,6 +670,7 @@
baseConfigurationReference = 8F60C161916125AAC467F7A3 /* Pods-BSImagePicker_Tests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = "";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
Expand All @@ -722,7 +679,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -731,11 +689,13 @@
baseConfigurationReference = 5E285F6115D57A6AB5B82652 /* Pods-BSImagePicker_Tests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Example/BSImagePicker/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
76 changes: 38 additions & 38 deletions Example/BSImagePicker/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Photos

class ViewController: UIViewController {

@IBAction func showImagePicker(sender: UIButton) {
@IBAction func showImagePicker(_ sender: UIButton) {
let vc = BSImagePickerViewController()
vc.maxNumberOfSelections = 6

Expand All @@ -42,26 +42,26 @@ class ViewController: UIViewController {
}, completion: nil)
}

@IBAction func showCustomImagePicker(sender: UIButton) {
@IBAction func showCustomImagePicker(_ sender: UIButton) {
let vc = BSImagePickerViewController()
vc.maxNumberOfSelections = 6
vc.takePhotoIcon = UIImage(named: "chat")

vc.albumButton.tintColor = UIColor.greenColor()
vc.cancelButton.tintColor = UIColor.redColor()
vc.doneButton.tintColor = UIColor.purpleColor()
vc.albumButton.tintColor = UIColor.green
vc.cancelButton.tintColor = UIColor.red
vc.doneButton.tintColor = UIColor.purple
vc.selectionCharacter = ""
vc.selectionFillColor = UIColor.grayColor()
vc.selectionStrokeColor = UIColor.yellowColor()
vc.selectionShadowColor = UIColor.redColor()
vc.selectionTextAttributes[NSForegroundColorAttributeName] = UIColor.lightGrayColor()
vc.selectionFillColor = UIColor.gray
vc.selectionStrokeColor = UIColor.yellow
vc.selectionShadowColor = UIColor.red
vc.selectionTextAttributes[NSForegroundColorAttributeName] = UIColor.lightGray
vc.cellsPerRow = {(verticalSize: UIUserInterfaceSizeClass, horizontalSize: UIUserInterfaceSizeClass) -> Int in
switch (verticalSize, horizontalSize) {
case (.Compact, .Regular): // iPhone5-6 portrait
case (.compact, .regular): // iPhone5-6 portrait
return 2
case (.Compact, .Compact): // iPhone5-6 landscape
case (.compact, .compact): // iPhone5-6 landscape
return 2
case (.Regular, .Regular): // iPad portrait/landscape
case (.regular, .regular): // iPad portrait/landscape
return 3
default:
return 2
Expand All @@ -80,32 +80,32 @@ class ViewController: UIViewController {
}, completion: nil)
}

@IBAction func showImagePickerWithSelectedAssets(sender: UIButton) {
let allAssets = PHAsset.fetchAssetsWithMediaType(PHAssetMediaType.Image, options: nil)
var evenAssetIds = [String]()

allAssets.enumerateObjectsUsingBlock { (asset, idx, stop) -> Void in
if let asset = asset as? PHAsset where idx % 2 == 0 {
evenAssetIds.append(asset.localIdentifier)
}
}

let evenAssets = PHAsset.fetchAssetsWithLocalIdentifiers(evenAssetIds, options: nil)

let vc = BSImagePickerViewController()
vc.defaultSelections = evenAssets

bs_presentImagePickerController(vc, animated: true,
select: { (asset: PHAsset) -> Void in
print("Selected: \(asset)")
}, deselect: { (asset: PHAsset) -> Void in
print("Deselected: \(asset)")
}, cancel: { (assets: [PHAsset]) -> Void in
print("Cancel: \(assets)")
}, finish: { (assets: [PHAsset]) -> Void in
print("Finish: \(assets)")
}, completion: nil)

@IBAction func showImagePickerWithSelectedAssets(_ sender: UIButton) {
// FIXME:
// let allAssets = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: nil)
// var evenAssetIds = [String]()
//
// allAssets.enumerateObjects { (asset, idx, stop) -> Void in
// if let asset = asset as? PHAsset , idx % 2 == 0 {
// evenAssetIds.append(asset.localIdentifier)
// }
// }
//
// let evenAssets = PHAsset.fetchAssets(withLocalIdentifiers: evenAssetIds, options: nil)
//
// let vc = BSImagePickerViewController()
// vc.defaultSelections = evenAssets
//
// bs_presentImagePickerController(vc, animated: true,
// select: { (asset: PHAsset) -> Void in
// print("Selected: \(asset)")
// }, deselect: { (asset: PHAsset) -> Void in
// print("Deselected: \(asset)")
// }, cancel: { (assets: [PHAsset]) -> Void in
// print("Cancel: \(assets)")
// }, finish: { (assets: [PHAsset]) -> Void in
// print("Finish: \(assets)")
// }, completion: nil)
}
}

Loading

0 comments on commit 4e647ed

Please sign in to comment.