From 68a429be43d7b3476d2e1d483a14359998636264 Mon Sep 17 00:00:00 2001 From: Mujtaba Hassanpur Date: Wed, 20 Sep 2017 21:14:45 -0700 Subject: [PATCH 01/20] Fixes Swift 4 errors and warnings --- Cartfile.resolved | 2 +- Lightbox.xcodeproj/project.pbxproj | 22 +++++++++++++++---- .../xcschemes/Lightbox-iOS.xcscheme | 4 +++- Source/Library/LightboxTransition.swift | 2 +- Source/LightboxConfig.swift | 22 +++++++++---------- Source/LightboxController.swift | 2 +- Source/Views/HeaderView.swift | 4 ++-- Source/Views/InfoLabel.swift | 8 +++---- Source/Views/PageView.swift | 8 +++---- 9 files changed, 45 insertions(+), 29 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 5a2ee557..577d939b 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "hyperoslo/Hue" "f82ffc7dd55d093d3acc6ce5b3d36ca259091fdd" +github "hyperoslo/Hue" "b0714f1b2a3d8d9e306eef4b8d86a2547baff556" diff --git a/Lightbox.xcodeproj/project.pbxproj b/Lightbox.xcodeproj/project.pbxproj index 350bc59a..6166fc6c 100644 --- a/Lightbox.xcodeproj/project.pbxproj +++ b/Lightbox.xcodeproj/project.pbxproj @@ -163,12 +163,12 @@ D523B0A01C43AA2A001AD1EC /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Hyper Interaktiv AS"; TargetAttributes = { D523B0A81C43AA2A001AD1EC = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; }; }; @@ -262,14 +262,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -313,14 +319,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -369,7 +381,8 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox; PRODUCT_NAME = Lightbox; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -392,7 +405,8 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox; PRODUCT_NAME = Lightbox; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/Lightbox.xcodeproj/xcshareddata/xcschemes/Lightbox-iOS.xcscheme b/Lightbox.xcodeproj/xcshareddata/xcschemes/Lightbox-iOS.xcscheme index 1e6cc299..1a2d24a8 100644 --- a/Lightbox.xcodeproj/xcshareddata/xcschemes/Lightbox-iOS.xcscheme +++ b/Lightbox.xcodeproj/xcshareddata/xcschemes/Lightbox-iOS.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Source/Library/LightboxTransition.swift b/Source/Library/LightboxTransition.swift index d08d0a7d..1b94a2fd 100644 --- a/Source/Library/LightboxTransition.swift +++ b/Source/Library/LightboxTransition.swift @@ -45,7 +45,7 @@ class LightboxTransition: UIPercentDrivenInteractiveTransition { // MARK: - Pan gesture recognizer - func handlePanGesture(_ gesture: UIPanGestureRecognizer) { + @objc func handlePanGesture(_ gesture: UIPanGestureRecognizer) { let translation = gesture.translation(in: scrollView) let percentage = abs(translation.y) / UIScreen.main.bounds.height / 1.5 let velocity = gesture.velocity(in: scrollView) diff --git a/Source/LightboxConfig.swift b/Source/LightboxConfig.swift index 3fb1d465..93111288 100644 --- a/Source/LightboxConfig.swift +++ b/Source/LightboxConfig.swift @@ -38,9 +38,9 @@ open class LightboxConfig { public static var separatorColor = UIColor(hex: "3D4757") public static var textAttributes = [ - NSFontAttributeName: UIFont.systemFont(ofSize: 12), - NSForegroundColorAttributeName: UIColor(hex: "899AB8"), - NSParagraphStyleAttributeName: { + NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12), + NSAttributedStringKey.foregroundColor: UIColor(hex: "899AB8"), + NSAttributedStringKey.paragraphStyle: { var style = NSMutableParagraphStyle() style.alignment = .center return style @@ -55,9 +55,9 @@ open class LightboxConfig { public static var image: UIImage? public static var textAttributes = [ - NSFontAttributeName: UIFont.boldSystemFont(ofSize: 16), - NSForegroundColorAttributeName: UIColor.white, - NSParagraphStyleAttributeName: { + NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 16), + NSAttributedStringKey.foregroundColor: UIColor.white, + NSAttributedStringKey.paragraphStyle: { var style = NSMutableParagraphStyle() style.alignment = .center return style @@ -72,9 +72,9 @@ open class LightboxConfig { public static var image: UIImage? public static var textAttributes = [ - NSFontAttributeName: UIFont.boldSystemFont(ofSize: 16), - NSForegroundColorAttributeName: UIColor(hex: "FA2F5B"), - NSParagraphStyleAttributeName: { + NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 16), + NSAttributedStringKey.foregroundColor: UIColor(hex: "FA2F5B"), + NSAttributedStringKey.paragraphStyle: { var style = NSMutableParagraphStyle() style.alignment = .center return style @@ -89,8 +89,8 @@ open class LightboxConfig { public static var ellipsisColor = UIColor(hex: "899AB9") public static var textAttributes = [ - NSFontAttributeName: UIFont.systemFont(ofSize: 12), - NSForegroundColorAttributeName: UIColor(hex: "DBDBDB") + NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12), + NSAttributedStringKey.foregroundColor: UIColor(hex: "DBDBDB") ] } diff --git a/Source/LightboxController.swift b/Source/LightboxController.swift index 866a9e7a..6d780d97 100644 --- a/Source/LightboxController.swift +++ b/Source/LightboxController.swift @@ -252,7 +252,7 @@ open class LightboxController: UIViewController { // MARK: - Actions - func overlayViewDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) { + @objc func overlayViewDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) { footerView.expand(false) } diff --git a/Source/Views/HeaderView.swift b/Source/Views/HeaderView.swift index e2f28a84..7393ad48 100644 --- a/Source/Views/HeaderView.swift +++ b/Source/Views/HeaderView.swift @@ -85,11 +85,11 @@ open class HeaderView: UIView { // MARK: - Actions - func deleteButtonDidPress(_ button: UIButton) { + @objc func deleteButtonDidPress(_ button: UIButton) { delegate?.headerView(self, didPressDeleteButton: button) } - func closeButtonDidPress(_ button: UIButton) { + @objc func closeButtonDidPress(_ button: UIButton) { delegate?.headerView(self, didPressCloseButton: button) } } diff --git a/Source/Views/InfoLabel.swift b/Source/Views/InfoLabel.swift index 09794828..be3cb9d7 100644 --- a/Source/Views/InfoLabel.swift +++ b/Source/Views/InfoLabel.swift @@ -85,7 +85,7 @@ open class InfoLabel: UILabel { // MARK: - Actions - func labelDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) { + @objc func labelDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) { shortText = truncatedText expanded ? collapse() : expand() } @@ -110,7 +110,7 @@ open class InfoLabel: UILabel { if string.range(of: ellipsis) != nil { let range = (string as NSString).range(of: ellipsis) - attributedString.addAttribute(NSForegroundColorAttributeName, + attributedString.addAttribute(NSAttributedStringKey.foregroundColor, value: LightboxConfig.InfoLabel.ellipsisColor, range: range) } @@ -123,12 +123,12 @@ open class InfoLabel: UILabel { return string.boundingRect( with: CGSize(width: bounds.size.width, height: CGFloat.greatestFiniteMagnitude), options: [.usesLineFragmentOrigin, .usesFontLeading], - attributes: [NSFontAttributeName: font], + attributes: [NSAttributedStringKey.font: font], context: nil).height } fileprivate func numberOfLines(_ string: String) -> Int { - let lineHeight = "A".size(attributes: [NSFontAttributeName: font]).height + let lineHeight = "A".size(withAttributes: [NSAttributedStringKey.font: font]).height let totalHeight = heightForString(string) return Int(totalHeight / lineHeight) diff --git a/Source/Views/PageView.swift b/Source/Views/PageView.swift index bbaec4f4..278cffe7 100644 --- a/Source/Views/PageView.swift +++ b/Source/Views/PageView.swift @@ -102,7 +102,7 @@ class PageView: UIScrollView { // MARK: - Recognizers - func scrollViewDoubleTapped(_ recognizer: UITapGestureRecognizer) { + @objc func scrollViewDoubleTapped(_ recognizer: UITapGestureRecognizer) { let pointInView = recognizer.location(in: imageView) let newZoomScale = zoomScale > minimumZoomScale ? minimumZoomScale @@ -118,7 +118,7 @@ class PageView: UIScrollView { zoom(to: rectToZoomTo, animated: true) } - func viewTapped(_ recognizer: UITapGestureRecognizer) { + @objc func viewTapped(_ recognizer: UITapGestureRecognizer) { pageViewDelegate?.pageViewDidTouch(self) } @@ -177,7 +177,7 @@ class PageView: UIScrollView { // MARK: - Action - func playButtonTouched(_ button: UIButton) { + @objc func playButtonTouched(_ button: UIButton) { guard let videoURL = image.videoURL else { return } pageViewDelegate?.pageView(self, didTouchPlayButton: videoURL as URL) @@ -198,7 +198,7 @@ class PageView: UIScrollView { extension PageView: LayoutConfigurable { - func configureLayout() { + @objc func configureLayout() { contentFrame = frame contentSize = frame.size imageView.frame = frame From b5d86f1f7963c3b1ce7ad459e80462bd0321bb2c Mon Sep 17 00:00:00 2001 From: Mujtaba Hassanpur Date: Thu, 21 Sep 2017 10:28:51 -0700 Subject: [PATCH 02/20] Fixes more issues with @objc modifier on configureLayout() methods --- Source/Views/FooterView.swift | 2 +- Source/Views/HeaderView.swift | 2 +- Source/Views/InfoLabel.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Views/FooterView.swift b/Source/Views/FooterView.swift index 683d4cc9..4546ecfd 100644 --- a/Source/Views/FooterView.swift +++ b/Source/Views/FooterView.swift @@ -98,7 +98,7 @@ open class FooterView: UIView { extension FooterView: LayoutConfigurable { - public func configureLayout() { + @objc public func configureLayout() { infoLabel.frame = CGRect(x: 17, y: 0, width: frame.width - 17 * 2, height: 35) infoLabel.configureLayout() } diff --git a/Source/Views/HeaderView.swift b/Source/Views/HeaderView.swift index 7393ad48..e21d5672 100644 --- a/Source/Views/HeaderView.swift +++ b/Source/Views/HeaderView.swift @@ -98,7 +98,7 @@ open class HeaderView: UIView { extension HeaderView: LayoutConfigurable { - public func configureLayout() { + @objc public func configureLayout() { closeButton.frame.origin = CGPoint( x: bounds.width - closeButton.frame.width - 17, y: 0) diff --git a/Source/Views/InfoLabel.swift b/Source/Views/InfoLabel.swift index be3cb9d7..87807ad5 100644 --- a/Source/Views/InfoLabel.swift +++ b/Source/Views/InfoLabel.swift @@ -139,7 +139,7 @@ open class InfoLabel: UILabel { extension InfoLabel: LayoutConfigurable { - public func configureLayout() { + @objc public func configureLayout() { shortText = truncatedText expanded ? expand() : collapse() } From 0e16f68dc12a218614cac472dd13347490f466c6 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 15:34:47 +0200 Subject: [PATCH 03/20] Remove travis --- .slather.yml | 4 ---- .travis.yml | 13 ------------- 2 files changed, 17 deletions(-) delete mode 100644 .slather.yml delete mode 100644 .travis.yml diff --git a/.slather.yml b/.slather.yml deleted file mode 100644 index 58191204..00000000 --- a/.slather.yml +++ /dev/null @@ -1,4 +0,0 @@ -ci_service: travis_ci -coverage_service: coveralls -xcodeproj: Tests/Tests.xcodeproj -source_directory: Source diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c1694a47..00000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -osx_image: xcode8.3 -language: swift - -before_install: -- brew update -- if brew outdated | grep -qx carthage; then brew upgrade carthage; fi -- travis_wait 35 carthage bootstrap --platform iOS - -script: -- xcodebuild clean build -project Lightbox.xcodeproj -scheme "Lightbox-iOS" -sdk iphonesimulator - -notifications: - email: false From a69fb3da174efca34ba08de4c4abb66b7d1a378b Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 15:35:28 +0200 Subject: [PATCH 04/20] Use swift 4 --- .swift-version | 2 +- Lightbox.podspec | 6 +++--- README.md | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.swift-version b/.swift-version index 9f55b2cc..5186d070 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +4.0 diff --git a/Lightbox.podspec b/Lightbox.podspec index 9f4580dc..5d253e58 100644 --- a/Lightbox.podspec +++ b/Lightbox.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "Lightbox" s.summary = "A a convenient and easy to use image viewer for your iOS app, packed with all the features you expect" - s.version = "1.0.0" + s.version = "2.0.0" s.homepage = "https://github.com/hyperoslo/Lightbox" s.license = 'MIT' s.author = { "Hyper Interaktiv AS" => "ios@hyper.no" } s.source = { :git => "https://github.com/hyperoslo/Lightbox.git", :tag => s.version.to_s } s.social_media_url = 'https://twitter.com/hyperoslo' - s.platform = :ios, '8.0' + s.platform = :ios, '9.0' s.requires_arc = true s.source_files = 'Source/**/*' s.ios.resource = 'Resources/Lightbox.bundle' @@ -15,5 +15,5 @@ Pod::Spec.new do |s| s.frameworks = 'UIKit', 'AVFoundation', 'AVKit' s.dependency 'Hue' - s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3.0' } + s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' } end diff --git a/README.md b/README.md index 8b15301e..3bfb21dc 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # Lightbox -[![Version](https://img.shields.io/cocoapods/v/Lightbox.svg?style=flat)](http://cocoadocs.org/docsets/Lightbox) [![CI Status](http://img.shields.io/travis/hyperoslo/Lightbox.svg?style=flat)](https://travis-ci.org/hyperoslo/Lightbox) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![License](https://img.shields.io/cocoapods/l/Lightbox.svg?style=flat)](http://cocoadocs.org/docsets/Lightbox) [![Platform](https://img.shields.io/cocoapods/p/Lightbox.svg?style=flat)](http://cocoadocs.org/docsets/Lightbox) -![Swift](https://img.shields.io/badge/%20in-swift%203.0-orange.svg) +![Swift](https://img.shields.io/badge/%20in-swift%204.0-orange.svg) [Demo](https://appetize.io/app/wfgwc2uvg82m9pzbt17p4rrgh4?device=iphone5s&scale=75&orientation=portrait&osVersion=9.3) From 7885828fa34c3bde41103ffabf0aaee136ae24d0 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 15:36:30 +0200 Subject: [PATCH 05/20] Use latest version of Hue --- Cartfile | 2 +- Cartfile.resolved | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cartfile b/Cartfile index 5ea355bc..3a543005 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "hyperoslo/Hue" "master" +github "hyperoslo/Hue" diff --git a/Cartfile.resolved b/Cartfile.resolved index 577d939b..196869da 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "hyperoslo/Hue" "b0714f1b2a3d8d9e306eef4b8d86a2547baff556" +github "hyperoslo/Hue" "3.0.0" From 29f5e05f1be6655ed19a7e11e8457ac05fa0f7e3 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 15:38:40 +0200 Subject: [PATCH 06/20] Add circle CI --- circle.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 circle.yml diff --git a/circle.yml b/circle.yml new file mode 100644 index 00000000..0305b7b6 --- /dev/null +++ b/circle.yml @@ -0,0 +1,13 @@ +machine: + xcode: + version: "9.0" + +dependencies: + override: + - bin/bootstrap-if-needed + cache_directories: + - "Carthage" + +test: + override: + - set -o pipefail && xcodebuild -project Lightbox.xcodeproj -scheme "Lightbox-iOS" -sdk iphonesimulator clean build \ No newline at end of file From 59d59bd532cb988fe2eb68e753fc2f48448101f4 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 15:39:22 +0200 Subject: [PATCH 07/20] Use swift 4 --- Lightbox.xcodeproj/project.pbxproj | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Lightbox.xcodeproj/project.pbxproj b/Lightbox.xcodeproj/project.pbxproj index 6166fc6c..27c64cb4 100644 --- a/Lightbox.xcodeproj/project.pbxproj +++ b/Lightbox.xcodeproj/project.pbxproj @@ -299,12 +299,12 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.2; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -350,11 +350,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.2; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -376,13 +376,12 @@ ); INFOPLIST_FILE = Lightbox/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox; PRODUCT_NAME = Lightbox; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -400,13 +399,12 @@ ); INFOPLIST_FILE = Lightbox/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox; PRODUCT_NAME = Lightbox; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; }; name = Release; }; From 45abbf66adf585cc1d4b11ea35a6781efacd782c Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 15:40:28 +0200 Subject: [PATCH 08/20] Disable Swift 3 @objc Inference --- Lightbox.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lightbox.xcodeproj/project.pbxproj b/Lightbox.xcodeproj/project.pbxproj index 27c64cb4..67f69a54 100644 --- a/Lightbox.xcodeproj/project.pbxproj +++ b/Lightbox.xcodeproj/project.pbxproj @@ -381,7 +381,6 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox; PRODUCT_NAME = Lightbox; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = On; }; name = Debug; }; @@ -404,7 +403,6 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox; PRODUCT_NAME = Lightbox; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = On; }; name = Release; }; From aec061594db0b07c9ecf370bdc706ef4a414f2af Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 16:01:57 +0200 Subject: [PATCH 09/20] Add Imaginary --- Cartfile | 1 + Cartfile.resolved | 3 +++ Lightbox.podspec | 1 + Lightbox.xcodeproj/project.pbxproj | 15 +++++++++++++++ 4 files changed, 20 insertions(+) diff --git a/Cartfile b/Cartfile index 3a543005..ed7d9beb 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1,2 @@ github "hyperoslo/Hue" +github "hyperoslo/Imaginary" \ No newline at end of file diff --git a/Cartfile.resolved b/Cartfile.resolved index 196869da..2bdc3e34 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1,4 @@ +github "hyperoslo/Cache" "4.0.0" github "hyperoslo/Hue" "3.0.0" +github "hyperoslo/Imaginary" "3.0.0" +github "onmyway133/SwiftHash" "2.0.1" diff --git a/Lightbox.podspec b/Lightbox.podspec index 5d253e58..d1579605 100644 --- a/Lightbox.podspec +++ b/Lightbox.podspec @@ -14,6 +14,7 @@ Pod::Spec.new do |s| s.frameworks = 'UIKit', 'AVFoundation', 'AVKit' s.dependency 'Hue' + s.dependency 'Imaginary' s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' } end diff --git a/Lightbox.xcodeproj/project.pbxproj b/Lightbox.xcodeproj/project.pbxproj index 67f69a54..f91a70cc 100644 --- a/Lightbox.xcodeproj/project.pbxproj +++ b/Lightbox.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ D22006741DFB4D9700E92898 /* Lightbox.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D22006731DFB4D9700E92898 /* Lightbox.bundle */; }; + D2A58F5E1F7943A30064F14E /* Imaginary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2A58F5D1F7943A30064F14E /* Imaginary.framework */; }; D2D71BBC1D54DA77006AB907 /* AssetManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D71BBB1D54DA77006AB907 /* AssetManager.swift */; }; D5026B3C1C5BF3FD003BC1A3 /* LightboxImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5026B3B1C5BF3FD003BC1A3 /* LightboxImage.swift */; }; D523B0BD1C43AA8B001AD1EC /* LightboxConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = D523B0B61C43AA8A001AD1EC /* LightboxConfig.swift */; }; @@ -25,6 +26,7 @@ /* Begin PBXFileReference section */ D22006731DFB4D9700E92898 /* Lightbox.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Lightbox.bundle; sourceTree = ""; }; + D2A58F5D1F7943A30064F14E /* Imaginary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Imaginary.framework; path = Carthage/Build/iOS/Imaginary.framework; sourceTree = ""; }; D2D71BBB1D54DA77006AB907 /* AssetManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AssetManager.swift; sourceTree = ""; }; D5026B3B1C5BF3FD003BC1A3 /* LightboxImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LightboxImage.swift; sourceTree = ""; }; D523B0A91C43AA2A001AD1EC /* Lightbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Lightbox.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -47,6 +49,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D2A58F5E1F7943A30064F14E /* Imaginary.framework in Frameworks */, D54DFCC21C5AAAF100ADEA0E /* Hue.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -62,6 +65,14 @@ path = Resources; sourceTree = ""; }; + D2A58F5C1F7943A30064F14E /* Frameworks */ = { + isa = PBXGroup; + children = ( + D2A58F5D1F7943A30064F14E /* Imaginary.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; D523B09F1C43AA2A001AD1EC = { isa = PBXGroup; children = ( @@ -70,6 +81,7 @@ D523B0B41C43AA8A001AD1EC /* Source */, D523B0AB1C43AA2A001AD1EC /* Lightbox */, D523B0AA1C43AA2A001AD1EC /* Products */, + D2A58F5C1F7943A30064F14E /* Frameworks */, ); sourceTree = ""; }; @@ -221,6 +233,9 @@ ); inputPaths = ( "$(SRCROOT)/Carthage/Build/iOS/Hue.framework", + "$(SRCROOT)/Carthage/Build/iOS/Imaginary.framework", + "$(SRCROOT)/Carthage/Build/iOS/Cache.framework", + "$(SRCROOT)/Carthage/Build/iOS/SwiftHash.framework", ); name = "Copy frameworks with Carthage"; outputPaths = ( From 8867836ff5879f3c8bb3316c881613fa0aed64a0 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 16:06:16 +0200 Subject: [PATCH 10/20] Use Imaginary to load image --- Source/LightboxConfig.swift | 19 ++----------------- Source/LightboxImage.swift | 13 +++++++++---- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Source/LightboxConfig.swift b/Source/LightboxConfig.swift index 93111288..5d6387a3 100644 --- a/Source/LightboxConfig.swift +++ b/Source/LightboxConfig.swift @@ -3,26 +3,11 @@ import Hue import AVKit import AVFoundation -open class LightboxConfig { +public class LightboxConfig { public typealias LoadImageCompletion = (_ error: NSError?, _ image: UIImage?) -> Void - open static var hideStatusBar = true - - open static var loadImage: (_ imageView: UIImageView, _ URL: URL, _ completion: LoadImageCompletion?) -> Void = { - imageView, URL, completion in - let imageRequest: URLRequest = URLRequest(url: URL) - - NSURLConnection.sendAsynchronousRequest(imageRequest, - queue: OperationQueue.main, - completionHandler: { _, data, error in - if let data = data, let image = UIImage(data: data) { - imageView.image = image - } - - completion?(error as NSError?, imageView.image) - }) - } + public static var hideStatusBar = true open static var handleVideo: (_ from: UIViewController, _ videoURL: URL) -> Void = { from, videoURL in let videoController = AVPlayerViewController() diff --git a/Source/LightboxImage.swift b/Source/LightboxImage.swift index 83937ba4..90646bc9 100644 --- a/Source/LightboxImage.swift +++ b/Source/LightboxImage.swift @@ -1,4 +1,5 @@ import UIKit +import Imaginary open class LightboxImage { @@ -26,10 +27,14 @@ open class LightboxImage { imageView.image = image completion?(image) } else if let imageURL = imageURL { - LightboxConfig.loadImage(imageView, imageURL) { [weak self] _, image in - self?.image = image - completion?(image) - } + imageView.setImage(url: imageURL, placeholder: nil, completion: { result in + switch result { + case .value(let image): + completion?(image) + case .error: + completion?(nil) + } + }) } } } From 961020ea94eff752808f3c2d5fc0555aa09e4816 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 16:14:39 +0200 Subject: [PATCH 11/20] Update demo --- .../DemoLightbox.xcodeproj/project.pbxproj | 84 ++++++++++++------- .../DemoLightbox/ViewController.swift | 2 +- Example/DemoLightbox/Podfile | 11 ++- Example/DemoLightbox/Podfile.lock | 23 +++-- Source/LightboxConfig.swift | 36 ++++---- 5 files changed, 94 insertions(+), 62 deletions(-) diff --git a/Example/DemoLightbox/DemoLightbox.xcodeproj/project.pbxproj b/Example/DemoLightbox/DemoLightbox.xcodeproj/project.pbxproj index 6739cc50..ab200261 100644 --- a/Example/DemoLightbox/DemoLightbox.xcodeproj/project.pbxproj +++ b/Example/DemoLightbox/DemoLightbox.xcodeproj/project.pbxproj @@ -11,20 +11,20 @@ 29B4A42F1C43A4320060ED52 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29B4A42E1C43A4320060ED52 /* ViewController.swift */; }; 29B4A4341C43A4320060ED52 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 29B4A4331C43A4320060ED52 /* Assets.xcassets */; }; 29B4A4371C43A4320060ED52 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 29B4A4351C43A4320060ED52 /* LaunchScreen.storyboard */; }; - 7193005DD460E198432D8F06 /* Pods_DemoLightbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0977FB7C36F459186E043753 /* Pods_DemoLightbox.framework */; }; + B89E57B7A21C44D762123511 /* Pods_DemoLightbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE4E898FD95F4D90F624B067 /* Pods_DemoLightbox.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 0977FB7C36F459186E043753 /* Pods_DemoLightbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DemoLightbox.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 064155DBC618EBACF5C257C6 /* Pods-DemoLightbox.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DemoLightbox.release.xcconfig"; path = "Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox.release.xcconfig"; sourceTree = ""; }; 29B4A4291C43A4320060ED52 /* DemoLightbox.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DemoLightbox.app; sourceTree = BUILT_PRODUCTS_DIR; }; 29B4A42C1C43A4320060ED52 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 29B4A42E1C43A4320060ED52 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 29B4A4331C43A4320060ED52 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29B4A4361C43A4320060ED52 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29B4A4381C43A4320060ED52 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5B9CE7F93A06A0459BF452D8 /* Pods-DemoLightbox.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DemoLightbox.release.xcconfig"; path = "Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox.release.xcconfig"; sourceTree = ""; }; - C37FDBF69CDC2A95E0E105A7 /* Pods-DemoLightbox.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DemoLightbox.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox.debug.xcconfig"; sourceTree = ""; }; + 6096248776155BE47C0A196A /* Pods-DemoLightbox.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DemoLightbox.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox.debug.xcconfig"; sourceTree = ""; }; DAE713340DA5D2F2EF13EA8D /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + EE4E898FD95F4D90F624B067 /* Pods_DemoLightbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DemoLightbox.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -32,20 +32,29 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 7193005DD460E198432D8F06 /* Pods_DemoLightbox.framework in Frameworks */, + B89E57B7A21C44D762123511 /* Pods_DemoLightbox.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0C8887567644E86396B8D885 /* Pods */ = { + isa = PBXGroup; + children = ( + 6096248776155BE47C0A196A /* Pods-DemoLightbox.debug.xcconfig */, + 064155DBC618EBACF5C257C6 /* Pods-DemoLightbox.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; 29B4A4201C43A4320060ED52 = { isa = PBXGroup; children = ( 29B4A42B1C43A4320060ED52 /* DemoLightbox */, 29B4A42A1C43A4320060ED52 /* Products */, B1B2B3DADEEC7FD14D4A9FF8 /* Frameworks */, - 80F119CA8153119A6934480D /* Pods */, + 0C8887567644E86396B8D885 /* Pods */, ); sourceTree = ""; }; @@ -69,20 +78,11 @@ path = DemoLightbox; sourceTree = ""; }; - 80F119CA8153119A6934480D /* Pods */ = { - isa = PBXGroup; - children = ( - C37FDBF69CDC2A95E0E105A7 /* Pods-DemoLightbox.debug.xcconfig */, - 5B9CE7F93A06A0459BF452D8 /* Pods-DemoLightbox.release.xcconfig */, - ); - name = Pods; - sourceTree = ""; - }; B1B2B3DADEEC7FD14D4A9FF8 /* Frameworks */ = { isa = PBXGroup; children = ( DAE713340DA5D2F2EF13EA8D /* Pods.framework */, - 0977FB7C36F459186E043753 /* Pods_DemoLightbox.framework */, + EE4E898FD95F4D90F624B067 /* Pods_DemoLightbox.framework */, ); name = Frameworks; sourceTree = ""; @@ -94,12 +94,12 @@ isa = PBXNativeTarget; buildConfigurationList = 29B4A43B1C43A4320060ED52 /* Build configuration list for PBXNativeTarget "DemoLightbox" */; buildPhases = ( - 2CF277B8821F7CE6E2730C9C /* [CP] Check Pods Manifest.lock */, + 4DE126F6B5D0C8D6C0E7D848 /* [CP] Check Pods Manifest.lock */, 29B4A4251C43A4320060ED52 /* Sources */, 29B4A4261C43A4320060ED52 /* Frameworks */, 29B4A4271C43A4320060ED52 /* Resources */, - 831C9CD301B03A92F6320AEE /* [CP] Embed Pods Frameworks */, - 3BCDC27EE322C46C109D231B /* [CP] Copy Pods Resources */, + F162948C45248BBD677112BF /* [CP] Embed Pods Frameworks */, + D1AB0C213924D367899FA1A2 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -117,7 +117,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Hyper Interaktiv AS"; TargetAttributes = { 29B4A4281C43A4320060ED52 = { @@ -158,22 +158,25 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 2CF277B8821F7CE6E2730C9C /* [CP] Check Pods Manifest.lock */ = { + 4DE126F6B5D0C8D6C0E7D848 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-DemoLightbox-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/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"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/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# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 3BCDC27EE322C46C109D231B /* [CP] Copy Pods Resources */ = { + D1AB0C213924D367899FA1A2 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -188,15 +191,26 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 831C9CD301B03A92F6320AEE /* [CP] Embed Pods Frameworks */ = { + F162948C45248BBD677112BF /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-DemoLightbox/Pods-DemoLightbox-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Cache/Cache.framework", + "${BUILT_PRODUCTS_DIR}/Hue/Hue.framework", + "${BUILT_PRODUCTS_DIR}/Imaginary/Imaginary.framework", + "${BUILT_PRODUCTS_DIR}/Lightbox/Lightbox.framework", + "${BUILT_PRODUCTS_DIR}/SwiftHash/SwiftHash.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cache.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Hue.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Imaginary.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Lightbox.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftHash.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -237,14 +251,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -272,7 +292,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -284,14 +304,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -312,14 +338,14 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; }; name = Release; }; 29B4A43C1C43A4320060ED52 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = C37FDBF69CDC2A95E0E105A7 /* Pods-DemoLightbox.debug.xcconfig */; + baseConfigurationReference = 6096248776155BE47C0A196A /* Pods-DemoLightbox.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -328,13 +354,12 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.DemoLightbox; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; }; name = Debug; }; 29B4A43D1C43A4320060ED52 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5B9CE7F93A06A0459BF452D8 /* Pods-DemoLightbox.release.xcconfig */; + baseConfigurationReference = 064155DBC618EBACF5C257C6 /* Pods-DemoLightbox.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -343,7 +368,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.DemoLightbox; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/Example/DemoLightbox/DemoLightbox/ViewController.swift b/Example/DemoLightbox/DemoLightbox/ViewController.swift index da4ba124..650c9b9f 100644 --- a/Example/DemoLightbox/DemoLightbox/ViewController.swift +++ b/Example/DemoLightbox/DemoLightbox/ViewController.swift @@ -25,7 +25,7 @@ class ViewController: UIViewController { // MARK: - Action methods - func showLightbox() { + @objc func showLightbox() { let images = [ LightboxImage(imageURL: URL(string: "https://cdn.arstechnica.net/2011/10/05/iphone4s_sample_apple-4e8c706-intro.jpg")!), LightboxImage( diff --git a/Example/DemoLightbox/Podfile b/Example/DemoLightbox/Podfile index f19e6ec5..ec585364 100644 --- a/Example/DemoLightbox/Podfile +++ b/Example/DemoLightbox/Podfile @@ -1,7 +1,6 @@ -platform :ios, '8.0' +platform :ios, '9.0' -use_frameworks! -inhibit_all_warnings! - -pod 'Lightbox', path: '../../' -target 'DemoLightbox' +target 'DemoLightbox' do + use_frameworks! + pod 'Lightbox', path: '../../' +end diff --git a/Example/DemoLightbox/Podfile.lock b/Example/DemoLightbox/Podfile.lock index d1409d3e..18b900a5 100644 --- a/Example/DemoLightbox/Podfile.lock +++ b/Example/DemoLightbox/Podfile.lock @@ -1,19 +1,28 @@ PODS: - - Hue (2.0.1) - - Lightbox (1.0.0): + - Cache (4.0.0): + - SwiftHash (~> 2.0.0) + - Hue (3.0.0) + - Imaginary (3.0.0): + - Cache (~> 4.0) + - Lightbox (2.0.0): - Hue + - Imaginary + - SwiftHash (2.0.0) DEPENDENCIES: - Lightbox (from `../../`) EXTERNAL SOURCES: Lightbox: - :path: "../../" + :path: ../../ SPEC CHECKSUMS: - Hue: 354caec055fdc9d38b5ef33ca2e7224721843baf - Lightbox: a7edccb98c1a84a4b089a44dbaf2b39a409fbfcb + Cache: e73353960c614ab79b0c6911b8c39da05b334470 + Hue: b8fe1e43eef13631331eebecb2198b68e2622f95 + Imaginary: 2765d293d425cbed3b07fa11642554cbaebe913d + Lightbox: e7de1d134eee502ca578a6ab13382c820965b7b3 + SwiftHash: d2e09b13495447178cdfb8e46e54a5c46f15f5a9 -PODFILE CHECKSUM: cd88b68c201e5c39cef62070056649eaee91c71b +PODFILE CHECKSUM: 408ae3477507a1d4b7ff06ffb3f162eda443424f -COCOAPODS: 1.2.1 +COCOAPODS: 1.3.1 diff --git a/Source/LightboxConfig.swift b/Source/LightboxConfig.swift index 5d6387a3..0f936e41 100644 --- a/Source/LightboxConfig.swift +++ b/Source/LightboxConfig.swift @@ -22,14 +22,14 @@ public class LightboxConfig { public static var enabled = true public static var separatorColor = UIColor(hex: "3D4757") - public static var textAttributes = [ - NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12), - NSAttributedStringKey.foregroundColor: UIColor(hex: "899AB8"), - NSAttributedStringKey.paragraphStyle: { + public static var textAttributes: [NSAttributedStringKey: Any] = [ + .font: UIFont.systemFont(ofSize: 12), + .foregroundColor: UIColor(hex: "899AB8"), + .paragraphStyle: { var style = NSMutableParagraphStyle() style.alignment = .center return style - }() + }() ] } @@ -39,14 +39,14 @@ public class LightboxConfig { public static var text = NSLocalizedString("Close", comment: "") public static var image: UIImage? - public static var textAttributes = [ - NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 16), - NSAttributedStringKey.foregroundColor: UIColor.white, - NSAttributedStringKey.paragraphStyle: { + public static var textAttributes: [NSAttributedStringKey: Any] = [ + .font: UIFont.boldSystemFont(ofSize: 16), + .foregroundColor: UIColor.white, + .paragraphStyle: { var style = NSMutableParagraphStyle() style.alignment = .center return style - }() + }() ] } @@ -56,14 +56,14 @@ public class LightboxConfig { public static var text = NSLocalizedString("Delete", comment: "") public static var image: UIImage? - public static var textAttributes = [ - NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 16), - NSAttributedStringKey.foregroundColor: UIColor(hex: "FA2F5B"), - NSAttributedStringKey.paragraphStyle: { + public static var textAttributes: [NSAttributedStringKey: Any] = [ + .font: UIFont.boldSystemFont(ofSize: 16), + .foregroundColor: UIColor(hex: "FA2F5B"), + .paragraphStyle: { var style = NSMutableParagraphStyle() style.alignment = .center return style - }() + }() ] } @@ -73,9 +73,9 @@ public class LightboxConfig { public static var ellipsisText = NSLocalizedString("Show more", comment: "") public static var ellipsisColor = UIColor(hex: "899AB9") - public static var textAttributes = [ - NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12), - NSAttributedStringKey.foregroundColor: UIColor(hex: "DBDBDB") + public static var textAttributes: [NSAttributedStringKey: Any] = [ + .font: UIFont.systemFont(ofSize: 12), + .foregroundColor: UIColor(hex: "DBDBDB") ] } From d0923f2660597eca47c03d122bd1acb58cbbf1ee Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 16:15:16 +0200 Subject: [PATCH 12/20] Remove typealias --- Source/LightboxConfig.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/LightboxConfig.swift b/Source/LightboxConfig.swift index 0f936e41..d5d14395 100644 --- a/Source/LightboxConfig.swift +++ b/Source/LightboxConfig.swift @@ -4,9 +4,6 @@ import AVKit import AVFoundation public class LightboxConfig { - - public typealias LoadImageCompletion = (_ error: NSError?, _ image: UIImage?) -> Void - public static var hideStatusBar = true open static var handleVideo: (_ from: UIViewController, _ videoURL: URL) -> Void = { from, videoURL in From d92b2c3e799d793e6a584561669fc82611b337cf Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 16:20:21 +0200 Subject: [PATCH 13/20] Add comments --- Source/AssetManager.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/AssetManager.swift b/Source/AssetManager.swift index 121d72ad..d6c56dca 100644 --- a/Source/AssetManager.swift +++ b/Source/AssetManager.swift @@ -1,5 +1,6 @@ import UIKit +/// Used to load assets from Lightbox bundle class AssetManager { static func image(_ named: String) -> UIImage? { From cb583ef202da2b4bc8c2c3e6ecf524d609ce5df7 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Mon, 25 Sep 2017 16:30:20 +0200 Subject: [PATCH 14/20] Add bootstrap scripts for Carthage --- bin/bootstrap | 4 ++++ bin/bootstrap-if-needed | 5 +++++ 2 files changed, 9 insertions(+) create mode 100755 bin/bootstrap create mode 100755 bin/bootstrap-if-needed diff --git a/bin/bootstrap b/bin/bootstrap new file mode 100755 index 00000000..d08c0b57 --- /dev/null +++ b/bin/bootstrap @@ -0,0 +1,4 @@ +#!/bin/sh + +carthage bootstrap +cp Cartfile.resolved Carthage diff --git a/bin/bootstrap-if-needed b/bin/bootstrap-if-needed new file mode 100755 index 00000000..c49a31d1 --- /dev/null +++ b/bin/bootstrap-if-needed @@ -0,0 +1,5 @@ +#!/bin/sh + +if ! cmp -s Cartfile.resolved Carthage/Cartfile.resolved; then + bin/bootstrap +fi From db80c7384c022894faa909e9ec932e3cf24a2076 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Tue, 26 Sep 2017 14:40:46 +0200 Subject: [PATCH 15/20] Add comments. Add makeLoadingIndicator --- Source/LightboxConfig.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/LightboxConfig.swift b/Source/LightboxConfig.swift index d5d14395..60100ef8 100644 --- a/Source/LightboxConfig.swift +++ b/Source/LightboxConfig.swift @@ -4,9 +4,11 @@ import AVKit import AVFoundation public class LightboxConfig { + /// Whether to show status bar while Lightbox is presented public static var hideStatusBar = true - open static var handleVideo: (_ from: UIViewController, _ videoURL: URL) -> Void = { from, videoURL in + /// Provide a closure to handle selected video + public static var handleVideo: (_ from: UIViewController, _ videoURL: URL) -> Void = { from, videoURL in let videoController = AVPlayerViewController() videoController.player = AVPlayer(url: videoURL) @@ -15,6 +17,11 @@ public class LightboxConfig { } } + /// Indicator is used to show while image is being fetched + public static var makeLoadingIndicator: () -> UIView = { + return LoadingIndicator() + } + public struct PageIndicator { public static var enabled = true public static var separatorColor = UIColor(hex: "3D4757") @@ -80,8 +87,4 @@ public class LightboxConfig { public static var minimumScale: CGFloat = 1.0 public static var maximumScale: CGFloat = 3.0 } - - public struct LoadingIndicator { - public static var configure: ((UIActivityIndicatorView) -> Void)? - } } From 401cfe185a612702444da807f15ab160973cf9c2 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Tue, 26 Sep 2017 14:41:16 +0200 Subject: [PATCH 16/20] Use loadingIndicator from Config --- Source/Views/PageView.swift | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/Source/Views/PageView.swift b/Source/Views/PageView.swift index 278cffe7..acbe360c 100644 --- a/Source/Views/PageView.swift +++ b/Source/Views/PageView.swift @@ -33,7 +33,7 @@ class PageView: UIScrollView { return button }() - lazy var activityIndicator: LoadingIndicator = LoadingIndicator() + lazy var loadingIndicator: UIView = LightboxConfig.makeLoadingIndicator() var image: LightboxImage var contentFrame = CGRect.zero @@ -51,7 +51,7 @@ class PageView: UIScrollView { configure() - activityIndicator.alpha = 1 + loadingIndicator.alpha = 1 self.image.addImageTo(imageView) { [weak self] image in guard let strongSelf = self else { return @@ -62,7 +62,7 @@ class PageView: UIScrollView { strongSelf.pageViewDelegate?.remoteImageDidLoad(image, imageView: strongSelf.imageView) UIView.animate(withDuration: 0.4) { - strongSelf.activityIndicator.alpha = 0 + strongSelf.loadingIndicator.alpha = 0 } } } @@ -80,7 +80,7 @@ class PageView: UIScrollView { addSubview(playButton) } - addSubview(activityIndicator) + addSubview(loadingIndicator) delegate = self isMultipleTouchEnabled = true @@ -127,7 +127,7 @@ class PageView: UIScrollView { override func layoutSubviews() { super.layoutSubviews() - activityIndicator.center = imageView.center + loadingIndicator.center = imageView.center playButton.center = imageView.center } @@ -182,16 +182,6 @@ class PageView: UIScrollView { pageViewDelegate?.pageView(self, didTouchPlayButton: videoURL as URL) } - - // MARK: - Controls - - func makeActivityIndicator() -> UIActivityIndicatorView { - let view = UIActivityIndicatorView(activityIndicatorStyle: .white) - LightboxConfig.LoadingIndicator.configure?(view) - view.startAnimating() - - return view - } } // MARK: - LayoutConfigurable From 8f51e95e35d7f6e53fe9acc013ddaf401d5d28fa Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Tue, 3 Oct 2017 14:34:02 +0200 Subject: [PATCH 17/20] Add emojis --- Cartfile.resolved | 2 +- Example/DemoLightbox/DemoLightbox/ViewController.swift | 2 +- Example/DemoLightbox/Podfile.lock | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 2bdc3e34..e18078ca 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,4 @@ -github "hyperoslo/Cache" "4.0.0" +github "hyperoslo/Cache" "4.0.2" github "hyperoslo/Hue" "3.0.0" github "hyperoslo/Imaginary" "3.0.0" github "onmyway133/SwiftHash" "2.0.1" diff --git a/Example/DemoLightbox/DemoLightbox/ViewController.swift b/Example/DemoLightbox/DemoLightbox/ViewController.swift index 650c9b9f..676e52b0 100644 --- a/Example/DemoLightbox/DemoLightbox/ViewController.swift +++ b/Example/DemoLightbox/DemoLightbox/ViewController.swift @@ -34,7 +34,7 @@ class ViewController: UIViewController { ), LightboxImage( image: UIImage(named: "photo2")!, - text: "", + text: "🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲 🏃 🌲 🏃‍♀️ 🌲 🌲 🌲 🌲 🌲 🌲 🌲 🌲\n\nSuspendisse massa massa, maximus et finibus ac, auctor volutpat diam.\n\nPellentesque consequat magna condimentum mauris bibendum, nec ornare nisl hendrerit. Phasellus nec ultrices sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nSuspendisse sit amet facilisis ante, ac suscipit sem. Integer feugiat sit amet erat sit amet mattis. Donec tristique, nunc ut varius elementum, nisi elit viverra ipsum, vitae aliquam justo libero in arcu. Quisque tempor et justo at malesuada. Curabitur justo dolor, ornare convallis sollicitudin sed, consectetur eu turpis. \n\nNulla et dui condimentum, laoreet lacus eu, ultrices nisl. Vivamus in ante volutpat, gravida nunc scelerisque, sagittis tellus. Nullam justo purus, sagittis a tincidunt a, maximus nec sem.", videoURL: URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4") ), LightboxImage( diff --git a/Example/DemoLightbox/Podfile.lock b/Example/DemoLightbox/Podfile.lock index 18b900a5..366c8e27 100644 --- a/Example/DemoLightbox/Podfile.lock +++ b/Example/DemoLightbox/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - Cache (4.0.0): + - Cache (4.0.2): - SwiftHash (~> 2.0.0) - Hue (3.0.0) - Imaginary (3.0.0): @@ -17,7 +17,7 @@ EXTERNAL SOURCES: :path: ../../ SPEC CHECKSUMS: - Cache: e73353960c614ab79b0c6911b8c39da05b334470 + Cache: 363b6899cee63c82ccbd291e64a6c202abc17a88 Hue: b8fe1e43eef13631331eebecb2198b68e2622f95 Imaginary: 2765d293d425cbed3b07fa11642554cbaebe913d Lightbox: e7de1d134eee502ca578a6ab13382c820965b7b3 From 9ede29331acf90490a5903db6517bfdf1ece6fca Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Tue, 3 Oct 2017 14:34:08 +0200 Subject: [PATCH 18/20] Make demo app universal --- Example/DemoLightbox/DemoLightbox.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Example/DemoLightbox/DemoLightbox.xcodeproj/project.pbxproj b/Example/DemoLightbox/DemoLightbox.xcodeproj/project.pbxproj index ab200261..bf695428 100644 --- a/Example/DemoLightbox/DemoLightbox.xcodeproj/project.pbxproj +++ b/Example/DemoLightbox/DemoLightbox.xcodeproj/project.pbxproj @@ -354,6 +354,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.DemoLightbox; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -368,6 +369,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = no.hyper.DemoLightbox; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; From 0bd57097aa4331ee5218e58009eb2c6094c107e0 Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Tue, 3 Oct 2017 14:41:40 +0200 Subject: [PATCH 19/20] Lock dependencies versions --- Cartfile | 4 ++-- Lightbox.podspec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cartfile b/Cartfile index ed7d9beb..c36489c2 100644 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1,2 @@ -github "hyperoslo/Hue" -github "hyperoslo/Imaginary" \ No newline at end of file +github "hyperoslo/Hue" ~> 3.0 +github "hyperoslo/Imaginary" ~> 3.0 \ No newline at end of file diff --git a/Lightbox.podspec b/Lightbox.podspec index d1579605..922f28d7 100644 --- a/Lightbox.podspec +++ b/Lightbox.podspec @@ -13,8 +13,8 @@ Pod::Spec.new do |s| s.ios.resource = 'Resources/Lightbox.bundle' s.frameworks = 'UIKit', 'AVFoundation', 'AVKit' - s.dependency 'Hue' - s.dependency 'Imaginary' + s.dependency 'Hue', '~> 3.0' + s.dependency 'Imaginary', '~> 3.0' s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' } end From 23340fc075b51ea993b985c1968339d5f673fc2c Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Tue, 3 Oct 2017 14:44:55 +0200 Subject: [PATCH 20/20] Update demo --- Example/DemoLightbox/Podfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Example/DemoLightbox/Podfile.lock b/Example/DemoLightbox/Podfile.lock index 366c8e27..a4851e74 100644 --- a/Example/DemoLightbox/Podfile.lock +++ b/Example/DemoLightbox/Podfile.lock @@ -5,8 +5,8 @@ PODS: - Imaginary (3.0.0): - Cache (~> 4.0) - Lightbox (2.0.0): - - Hue - - Imaginary + - Hue (~> 3.0) + - Imaginary (~> 3.0) - SwiftHash (2.0.0) DEPENDENCIES: @@ -20,7 +20,7 @@ SPEC CHECKSUMS: Cache: 363b6899cee63c82ccbd291e64a6c202abc17a88 Hue: b8fe1e43eef13631331eebecb2198b68e2622f95 Imaginary: 2765d293d425cbed3b07fa11642554cbaebe913d - Lightbox: e7de1d134eee502ca578a6ab13382c820965b7b3 + Lightbox: f7f1cc942d81e84d85095531208f5fe1bfd9c639 SwiftHash: d2e09b13495447178cdfb8e46e54a5c46f15f5a9 PODFILE CHECKSUM: 408ae3477507a1d4b7ff06ffb3f162eda443424f