diff --git a/.travis.yml b/.travis.yml index e92ef03..222fc97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ -osx_image: xcode7.3 +osx_image: xcode8 language: objective-c script: - xcodebuild clean build -project Pages.xcodeproj -scheme "Pages-iOS" -sdk iphonesimulator -- xcodebuild test -project Pages.xcodeproj -scheme "Pages-iOS" -sdk iphonesimulator diff --git a/Example/PagesDemo/PagesDemo.xcodeproj/project.pbxproj b/Example/PagesDemo/PagesDemo.xcodeproj/project.pbxproj index 15f0a25..b77c239 100644 --- a/Example/PagesDemo/PagesDemo.xcodeproj/project.pbxproj +++ b/Example/PagesDemo/PagesDemo.xcodeproj/project.pbxproj @@ -7,24 +7,24 @@ objects = { /* Begin PBXBuildFile section */ - AE2AF244A0553133B9C82435 /* Pods_PagesDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F94DB02BD60FBDD9DA33B012 /* Pods_PagesDemo.framework */; }; B5419FC31B8334AF00492760 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B5419FC21B8334AF00492760 /* Main.storyboard */; }; BDA1583B1AD7EEBD0011D55A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDA1583A1AD7EEBD0011D55A /* AppDelegate.swift */; }; BDA158421AD7EEBD0011D55A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BDA158411AD7EEBD0011D55A /* Images.xcassets */; }; D21166C21D246AC500DF0F05 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21166C11D246AC500DF0F05 /* ViewController.swift */; }; + EB9A324F80F8E19183804738 /* Pods_PagesDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D8D75E2000442C0954B67BB /* Pods_PagesDemo.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 4D53AC2379C1A94B3C908B7A /* Pods-PagesDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PagesDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-PagesDemo/Pods-PagesDemo.release.xcconfig"; sourceTree = ""; }; 5CC842350E1F3977A4540338 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 8E6E29859734123F31FE8509 /* Pods-PagesDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PagesDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-PagesDemo/Pods-PagesDemo.release.xcconfig"; sourceTree = ""; }; + 7902FAAA6AD3A100A941EABA /* Pods-PagesDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PagesDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PagesDemo/Pods-PagesDemo.debug.xcconfig"; sourceTree = ""; }; + 7D8D75E2000442C0954B67BB /* Pods_PagesDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PagesDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B5419FC21B8334AF00492760 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; BDA158361AD7EEBD0011D55A /* PagesDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PagesDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; BDA158391AD7EEBD0011D55A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; BDA1583A1AD7EEBD0011D55A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; BDA158411AD7EEBD0011D55A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; D21166C11D246AC500DF0F05 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - ED566712FA0708F6D81C017F /* Pods-PagesDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PagesDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PagesDemo/Pods-PagesDemo.debug.xcconfig"; sourceTree = ""; }; - F94DB02BD60FBDD9DA33B012 /* Pods_PagesDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PagesDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -32,7 +32,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - AE2AF244A0553133B9C82435 /* Pods_PagesDemo.framework in Frameworks */, + EB9A324F80F8E19183804738 /* Pods_PagesDemo.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -45,7 +45,7 @@ BDA158371AD7EEBD0011D55A /* PagesDemo */, 146D72941AB782920058798C /* Products */, 2B3869E498899759381B9821 /* Frameworks */, - 2901A02E0A66267BD148C8E2 /* Pods */, + B872D4DB0C6956DED8617C14 /* Pods */, ); indentWidth = 2; sourceTree = ""; @@ -59,22 +59,22 @@ name = Products; sourceTree = ""; }; - 2901A02E0A66267BD148C8E2 /* Pods */ = { + 2B3869E498899759381B9821 /* Frameworks */ = { isa = PBXGroup; children = ( - ED566712FA0708F6D81C017F /* Pods-PagesDemo.debug.xcconfig */, - 8E6E29859734123F31FE8509 /* Pods-PagesDemo.release.xcconfig */, + 5CC842350E1F3977A4540338 /* Pods.framework */, + 7D8D75E2000442C0954B67BB /* Pods_PagesDemo.framework */, ); - name = Pods; + name = Frameworks; sourceTree = ""; }; - 2B3869E498899759381B9821 /* Frameworks */ = { + B872D4DB0C6956DED8617C14 /* Pods */ = { isa = PBXGroup; children = ( - 5CC842350E1F3977A4540338 /* Pods.framework */, - F94DB02BD60FBDD9DA33B012 /* Pods_PagesDemo.framework */, + 7902FAAA6AD3A100A941EABA /* Pods-PagesDemo.debug.xcconfig */, + 4D53AC2379C1A94B3C908B7A /* Pods-PagesDemo.release.xcconfig */, ); - name = Frameworks; + name = Pods; sourceTree = ""; }; BDA158371AD7EEBD0011D55A /* PagesDemo */ = { @@ -104,12 +104,12 @@ isa = PBXNativeTarget; buildConfigurationList = BDA158561AD7EEBD0011D55A /* Build configuration list for PBXNativeTarget "PagesDemo" */; buildPhases = ( - 10073011B792E16704D7CFF4 /* 📦 Check Pods Manifest.lock */, + 87830C85FBE6ED63082B5499 /* [CP] Check Pods Manifest.lock */, BDA158321AD7EEBD0011D55A /* Sources */, BDA158331AD7EEBD0011D55A /* Frameworks */, BDA158341AD7EEBD0011D55A /* Resources */, - 35E7166636F63403946986AF /* 📦 Embed Pods Frameworks */, - C820C599A4B0CF79E65C0F41 /* 📦 Copy Pods Resources */, + B554188A1267DC415D32994D /* [CP] Embed Pods Frameworks */, + D6F93E8DFEC598DE2E65F40F /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -128,11 +128,12 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = Hyper; TargetAttributes = { BDA158351AD7EEBD0011D55A = { CreatedOnToolsVersion = 6.3; + LastSwiftMigration = 0800; }; }; }; @@ -167,29 +168,29 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 10073011B792E16704D7CFF4 /* 📦 Check Pods Manifest.lock */ = { + 87830C85FBE6ED63082B5499 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "📦 Check Pods Manifest.lock"; + 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 cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + 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; }; - 35E7166636F63403946986AF /* 📦 Embed Pods Frameworks */ = { + B554188A1267DC415D32994D /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "📦 Embed Pods Frameworks"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -197,14 +198,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-PagesDemo/Pods-PagesDemo-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - C820C599A4B0CF79E65C0F41 /* 📦 Copy Pods Resources */ = { + D6F93E8DFEC598DE2E65F40F /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "📦 Copy Pods Resources"; + name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -230,6 +231,7 @@ 146D72B41AB782920058798C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -240,8 +242,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -250,6 +254,7 @@ ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -266,12 +271,14 @@ MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; + SWIFT_VERSION = 3.0; }; name = Debug; }; 146D72B51AB782920058798C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -282,8 +289,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -291,6 +300,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -300,14 +310,17 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.2; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; VALIDATE_PRODUCT = YES; }; name = Release; }; BDA158521AD7EEBD0011D55A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = ED566712FA0708F6D81C017F /* Pods-PagesDemo.debug.xcconfig */; + baseConfigurationReference = 7902FAAA6AD3A100A941EABA /* Pods-PagesDemo.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_NO_COMMON_BLOCKS = YES; @@ -321,14 +334,16 @@ PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; BDA158531AD7EEBD0011D55A /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 8E6E29859734123F31FE8509 /* Pods-PagesDemo.release.xcconfig */; + baseConfigurationReference = 4D53AC2379C1A94B3C908B7A /* Pods-PagesDemo.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_NO_COMMON_BLOCKS = YES; @@ -337,6 +352,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "no.hyper.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Example/PagesDemo/PagesDemo/AppDelegate.swift b/Example/PagesDemo/PagesDemo/AppDelegate.swift index d648a4a..324bc10 100644 --- a/Example/PagesDemo/PagesDemo/AppDelegate.swift +++ b/Example/PagesDemo/PagesDemo/AppDelegate.swift @@ -7,23 +7,23 @@ 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 { let pages = pagesControllerInCode() // let pages = pagesControllerInStoryboard() let navigationController = UINavigationController(rootViewController: pages) pages.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Previous Page", - style: .Plain, + style: .plain, target: pages, - action: #selector(PagesController.previous)) + action: #selector(PagesController.moveBack)) pages.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Next Page", - style: .Plain, + style: .plain, target: pages, - action: #selector(PagesController.next)) + action: #selector(PagesController.moveForward)) - window = UIWindow(frame: UIScreen.mainScreen().bounds) + window = UIWindow(frame: UIScreen.main.bounds) window?.rootViewController = navigationController window?.makeKeyAndVisible() return true @@ -34,7 +34,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var viewControllers: [UIViewController] = [] for i in 0..<5 { - if let imageURL = NSURL(string: "https://unsplash.it/375/667/?image=\(i+10)") { + if let imageURL = URL(string: "https://unsplash.it/375/667/?image=\(i+10)") { let viewController = ViewController() viewController.imageView.setImage(imageURL) diff --git a/Example/PagesDemo/PagesDemo/ViewController.swift b/Example/PagesDemo/PagesDemo/ViewController.swift index ec844df..ea8e1c0 100644 --- a/Example/PagesDemo/PagesDemo/ViewController.swift +++ b/Example/PagesDemo/PagesDemo/ViewController.swift @@ -1,20 +1,20 @@ import UIKit -public class ViewController: UIViewController { +class ViewController: UIViewController { lazy var imageView = UIImageView() - public override func viewDidLoad() { + override func viewDidLoad() { super.viewDidLoad() view.addSubview(imageView) - imageView.contentMode = .ScaleAspectFill + imageView.contentMode = .scaleAspectFill imageView.translatesAutoresizingMaskIntoConstraints = false - imageView.topAnchor.constraintEqualToAnchor(view.topAnchor).active = true - imageView.leftAnchor.constraintEqualToAnchor(view.leftAnchor).active = true - imageView.rightAnchor.constraintEqualToAnchor(view.rightAnchor).active = true - imageView.bottomAnchor.constraintEqualToAnchor(view.bottomAnchor).active = true + imageView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true + imageView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true + imageView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true + imageView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true } } diff --git a/Example/PagesDemo/Podfile b/Example/PagesDemo/Podfile index ef5c1ed..56bb61e 100644 --- a/Example/PagesDemo/Podfile +++ b/Example/PagesDemo/Podfile @@ -4,6 +4,6 @@ platform :ios, '9.0' target 'PagesDemo' do pod 'Pages', path: '../../' - pod 'Imaginary', git: 'https://github.com/hyperoslo/Imaginary' + pod 'Imaginary', git: 'https://github.com/hyperoslo/Imaginary', branch: 'swift-3' + pod 'Cache', git: 'https://github.com/hyperoslo/Cache', branch: 'swift-3' end - diff --git a/Example/PagesDemo/Podfile.lock b/Example/PagesDemo/Podfile.lock index 6274036..49794df 100644 --- a/Example/PagesDemo/Podfile.lock +++ b/Example/PagesDemo/Podfile.lock @@ -1,32 +1,40 @@ PODS: - - Cache (1.4.0): + - Cache (1.5.1): - CryptoSwift - - CryptoSwift (0.5.1) + - CryptoSwift (0.6.0) - Imaginary (0.1.0): - Cache - Pages (0.6.3) DEPENDENCIES: - - Imaginary (from `https://github.com/hyperoslo/Imaginary`) + - Cache (from `https://github.com/hyperoslo/Cache`, branch `swift-3`) + - Imaginary (from `https://github.com/hyperoslo/Imaginary`, branch `swift-3`) - Pages (from `../../`) EXTERNAL SOURCES: + Cache: + :branch: swift-3 + :git: https://github.com/hyperoslo/Cache Imaginary: + :branch: swift-3 :git: https://github.com/hyperoslo/Imaginary Pages: :path: "../../" CHECKOUT OPTIONS: + Cache: + :commit: f4f1398fe02c762630a802b5e5ae9c334beafed9 + :git: https://github.com/hyperoslo/Cache Imaginary: - :commit: 4ab2007614aa2397a9ce82c69771f21df3d37cdc + :commit: b8780d8f5037ea49050bdca18087b9c92f53f502 :git: https://github.com/hyperoslo/Imaginary SPEC CHECKSUMS: - Cache: 059cf0e10e6c3aec2c402eea19bd6b3aacb3fe9d - CryptoSwift: df42dda18baf6c76347a94e227dbcc0a341304bd + Cache: 87b48b059429d3b53238533830c53941f8aa85f0 + CryptoSwift: 4a599b7241b8d3b857d6e2c28867d0bd5d1aae24 Imaginary: 62a9ce1e6d7831ede429c8221a183f03ec2a90bc Pages: 71e80bc64040f1176297c327d080d80b7e74b38c -PODFILE CHECKSUM: 651e7c1534e217a37653348ac0245c09a990e37f +PODFILE CHECKSUM: f6fbb74b8eb8023fc4977191667777541703f745 -COCOAPODS: 1.0.0 +COCOAPODS: 1.1.0.rc.2 diff --git a/Pages.xcodeproj/project.pbxproj b/Pages.xcodeproj/project.pbxproj index 8d28ff6..3ca3020 100644 --- a/Pages.xcodeproj/project.pbxproj +++ b/Pages.xcodeproj/project.pbxproj @@ -104,11 +104,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0720; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Hyper Interaktiv AS"; TargetAttributes = { D5DF754B1C401B1800BF1AB6 = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0800; }; }; }; @@ -166,8 +167,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -214,8 +217,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -235,6 +240,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.2; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -245,6 +251,7 @@ D5DF75611C401B1800BF1AB6 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -256,12 +263,14 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Pages; PRODUCT_NAME = Pages; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Debug; }; D5DF75621C401B1800BF1AB6 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -273,6 +282,7 @@ PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Pages; PRODUCT_NAME = Pages; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/Pages.xcodeproj/xcshareddata/xcschemes/Pages-iOS.xcscheme b/Pages.xcodeproj/xcshareddata/xcschemes/Pages-iOS.xcscheme index ac1165d..ab1702d 100644 --- a/Pages.xcodeproj/xcshareddata/xcschemes/Pages-iOS.xcscheme +++ b/Pages.xcodeproj/xcshareddata/xcschemes/Pages-iOS.xcscheme @@ -1,6 +1,6 @@ Element? { - if let index = index where index >= 0 && index < endIndex { + func at(_ index: Int?) -> Element? { + if let index = index , index >= 0 && index < endIndex { return self[index] } else { return nil @@ -9,10 +9,10 @@ extension Array { } } -func nextIndex(x: Int?) -> Int? { - return x?.successor() +func nextIndex(_ x: Int?) -> Int? { + return ((x)! + 1) } -func prevIndex(x: Int?) -> Int? { - return x?.predecessor() +func prevIndex(_ x: Int?) -> Int? { + return ((x)! - 1) } diff --git a/Source/PagesController.swift b/Source/PagesController.swift index 1e33ddc..bf315cf 100644 --- a/Source/PagesController.swift +++ b/Source/PagesController.swift @@ -2,10 +2,10 @@ import UIKit @objc(HYPPagesControllerDelegate) public protocol PagesControllerDelegate { - func pageViewController(pageViewController: UIPageViewController, setViewController viewController: UIViewController, atPage page: Int) + func pageViewController(_ pageViewController: UIPageViewController, setViewController viewController: UIViewController, atPage page: Int) } -@objc(HYPPagesController) public class PagesController: UIPageViewController { +@objc(HYPPagesController) open class PagesController: UIPageViewController { struct Dimensions { static let bottomLineHeight: CGFloat = 1.0 @@ -13,47 +13,47 @@ import UIKit static let bottomLineBottomMargin: CGFloat = 36.0 } - public var startPage = 0 - public var setNavigationTitle = true + open var startPage = 0 + open var setNavigationTitle = true - public var enableSwipe = true { + open var enableSwipe = true { didSet { toggle() } } - public var showBottomLine = false { + open var showBottomLine = false { didSet { - bottomLineView.hidden = !showBottomLine + bottomLineView.isHidden = !showBottomLine } } - public var showPageControl = true + open var showPageControl = true lazy var pages = Array() - public var pagesCount: Int { + open var pagesCount: Int { return pages.count } - public private(set) var currentIndex = 0 + open fileprivate(set) var currentIndex = 0 - public weak var pagesDelegate: PagesControllerDelegate? + open weak var pagesDelegate: PagesControllerDelegate? - public private(set) lazy var bottomLineView: UIView = { + open fileprivate(set) lazy var bottomLineView: UIView = { let view = UIView() view.translatesAutoresizingMaskIntoConstraints = false - view.backgroundColor = .whiteColor() + view.backgroundColor = UIColor.white view.alpha = 0.4 - view.hidden = true + view.isHidden = true return view }() - public private(set) var pageControl: UIPageControl? + open fileprivate(set) var pageControl: UIPageControl? public convenience init(_ pages: [UIViewController], - transitionStyle: UIPageViewControllerTransitionStyle = .Scroll, - navigationOrientation: UIPageViewControllerNavigationOrientation = .Horizontal, + transitionStyle: UIPageViewControllerTransitionStyle = .scroll, + navigationOrientation: UIPageViewControllerNavigationOrientation = .horizontal, options: [String : AnyObject]? = nil) { self.init(transitionStyle: transitionStyle, navigationOrientation: navigationOrientation, @@ -62,7 +62,7 @@ import UIKit add(pages) } - public override func viewDidLoad() { + open override func viewDidLoad() { super.viewDidLoad() delegate = self @@ -70,11 +70,11 @@ import UIKit view.addSubview(bottomLineView) addConstraints() - view.bringSubviewToFront(bottomLineView) + view.bringSubview(toFront: bottomLineView) goTo(startPage) } - public override func viewDidAppear(animated: Bool) { + open override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) for subview in view.subviews { @@ -88,9 +88,9 @@ import UIKit // MARK: Public methods extension PagesController { - public func goTo(index: Int) { + open func goTo(_ index: Int) { if index >= 0 && index < pages.count { - let direction: UIPageViewControllerNavigationDirection = (index > currentIndex) ? .Forward : .Reverse + let direction: UIPageViewControllerNavigationDirection = (index > currentIndex) ? .forward : .reverse let viewController = pages[index] currentIndex = index setViewControllers([viewController], @@ -107,15 +107,15 @@ extension PagesController { } } - public func next() { + open func moveForward() { goTo(currentIndex + 1) } - public func previous() { + open func moveBack() { goTo(currentIndex - 1) } - public func add(viewControllers: [UIViewController]) { + open func add(_ viewControllers: [UIViewController]) { for viewController in viewControllers { addViewController(viewController) } @@ -126,21 +126,21 @@ extension PagesController { extension PagesController : UIPageViewControllerDataSource { - public func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? { + open func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { let index = prevIndex(viewControllerIndex(viewController)) return pages.at(index) } - public func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? { + open func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { let index: Int? = nextIndex(viewControllerIndex(viewController)) return pages.at(index) } - public func presentationCountForPageViewController(pageViewController: UIPageViewController) -> Int { + open func presentationCount(for pageViewController: UIPageViewController) -> Int { return showPageControl ? pages.count : 0 } - public func presentationIndexForPageViewController(pageViewController: UIPageViewController) -> Int { + open func presentationIndex(for pageViewController: UIPageViewController) -> Int { return showPageControl ? currentIndex : 0 } } @@ -149,11 +149,11 @@ extension PagesController : UIPageViewControllerDataSource { extension PagesController : UIPageViewControllerDelegate { - public func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, + open func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) { if completed { if let viewController = pageViewController.viewControllers?.last, - index = viewControllerIndex(viewController) { + let index = viewControllerIndex(viewController) { currentIndex = index if setNavigationTitle { @@ -174,25 +174,25 @@ extension PagesController : UIPageViewControllerDelegate { extension PagesController { - func viewControllerIndex(viewController: UIViewController) -> Int? { - return pages.indexOf(viewController) + func viewControllerIndex(_ viewController: UIViewController) -> Int? { + return pages.index(of: viewController) } - private func toggle() { + fileprivate func toggle() { for subview in view.subviews { if let subview = subview as? UIScrollView { - subview.scrollEnabled = enableSwipe + subview.isScrollEnabled = enableSwipe break } } } - private func addViewController(viewController: UIViewController) { + fileprivate func addViewController(_ viewController: UIViewController) { pages.append(viewController) if pages.count == 1 { setViewControllers([viewController], - direction: .Forward, + direction: .forward, animated: true, completion: { [unowned self] finished in self.pagesDelegate?.pageViewController(self, @@ -205,21 +205,21 @@ extension PagesController { } } - private func addConstraints() { - view.addConstraint(NSLayoutConstraint(item: bottomLineView, attribute: .Bottom, - relatedBy: .Equal, toItem: view, attribute: .Bottom, + fileprivate func addConstraints() { + view.addConstraint(NSLayoutConstraint(item: bottomLineView, attribute: .bottom, + relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1, constant: -Dimensions.bottomLineBottomMargin)) - view.addConstraint(NSLayoutConstraint(item: bottomLineView, attribute: .Left, - relatedBy: .Equal, toItem: view, attribute: .Left, + view.addConstraint(NSLayoutConstraint(item: bottomLineView, attribute: .left, + relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1, constant: Dimensions.bottomLineSideMargin)) - view.addConstraint(NSLayoutConstraint(item: bottomLineView, attribute: .Right, - relatedBy: .Equal, toItem: view, attribute: .Right, + view.addConstraint(NSLayoutConstraint(item: bottomLineView, attribute: .right, + relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1, constant: -Dimensions.bottomLineSideMargin)) - view.addConstraint(NSLayoutConstraint(item: bottomLineView, attribute: .Height, - relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, + view.addConstraint(NSLayoutConstraint(item: bottomLineView, attribute: .height, + relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: Dimensions.bottomLineHeight)) } } @@ -229,7 +229,7 @@ extension PagesController { extension PagesController { public convenience init(_ storyboardIds: [String], storyboard: UIStoryboard = UIStoryboard.Main) { - let pages = storyboardIds.map(storyboard.instantiateViewControllerWithIdentifier) + let pages = storyboardIds.map(storyboard.instantiateViewController(withIdentifier:)) self.init(pages) } }