From 5c7102fad691c23494c52dbceac03e83cea27ec9 Mon Sep 17 00:00:00 2001 From: izumi Date: Fri, 5 Oct 2018 18:21:50 +0900 Subject: [PATCH 1/4] Swift4.2 --- NohanaImagePicker.xcodeproj/project.pbxproj | 4 ++-- NohanaImagePicker/AlbumListEmptyIndicator.swift | 14 +++++++------- NohanaImagePicker/AlbumListViewController.swift | 4 ++-- .../AnimatableNavigationController.swift | 2 +- NohanaImagePicker/AssetCell.swift | 2 +- .../AssetDetailListViewController.swift | 4 ++-- NohanaImagePicker/AssetListViewController.swift | 2 +- .../ContractingAnimationController.swift | 2 +- NohanaImagePicker/MomentViewController.swift | 4 ++-- .../NohanaImagePickerController.swift | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/NohanaImagePicker.xcodeproj/project.pbxproj b/NohanaImagePicker.xcodeproj/project.pbxproj index 044f34b..54aa711 100644 --- a/NohanaImagePicker.xcodeproj/project.pbxproj +++ b/NohanaImagePicker.xcodeproj/project.pbxproj @@ -613,7 +613,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -634,7 +634,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/NohanaImagePicker/AlbumListEmptyIndicator.swift b/NohanaImagePicker/AlbumListEmptyIndicator.swift index 492d4c9..e0a08f2 100644 --- a/NohanaImagePicker/AlbumListEmptyIndicator.swift +++ b/NohanaImagePicker/AlbumListEmptyIndicator.swift @@ -23,22 +23,22 @@ class AlbumListEmptyIndicator: UILabel { centerStyle.alignment = NSTextAlignment.center let messageAttributes = [ - NSAttributedStringKey.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), - NSAttributedStringKey.font : UIFont.systemFont(ofSize: 26), - NSAttributedStringKey.paragraphStyle : centerStyle + NSAttributedString.Key.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), + NSAttributedString.Key.font : UIFont.systemFont(ofSize: 26), + NSAttributedString.Key.paragraphStyle : centerStyle ] let messageText = NSAttributedString(string: message, attributes: messageAttributes) let descriptionAttributes = [ - NSAttributedStringKey.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), - NSAttributedStringKey.font : UIFont.systemFont(ofSize: 14), - NSAttributedStringKey.paragraphStyle : centerStyle + NSAttributedString.Key.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1), + NSAttributedString.Key.font : UIFont.systemFont(ofSize: 14), + NSAttributedString.Key.paragraphStyle : centerStyle ] let descriptionText = NSAttributedString(string: description, attributes: descriptionAttributes) let attributedText = NSMutableAttributedString() attributedText.append(messageText) - attributedText.append(NSAttributedString(string: "\n\n", attributes: [NSAttributedStringKey.font : UIFont.systemFont(ofSize: 6)])) + attributedText.append(NSAttributedString(string: "\n\n", attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 6)])) attributedText.append(descriptionText) self.numberOfLines = 0 diff --git a/NohanaImagePicker/AlbumListViewController.swift b/NohanaImagePicker/AlbumListViewController.swift index 32207f1..fa13710 100644 --- a/NohanaImagePicker/AlbumListViewController.swift +++ b/NohanaImagePicker/AlbumListViewController.swift @@ -240,7 +240,7 @@ class AlbumListViewController: UITableViewController, EmptyIndicatable, Activity var isLoading = true func setUpActivityIndicator() { - activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) + activityIndicator = UIActivityIndicatorView(style: .gray) let screenRect = Size.screenRectWithoutAppBar(self) activityIndicator?.center = CGPoint(x: screenRect.size.width / 2, y: screenRect.size.height / 2) activityIndicator?.startAnimating() @@ -261,7 +261,7 @@ extension UIViewController { let infoButton = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil) infoButton.isEnabled = false - infoButton.setTitleTextAttributes([NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14), NSAttributedStringKey.foregroundColor: UIColor.black], for: UIControlState()) + infoButton.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: UIColor.black], for: UIControl.State()) self.toolbarItems = [leftSpace, infoButton, rightSpace] } diff --git a/NohanaImagePicker/AnimatableNavigationController.swift b/NohanaImagePicker/AnimatableNavigationController.swift index bad1b0c..3a44a38 100644 --- a/NohanaImagePicker/AnimatableNavigationController.swift +++ b/NohanaImagePicker/AnimatableNavigationController.swift @@ -25,7 +25,7 @@ class AnimatableNavigationController: UINavigationController, UINavigationContro self.delegate = self } - func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { + func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { switch operation { case .push where fromVC is AssetListViewController: diff --git a/NohanaImagePicker/AssetCell.swift b/NohanaImagePicker/AssetCell.swift index 726747b..ca1a299 100644 --- a/NohanaImagePicker/AssetCell.swift +++ b/NohanaImagePicker/AssetCell.swift @@ -30,7 +30,7 @@ class AssetCell: UICollectionViewCell { let droppedImage: UIImage? = nohanaImagePickerController.config.image.droppedSmall ?? UIImage(named: "btn_select_m", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) let pickedImage: UIImage? = nohanaImagePickerController.config.image.pickedSmall ?? UIImage(named: "btn_selected_m", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) - pickButton.setImage(droppedImage, for: UIControlState()) + pickButton.setImage(droppedImage, for: UIControl.State()) pickButton.setImage(pickedImage, for: .selected) } } diff --git a/NohanaImagePicker/AssetDetailListViewController.swift b/NohanaImagePicker/AssetDetailListViewController.swift index b28769e..06cd7e3 100644 --- a/NohanaImagePicker/AssetDetailListViewController.swift +++ b/NohanaImagePicker/AssetDetailListViewController.swift @@ -38,7 +38,7 @@ class AssetDetailListViewController: AssetListViewController { let droppedImage: UIImage? = nohanaImagePickerController.config.image.droppedLarge ?? UIImage(named: "btn_select_l", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) let pickedImage: UIImage? = nohanaImagePickerController.config.image.pickedLarge ?? UIImage(named: "btn_selected_l", in: nohanaImagePickerController.assetBundle, compatibleWith: nil) - pickButton.setImage(droppedImage, for: UIControlState()) + pickButton.setImage(droppedImage, for: UIControl.State()) pickButton.setImage(pickedImage, for: .selected) } } @@ -76,7 +76,7 @@ class AssetDetailListViewController: AssetListViewController { } DispatchQueue.main.async { let toIndexPath = IndexPath(item: indexPath.item, section: 0) - self.collectionView?.scrollToItem(at: toIndexPath, at: UICollectionViewScrollPosition.centeredHorizontally, animated: false) + self.collectionView?.scrollToItem(at: toIndexPath, at: UICollectionView.ScrollPosition.centeredHorizontally, animated: false) } } diff --git a/NohanaImagePicker/AssetListViewController.swift b/NohanaImagePicker/AssetListViewController.swift index 8fe2e1d..8b71c3a 100644 --- a/NohanaImagePicker/AssetListViewController.swift +++ b/NohanaImagePicker/AssetListViewController.swift @@ -35,7 +35,7 @@ class AssetListViewController: UICollectionViewController, UICollectionViewDeleg return CGSize.zero } var numberOfColumns = nohanaImagePickerController.numberOfColumnsInLandscape - if UIInterfaceOrientationIsPortrait(UIApplication.shared.statusBarOrientation) { + if UIApplication.shared.statusBarOrientation.isPortrait { numberOfColumns = nohanaImagePickerController.numberOfColumnsInPortrait } let cellMargin: CGFloat = 2 diff --git a/NohanaImagePicker/ContractingAnimationController.swift b/NohanaImagePicker/ContractingAnimationController.swift index b807909..77b30a1 100644 --- a/NohanaImagePicker/ContractingAnimationController.swift +++ b/NohanaImagePicker/ContractingAnimationController.swift @@ -77,7 +77,7 @@ class ContractingAnimationController: NSObject, UIViewControllerAnimatedTransiti UIView.animate( withDuration: transitionDuration(using: transitionContext), delay: 0, - options: UIViewAnimationOptions(), + options: UIView.AnimationOptions(), animations: { toVC.view.alpha = 1 contractingImageView.frame = Size.contractingAnimationToCellRect(toVC, toCell: toCell) diff --git a/NohanaImagePicker/MomentViewController.swift b/NohanaImagePicker/MomentViewController.swift index dd807e7..ff5fa6d 100644 --- a/NohanaImagePicker/MomentViewController.swift +++ b/NohanaImagePicker/MomentViewController.swift @@ -99,7 +99,7 @@ class MomentViewController: AssetListViewController, ActivityIndicatable { override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { switch kind { - case UICollectionElementKindSectionHeader: + case UICollectionView.elementKindSectionHeader: let album = momentAlbumList[indexPath.section] guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "MomentHeader", for: indexPath) as? MomentSectionHeaderView else { fatalError("failed to create MomentHeader") @@ -125,7 +125,7 @@ class MomentViewController: AssetListViewController, ActivityIndicatable { var isLoading = true func setUpActivityIndicator() { - activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) + activityIndicator = UIActivityIndicatorView(style: .gray) let screenRect = Size.screenRectWithoutAppBar(self) activityIndicator?.center = CGPoint(x: screenRect.size.width / 2, y: screenRect.size.height / 2) activityIndicator?.startAnimating() diff --git a/NohanaImagePicker/NohanaImagePickerController.swift b/NohanaImagePicker/NohanaImagePickerController.swift index a1fce79..ffea723 100644 --- a/NohanaImagePicker/NohanaImagePickerController.swift +++ b/NohanaImagePicker/NohanaImagePickerController.swift @@ -106,9 +106,9 @@ open class NohanaImagePickerController: UIViewController { guard let navigationController = storyboard.instantiateViewController(withIdentifier: viewControllerId) as? UINavigationController else { fatalError("navigationController init failed.") } - addChildViewController(navigationController) + addChild(navigationController) view.addSubview(navigationController.view) - navigationController.didMove(toParentViewController: self) + navigationController.didMove(toParent: self) // setup albumListViewController guard let albumListViewController = navigationController.topViewController as? AlbumListViewController else { From f39a38a615f33d57eba5cc8b1e81184fd95a9e1f Mon Sep 17 00:00:00 2001 From: izumi Date: Thu, 11 Oct 2018 10:12:35 +0900 Subject: [PATCH 2/4] update project settings. --- NohanaImagePicker.xcodeproj/project.pbxproj | 6 +++++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ .../xcshareddata/xcschemes/NohanaImagePicker.xcscheme | 4 +--- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 NohanaImagePicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/NohanaImagePicker.xcodeproj/project.pbxproj b/NohanaImagePicker.xcodeproj/project.pbxproj index 54aa711..315663a 100644 --- a/NohanaImagePicker.xcodeproj/project.pbxproj +++ b/NohanaImagePicker.xcodeproj/project.pbxproj @@ -314,7 +314,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = nohana; TargetAttributes = { F208E5501CD7370B00FFC9F6 = { @@ -498,12 +498,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -556,12 +558,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/NohanaImagePicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/NohanaImagePicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/NohanaImagePicker.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/NohanaImagePicker.xcodeproj/xcshareddata/xcschemes/NohanaImagePicker.xcscheme b/NohanaImagePicker.xcodeproj/xcshareddata/xcschemes/NohanaImagePicker.xcscheme index e91e1ba..ecf32c3 100644 --- a/NohanaImagePicker.xcodeproj/xcshareddata/xcschemes/NohanaImagePicker.xcscheme +++ b/NohanaImagePicker.xcodeproj/xcshareddata/xcschemes/NohanaImagePicker.xcscheme @@ -1,6 +1,6 @@ Date: Thu, 11 Oct 2018 10:14:45 +0900 Subject: [PATCH 3/4] fix warning. --- NohanaImagePicker/PhotoKitAssetList.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NohanaImagePicker/PhotoKitAssetList.swift b/NohanaImagePicker/PhotoKitAssetList.swift index 7c185f9..d66f59b 100644 --- a/NohanaImagePicker/PhotoKitAssetList.swift +++ b/NohanaImagePicker/PhotoKitAssetList.swift @@ -19,7 +19,7 @@ import Photos open class PhotoKitAssetList: ItemList { fileprivate let mediaType: MediaType - open let assetList: PHAssetCollection + public let assetList: PHAssetCollection fileprivate var fetchResult: PHFetchResult! init(album: PHAssetCollection, mediaType: MediaType) { From 9362d7ebd171be59a70b410f29ee77df5555de5a Mon Sep 17 00:00:00 2001 From: izumi Date: Thu, 11 Oct 2018 10:31:47 +0900 Subject: [PATCH 4/4] fix swift version. --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 5186d07..bf77d54 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0 +4.2