diff --git a/DeepLinkKit.podspec b/DeepLinkKit.podspec index b9a732c..9f49777 100644 --- a/DeepLinkKit.podspec +++ b/DeepLinkKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "DeepLinkKit" - s.version = "1.4.0" + s.version = "1.5.0" s.summary = "A splendid route-matching, block-based way to handle your deep links." s.description = <<-DESC DeepLink Kit is a splendid route-handling block-based way to handle deep links. Use DeepLink Kit to parse incoming URLs, extract parameters from the host, url etc.. and even build outgoing deep links. All with a simple, block-based interface. diff --git a/DeepLinkKit.xcodeproj/project.pbxproj b/DeepLinkKit.xcodeproj/project.pbxproj index d774862..273ac3b 100644 --- a/DeepLinkKit.xcodeproj/project.pbxproj +++ b/DeepLinkKit.xcodeproj/project.pbxproj @@ -830,7 +830,7 @@ attributes = { CLASSPREFIX = DPL; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Button, Inc."; TargetAttributes = { 6003F5AD195388D20070C39A = { @@ -838,6 +838,7 @@ }; 62335DD51B57003300E3818C = { CreatedOnToolsVersion = 6.4; + LastSwiftMigration = 0900; }; BFDB96ED1F3BFF8E001AE303 = { CreatedOnToolsVersion = 8.3.3; @@ -922,7 +923,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + 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"; showEnvVarsInLog = 0; }; 169E441B24A0182ECBEA02B1 /* [CP] Embed Pods Frameworks */ = { @@ -982,7 +983,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + 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"; showEnvVarsInLog = 0; }; 78E4A2B7A96651F3AE873F35 /* [CP] Check Pods Manifest.lock */ = { @@ -997,7 +998,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + 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"; showEnvVarsInLog = 0; }; 92CBDC92946CE1B22732C030 /* [CP] Copy Pods Resources */ = { @@ -1057,7 +1058,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + 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"; showEnvVarsInLog = 0; }; D0318767A555E3ECB0E5307A /* [CP] Copy Pods Resources */ = { @@ -1243,19 +1244,30 @@ 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; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; 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", @@ -1284,18 +1296,29 @@ 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; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; 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; @@ -1304,6 +1327,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -1397,6 +1421,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "SampleApps/ReceiverDemoSwift/ReceiverDemoSwift-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 1; }; name = Debug; @@ -1419,6 +1445,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.usebutton.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "SampleApps/ReceiverDemoSwift/ReceiverDemoSwift-Bridging-Header.h"; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 1; }; name = Test; @@ -1441,6 +1469,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.usebutton.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "SampleApps/ReceiverDemoSwift/ReceiverDemoSwift-Bridging-Header.h"; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 1; }; name = Release; @@ -1548,18 +1578,29 @@ 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; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = 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", @@ -1730,6 +1771,7 @@ BFDB96F51F3BFF8E001AE303 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; DEDB14AD1A3F944E00A837F8 /* Build configuration list for PBXNativeTarget "SenderDemo" */ = { isa = XCConfigurationList; diff --git a/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/DeepLinkKit.xcscheme b/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/DeepLinkKit.xcscheme index 9b4941b..6ac0847 100644 --- a/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/DeepLinkKit.xcscheme +++ b/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/DeepLinkKit.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/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/ReceiverDemo.xcscheme b/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/ReceiverDemo.xcscheme index 3c503d8..e854a20 100644 --- a/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/ReceiverDemo.xcscheme +++ b/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/ReceiverDemo.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/SenderDemo.xcscheme b/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/SenderDemo.xcscheme index 3992890..52d9a16 100644 --- a/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/SenderDemo.xcscheme +++ b/DeepLinkKit.xcodeproj/xcshareddata/xcschemes/SenderDemo.xcscheme @@ -1,6 +1,6 @@ ())"); /** @@ -138,6 +147,6 @@ typedef void(^DPLRouteCompletionBlock)(BOOL handled, NSError *error); @endcode @note The type of the returned handler is the type you registered for that route. */ -- (id)objectForKeyedSubscript:(NSString *)key; +- (id)objectForKeyedSubscript:(NSString *)key NS_SWIFT_UNAVAILABLE("Not Available"); @end diff --git a/DeepLinkKit/Router/DPLDeepLinkRouter.m b/DeepLinkKit/Router/DPLDeepLinkRouter.m index 3dad9bc..0a642b3 100644 --- a/DeepLinkKit/Router/DPLDeepLinkRouter.m +++ b/DeepLinkKit/Router/DPLDeepLinkRouter.m @@ -62,6 +62,11 @@ - (void)registerBlock:(DPLRouteHandlerBlock)routeHandlerBlock forRoute:(NSString } +- (void)register:(NSString *)route routeHandlerBlock:(DPLRouteHandlerBlock)routeHandlerBlock { + [self registerBlock:routeHandlerBlock forRoute:route]; +} + + #pragma mark - Registering Routes via Object Subscripting - (id)objectForKeyedSubscript:(NSString *)key { diff --git a/Podfile b/Podfile index 05018c8..21bb9ff 100644 --- a/Podfile +++ b/Podfile @@ -1,6 +1,7 @@ project 'DeepLinkKit.xcodeproj', 'Test' => :debug inhibit_all_warnings! use_frameworks! +platform :ios, '8.0' target 'SenderDemo' do pod 'DeepLinkKit', :path => '.' diff --git a/Podfile.lock b/Podfile.lock index fa9c401..8acf17b 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - DeepLinkKit (1.4.0) + - DeepLinkKit (1.5.0) - Expecta (1.0.6) - KIF (3.6.0): - KIF/Core (= 3.6.0) @@ -19,12 +19,12 @@ EXTERNAL SOURCES: :path: "." SPEC CHECKSUMS: - DeepLinkKit: bffd3b5e51549222f974d631b4e0e7484600b9d8 + DeepLinkKit: 98a26f2c5cf4c86b97c1170cdf3737ae49a3a50c Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5 KIF: bd770edd8ce49bc7308501e4871e58a02d137be3 OCMock: 35ae71d6a8fcc1b59434d561d1520b9dd4f15765 Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66 -PODFILE CHECKSUM: 47a943bbf5fb3be0a7f74806f054afe0fc7974ff +PODFILE CHECKSUM: c390f027c860b497aa35e691b8e585f706ac36a5 -COCOAPODS: 1.2.0 +COCOAPODS: 1.2.1 diff --git a/README.md b/README.md index c9a8b57..e899b01 100644 --- a/README.md +++ b/README.md @@ -79,11 +79,22 @@ Add deep link support to your app in 5 minutes or less following these simple st
**4. Register a route handler** +Objective-C ````objc self.router[@"/log/:message"] = ^(DPLDeepLink *link) { NSLog(@"%@", link.routeParameters[@"message"]); }; ```` + +Swift +````swift +self.router.register("/log/:message") { link in + if let link = link { + print("\(link.routeParameters["message"])") + } +} +```` +
**5. Pass incoming URLs to the router** diff --git a/SampleApps/ReceiverDemoSwift/DPLReceiverSwiftAppDelegate.swift b/SampleApps/ReceiverDemoSwift/DPLReceiverSwiftAppDelegate.swift index c709089..079908c 100644 --- a/SampleApps/ReceiverDemoSwift/DPLReceiverSwiftAppDelegate.swift +++ b/SampleApps/ReceiverDemoSwift/DPLReceiverSwiftAppDelegate.swift @@ -6,29 +6,46 @@ class DPLReceiverSwiftAppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? lazy var router: DPLDeepLinkRouter = DPLDeepLinkRouter() - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - // Register a class to a route using object subscripting - self.router["/product/:sku"] = DPLProductRouteHandler.self + // Register a block to a route (matches dpl:///product/93598) + self.router.register("/product/:sku") { link in + print("\(link!.url.absoluteString)") + + if let rootViewController = application.keyWindow?.rootViewController as? UINavigationController { + if let storyboard = rootViewController.storyboard { + if let controller = storyboard.instantiateViewController(withIdentifier: "detail") as? DPLTargetViewController { + controller.configure(with: link) + rootViewController.pushViewController(controller as! UIViewController, animated: false) + } + } + } + } - // Register a class to a route using the explicit registration call + self.router.register("/log/:message") { link in + if let link = link { + print("\(String(describing: link.routeParameters["message"]))") + } + } + + // Register a class to a route. self.router.registerHandlerClass(DPLMessageRouteHandler.self, forRoute: "/say/:title/:message") return true } - func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { - self.router.handleURL(url, withCompletion: nil) + func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { + self.router.handle(url, withCompletion: nil) return true } - func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { - self.router.handleURL(url, withCompletion: nil) + func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool { + self.router.handle(url, withCompletion: nil) return true } - func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool { - self.router.handleUserActivity(userActivity, withCompletion: nil) + func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool { + self.router.handle(userActivity, withCompletion: nil) return true } } diff --git a/SampleApps/ReceiverDemoSwift/RouteHandlers/DPLMessageRouteHandler.swift b/SampleApps/ReceiverDemoSwift/RouteHandlers/DPLMessageRouteHandler.swift index 4ed35ec..ec26259 100644 --- a/SampleApps/ReceiverDemoSwift/RouteHandlers/DPLMessageRouteHandler.swift +++ b/SampleApps/ReceiverDemoSwift/RouteHandlers/DPLMessageRouteHandler.swift @@ -1,9 +1,9 @@ import Foundation -public class DPLMessageRouteHandler: DPLRouteHandler { - public override func shouldHandleDeepLink(deepLink: DPLDeepLink!) -> Bool { +open class DPLMessageRouteHandler: DPLRouteHandler { + open override func shouldHandle(_ deepLink: DPLDeepLink!) -> Bool { if let title = deepLink.routeParameters["title"] as? String, - message = deepLink.routeParameters["message"] as? String { + let message = deepLink.routeParameters["message"] as? String { UIAlertView(title: title, message: message, delegate: nil, cancelButtonTitle: "OK").show() } return false diff --git a/SampleApps/ReceiverDemoSwift/RouteHandlers/DPLProductRouteHandler.swift b/SampleApps/ReceiverDemoSwift/RouteHandlers/DPLProductRouteHandler.swift index 1a4f68b..de29df7 100644 --- a/SampleApps/ReceiverDemoSwift/RouteHandlers/DPLProductRouteHandler.swift +++ b/SampleApps/ReceiverDemoSwift/RouteHandlers/DPLProductRouteHandler.swift @@ -1,11 +1,11 @@ import Foundation -public class DPLProductRouteHandler: DPLRouteHandler { - public override func targetViewController() -> UIViewController! { - if let storyboard = UIApplication.sharedApplication().keyWindow?.rootViewController?.storyboard { - return storyboard.instantiateViewControllerWithIdentifier("detail") as! DPLProductDetailViewController +open class DPLProductRouteHandler: DPLRouteHandler { + open override func targetViewController() -> UIViewController & DPLTargetViewController { + if let storyboard = UIApplication.shared.keyWindow?.rootViewController?.storyboard { + return storyboard.instantiateViewController(withIdentifier: "detail") as! DPLProductDetailViewController } - return UIViewController() + return super.targetViewController() } -} \ No newline at end of file +}