Skip to content

Commit

Permalink
Xcode 10, Swift 4.2 Compatibility (#48)
Browse files Browse the repository at this point in the history
Xcode 10 and Swift 4.2
  • Loading branch information
damozhang authored and mats-claassen committed Sep 20, 2018
1 parent 3ed714c commit 6e75b94
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "xmartlabs/Eureka" "4.1.1"
github "Quick/Nimble" "v7.0.3"
github "Quick/Quick" "v1.2.0"
github "Quick/Nimble" "v7.3.0"
github "Quick/Quick" "v1.3.1"
github "xmartlabs/Eureka" "4.2.0"
7 changes: 3 additions & 4 deletions Example/CustomPickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ open class CustomPickerController: UIImagePickerController, TypedRowControllerTy
// Allow edition
allowsEditing = true
}

open func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
(row as? MyImageRow)?.imageURL = info[UIImagePickerControllerReferenceURL] as? URL
row.value = info[UIImagePickerControllerOriginalImage] as? UIImage
open func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
(row as? MyImageRow)?.imageURL = info[UIImagePickerController.InfoKey.referenceURL] as? URL
row.value = info[UIImagePickerController.InfoKey.originalImage] as? UIImage
onDismissCallback?(self)
}

Expand Down
4 changes: 2 additions & 2 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks $(SRCROOT)/../Carthage/Build/iOS";
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -393,7 +393,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks $(SRCROOT)/../Carthage/Build/iOS";
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
4 changes: 2 additions & 2 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ViewController: FormViewController {
<<< ImageRow() { row in
row.title = "Image Row 1"
row.sourceTypes = [.PhotoLibrary, .SavedPhotosAlbum]
row.clearAction = .yes(style: UIAlertActionStyle.destructive)
row.clearAction = .yes(style: UIAlertAction.Style.destructive)
}
+++
Section()
Expand Down Expand Up @@ -61,7 +61,7 @@ public final class MyImageCell: PushSelectorCell<UIImage> {
super.init(coder: aDecoder)
}

public required init(style: UITableViewCellStyle, reuseIdentifier: String?) {
public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
fatalError("init(style:reuseIdentifier:) has not been implemented")
}

Expand Down
4 changes: 2 additions & 2 deletions ImageRow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -400,7 +400,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
6 changes: 3 additions & 3 deletions Sources/ImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ open class ImagePickerController: UIImagePickerController, TypedRowControllerTyp
delegate = self
}

open func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
(row as? ImageRow)?.imageURL = info[UIImagePickerControllerReferenceURL] as? URL
open func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
(row as? ImageRow)?.imageURL = info[UIImagePickerController.InfoKey.referenceURL] as? URL

row.value = info[ (row as? ImageRow)?.useEditedImage ?? false ? UIImagePickerControllerEditedImage : UIImagePickerControllerOriginalImage] as? UIImage
row.value = info[ (row as? ImageRow)?.useEditedImage ?? false ? UIImagePickerController.InfoKey.editedImage : UIImagePickerController.InfoKey.originalImage] as? UIImage
(row as? ImageRow)?.userPickerInfo = info
onDismissCallback?(self)
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/ImageRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct ImageRowSourceTypes: OptionSet {
public var imagePickerControllerSourceTypeRawValue: Int { return self.rawValue >> 1 }

public init(rawValue: Int) { self.rawValue = rawValue }
init(_ sourceType: UIImagePickerControllerSourceType) { self.init(rawValue: 1 << sourceType.rawValue) }
init(_ sourceType: UIImagePickerController.SourceType) { self.init(rawValue: 1 << sourceType.rawValue) }

public static let PhotoLibrary = ImageRowSourceTypes(.photoLibrary)
public static let Camera = ImageRowSourceTypes(.camera)
Expand All @@ -55,7 +55,7 @@ public extension ImageRowSourceTypes {

public enum ImageClearAction {
case no
case yes(style: UIAlertActionStyle)
case yes(style: UIAlertAction.Style)
}

protocol ImageRowProtocol {
Expand All @@ -78,11 +78,11 @@ open class _ImageRow<Cell: CellType>: OptionsRow<Cell>, PresenterRowType, ImageR
open var clearAction = ImageClearAction.yes(style: .destructive)
open var placeholderImage: UIImage?

open var userPickerInfo : [String:Any]?
open var userPickerInfo : [UIImagePickerController.InfoKey:Any]?
open var allowEditor : Bool
open var useEditedImage : Bool

private var _sourceType: UIImagePickerControllerSourceType = .camera
private var _sourceType: UIImagePickerController.SourceType = .camera

public required init(tag: String?) {
sourceTypes = .All
Expand All @@ -101,7 +101,7 @@ open class _ImageRow<Cell: CellType>: OptionsRow<Cell>, PresenterRowType, ImageR
}

// copy over the existing logic from the SelectorRow
func displayImagePickerController(_ sourceType: UIImagePickerControllerSourceType) {
func displayImagePickerController(_ sourceType: UIImagePickerController.SourceType) {
if let presentationMode = presentationMode, !isDisabled {
if let controller = presentationMode.makeController(){
controller.row = self
Expand Down Expand Up @@ -182,7 +182,7 @@ open class _ImageRow<Cell: CellType>: OptionsRow<Cell>, PresenterRowType, ImageR
}

if sourceActionSheet.actions.count == 1 {
if let imagePickerSourceType = UIImagePickerControllerSourceType(rawValue: sourceTypes.imagePickerControllerSourceTypeRawValue) {
if let imagePickerSourceType = UIImagePickerController.SourceType(rawValue: sourceTypes.imagePickerControllerSourceTypeRawValue) {
displayImagePickerController(imagePickerSourceType)
}
} else {
Expand Down Expand Up @@ -212,7 +212,7 @@ open class _ImageRow<Cell: CellType>: OptionsRow<Cell>, PresenterRowType, ImageR

public extension _ImageRow {
func createOptionForAlertController(_ alertController: UIAlertController, sourceType: ImageRowSourceTypes) {
guard let pickerSourceType = UIImagePickerControllerSourceType(rawValue: sourceType.imagePickerControllerSourceTypeRawValue), sourceTypes.contains(sourceType) else { return }
guard let pickerSourceType = UIImagePickerController.SourceType(rawValue: sourceType.imagePickerControllerSourceTypeRawValue), sourceTypes.contains(sourceType) else { return }

let option = UIAlertAction(title: NSLocalizedString(sourceType.localizedString, comment: ""), style: .default) { [weak self] _ in
self?.displayImagePickerController(pickerSourceType)
Expand Down

0 comments on commit 6e75b94

Please sign in to comment.