├── .swift-version ├── .travis.yml ├── Example ├── Podfile ├── Podfile.lock ├── Pods │ ├── Headers │ │ ├── Private │ │ │ └── WLRRoute │ │ │ │ ├── NSError+WLRError.h │ │ │ │ ├── NSString+WLRQuery.h │ │ │ │ ├── UIViewController+WLRRoute.h │ │ │ │ ├── WLRMatchResult.h │ │ │ │ ├── WLRRegularExpression.h │ │ │ │ ├── WLRRoute.h │ │ │ │ ├── WLRRouteHandler.h │ │ │ │ ├── WLRRouteMatcher.h │ │ │ │ ├── WLRRouteMiddlewareProtocol.h │ │ │ │ ├── WLRRouteRequest.h │ │ │ │ └── WLRRouter.h │ │ └── Public │ │ │ └── WLRRoute │ │ │ ├── NSError+WLRError.h │ │ │ ├── NSString+WLRQuery.h │ │ │ ├── UIViewController+WLRRoute.h │ │ │ ├── WLRMatchResult.h │ │ │ ├── WLRRegularExpression.h │ │ │ ├── WLRRoute.h │ │ │ ├── WLRRouteHandler.h │ │ │ ├── WLRRouteMatcher.h │ │ │ ├── WLRRouteMiddlewareProtocol.h │ │ │ ├── WLRRouteRequest.h │ │ │ └── WLRRouter.h │ ├── Local Podspecs │ │ └── WLRRoute.podspec.json │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ ├── project.pbxproj │ │ └── xcuserdata │ │ │ └── Neo.xcuserdatad │ │ │ └── xcschemes │ │ │ ├── Pods-WLRRoute_Example.xcscheme │ │ │ ├── Pods-WLRRoute_Tests.xcscheme │ │ │ ├── WLRRoute.xcscheme │ │ │ └── xcschememanagement.plist │ └── Target Support Files │ │ ├── Pods-WLRRoute_Example │ │ ├── Pods-WLRRoute_Example-acknowledgements.markdown │ │ ├── Pods-WLRRoute_Example-acknowledgements.plist │ │ ├── Pods-WLRRoute_Example-dummy.m │ │ ├── Pods-WLRRoute_Example-frameworks.sh │ │ ├── Pods-WLRRoute_Example-resources.sh │ │ ├── Pods-WLRRoute_Example.debug.xcconfig │ │ └── Pods-WLRRoute_Example.release.xcconfig │ │ ├── Pods-WLRRoute_Tests │ │ ├── Pods-WLRRoute_Tests-acknowledgements.markdown │ │ ├── Pods-WLRRoute_Tests-acknowledgements.plist │ │ ├── Pods-WLRRoute_Tests-dummy.m │ │ ├── Pods-WLRRoute_Tests-frameworks.sh │ │ ├── Pods-WLRRoute_Tests-resources.sh │ │ ├── Pods-WLRRoute_Tests.debug.xcconfig │ │ └── Pods-WLRRoute_Tests.release.xcconfig │ │ └── WLRRoute │ │ ├── WLRRoute-dummy.m │ │ ├── WLRRoute-prefix.pch │ │ └── WLRRoute.xcconfig ├── Tests │ ├── Tests-Info.plist │ ├── Tests-Prefix.pch │ ├── Tests.m │ └── en.lproj │ │ └── InfoPlist.strings ├── WLRRoute.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ ├── xcshareddata │ │ └── xcschemes │ │ │ └── WLRRoute-Example.xcscheme │ └── xcuserdata │ │ └── Neo.xcuserdatad │ │ └── xcschemes │ │ ├── WLRRoute_Tests.xcscheme │ │ └── xcschememanagement.plist ├── WLRRoute.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── Neo.xcuserdatad │ │ ├── UserInterfaceState.xcuserstate │ │ └── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist └── WLRRoute │ ├── HBXCALLBACKHandler.h │ ├── HBXCALLBACKHandler.m │ ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json │ ├── Main.storyboard │ ├── WLRAppDelegate.h │ ├── WLRAppDelegate.m │ ├── WLRRoute-Info.plist │ ├── WLRRoute-Prefix.pch │ ├── WLRSignHandler.h │ ├── WLRSignHandler.m │ ├── WLRSignViewController.h │ ├── WLRSignViewController.m │ ├── WLRUserHandler.h │ ├── WLRUserHandler.m │ ├── WLRUserViewController.h │ ├── WLRUserViewController.m │ ├── WLRViewController.h │ ├── WLRViewController.m │ ├── en.lproj │ └── InfoPlist.strings │ └── main.m ├── LICENSE ├── README.md ├── WLRRoute.podspec ├── WLRRoute ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── NSError+WLRError.h │ ├── NSError+WLRError.m │ ├── NSString+WLRQuery.h │ ├── NSString+WLRQuery.m │ ├── UIViewController+WLRRoute.h │ ├── UIViewController+WLRRoute.m │ ├── WLRMatchResult.h │ ├── WLRMatchResult.m │ ├── WLRRegularExpression.h │ ├── WLRRegularExpression.m │ ├── WLRRoute.h │ ├── WLRRouteHandler.h │ ├── WLRRouteHandler.m │ ├── WLRRouteMatcher.h │ ├── WLRRouteMatcher.m │ ├── WLRRouteMiddlewareProtocol.h │ ├── WLRRouteRequest.h │ ├── WLRRouteRequest.m │ ├── WLRRouter.h │ └── WLRRouter.m └── _Pods.xcodeproj /.swift-version: -------------------------------------------------------------------------------- 1 | 2.3 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * http://www.objc.io/issue-6/travis-ci.html 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -workspace Example/WLRRoute.xcworkspace -scheme WLRRoute-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | #use_frameworks! 2 | 3 | target 'WLRRoute_Example' do 4 | pod 'WLRRoute', :path => '../' 5 | 6 | target 'WLRRoute_Tests' do 7 | inherit! :search_paths 8 | 9 | 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - WLRRoute (0.0.9) 3 | 4 | DEPENDENCIES: 5 | - WLRRoute (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | WLRRoute: 9 | :path: ../ 10 | 11 | SPEC CHECKSUMS: 12 | WLRRoute: 1c0989116e8dbfde69975e0300744a1598fffcae 13 | 14 | PODFILE CHECKSUM: d2c1d30c37b28d4f92a50a6129b7c5fc7f2e356b 15 | 16 | COCOAPODS: 1.4.0 17 | -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/NSError+WLRError.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/NSError+WLRError.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/NSString+WLRQuery.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/NSString+WLRQuery.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/UIViewController+WLRRoute.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/UIViewController+WLRRoute.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/WLRMatchResult.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRMatchResult.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/WLRRegularExpression.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRegularExpression.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/WLRRoute.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRoute.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/WLRRouteHandler.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouteHandler.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/WLRRouteMatcher.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouteMatcher.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/WLRRouteMiddlewareProtocol.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouteMiddlewareProtocol.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/WLRRouteRequest.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouteRequest.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Private/WLRRoute/WLRRouter.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouter.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/NSError+WLRError.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/NSError+WLRError.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/NSString+WLRQuery.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/NSString+WLRQuery.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/UIViewController+WLRRoute.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/UIViewController+WLRRoute.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/WLRMatchResult.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRMatchResult.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/WLRRegularExpression.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRegularExpression.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/WLRRoute.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRoute.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/WLRRouteHandler.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouteHandler.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/WLRRouteMatcher.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouteMatcher.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/WLRRouteMiddlewareProtocol.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouteMiddlewareProtocol.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/WLRRouteRequest.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouteRequest.h -------------------------------------------------------------------------------- /Example/Pods/Headers/Public/WLRRoute/WLRRouter.h: -------------------------------------------------------------------------------- 1 | ../../../../../WLRRoute/Classes/WLRRouter.h -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/WLRRoute.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "WLRRoute", 3 | "version": "0.0.9", 4 | "summary": "WLRRoute is a simple route,it can provide Url matching and custom handler~", 5 | "description": "It is used to show how to build a route system in iOS app, and I keep it simple and clear.WLRRoute provide url matching , primitive parameters transfer, target callback block , custom handler can overwrite transitionWithRequest to navigate source to target.", 6 | "homepage": "https://github.com/Neojoke/WLRRoute", 7 | "license": { 8 | "type": "MIT", 9 | "file": "LICENSE" 10 | }, 11 | "authors": { 12 | "Neo": "394570610@qq.com" 13 | }, 14 | "source": { 15 | "git": "https://github.com/Neojoke/WLRRoute.git", 16 | "tag": "0.0.9" 17 | }, 18 | "platforms": { 19 | "ios": "7.0" 20 | }, 21 | "source_files": "WLRRoute/Classes/**/*" 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - WLRRoute (0.0.9) 3 | 4 | DEPENDENCIES: 5 | - WLRRoute (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | WLRRoute: 9 | :path: ../ 10 | 11 | SPEC CHECKSUMS: 12 | WLRRoute: 1c0989116e8dbfde69975e0300744a1598fffcae 13 | 14 | PODFILE CHECKSUM: d2c1d30c37b28d4f92a50a6129b7c5fc7f2e356b 15 | 16 | COCOAPODS: 1.4.0 17 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Neo.xcuserdatad/xcschemes/Pods-WLRRoute_Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Neo.xcuserdatad/xcschemes/Pods-WLRRoute_Tests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Neo.xcuserdatad/xcschemes/WLRRoute.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/xcuserdata/Neo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-WLRRoute_Example.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | Pods-WLRRoute_Tests.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 1 20 | 21 | WLRRoute.xcscheme 22 | 23 | isShown 24 | 25 | orderHint 26 | 2 27 | 28 | 29 | SuppressBuildableAutocreation 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## WLRRoute 5 | 6 | Copyright (c) 2016 Neo <394570610@qq.com> 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | Generated by CocoaPods - https://cocoapods.org 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2016 Neo <394570610@qq.com> 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | License 38 | MIT 39 | Title 40 | WLRRoute 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Generated by CocoaPods - https://cocoapods.org 47 | Title 48 | 49 | Type 50 | PSGroupSpecifier 51 | 52 | 53 | StringsTable 54 | Acknowledgements 55 | Title 56 | Acknowledgements 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_WLRRoute_Example : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_WLRRoute_Example 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | # Used as a return value for each invocation of `strip_invalid_archs` function. 10 | STRIP_BINARY_RETVAL=0 11 | 12 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 13 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 14 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 15 | 16 | # Copies and strips a vendored framework 17 | install_framework() 18 | { 19 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 20 | local source="${BUILT_PRODUCTS_DIR}/$1" 21 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 22 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 23 | elif [ -r "$1" ]; then 24 | local source="$1" 25 | fi 26 | 27 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 28 | 29 | if [ -L "${source}" ]; then 30 | echo "Symlinked..." 31 | source="$(readlink "${source}")" 32 | fi 33 | 34 | # Use filter instead of exclude so missing patterns don't throw errors. 35 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 36 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 37 | 38 | local basename 39 | basename="$(basename -s .framework "$1")" 40 | binary="${destination}/${basename}.framework/${basename}" 41 | if ! [ -r "$binary" ]; then 42 | binary="${destination}/${basename}" 43 | fi 44 | 45 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 46 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 47 | strip_invalid_archs "$binary" 48 | fi 49 | 50 | # Resign the code if required by the build settings to avoid unstable apps 51 | code_sign_if_enabled "${destination}/$(basename "$1")" 52 | 53 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 54 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 55 | local swift_runtime_libs 56 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 57 | for lib in $swift_runtime_libs; do 58 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 59 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 60 | code_sign_if_enabled "${destination}/${lib}" 61 | done 62 | fi 63 | } 64 | 65 | # Copies and strips a vendored dSYM 66 | install_dsym() { 67 | local source="$1" 68 | if [ -r "$source" ]; then 69 | # Copy the dSYM into a the targets temp dir. 70 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" 71 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" 72 | 73 | local basename 74 | basename="$(basename -s .framework.dSYM "$source")" 75 | binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" 76 | 77 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 78 | if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then 79 | strip_invalid_archs "$binary" 80 | fi 81 | 82 | if [[ $STRIP_BINARY_RETVAL == 1 ]]; then 83 | # Move the stripped file into its final destination. 84 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" 85 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" 86 | else 87 | # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. 88 | touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" 89 | fi 90 | fi 91 | } 92 | 93 | # Signs a framework with the provided identity 94 | code_sign_if_enabled() { 95 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 96 | # Use the current code_sign_identitiy 97 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 98 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 99 | 100 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 101 | code_sign_cmd="$code_sign_cmd &" 102 | fi 103 | echo "$code_sign_cmd" 104 | eval "$code_sign_cmd" 105 | fi 106 | } 107 | 108 | # Strip invalid architectures 109 | strip_invalid_archs() { 110 | binary="$1" 111 | # Get architectures for current target binary 112 | binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" 113 | # Intersect them with the architectures we are building for 114 | intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" 115 | # If there are no archs supported by this binary then warn the user 116 | if [[ -z "$intersected_archs" ]]; then 117 | echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." 118 | STRIP_BINARY_RETVAL=0 119 | return 120 | fi 121 | stripped="" 122 | for arch in $binary_archs; do 123 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 124 | # Strip non-valid architectures in-place 125 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 126 | stripped="$stripped $arch" 127 | fi 128 | done 129 | if [[ "$stripped" ]]; then 130 | echo "Stripped $binary of architectures:$stripped" 131 | fi 132 | STRIP_BINARY_RETVAL=1 133 | } 134 | 135 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 136 | wait 137 | fi 138 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 12 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 13 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 14 | 15 | case "${TARGETED_DEVICE_FAMILY}" in 16 | 1,2) 17 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 18 | ;; 19 | 1) 20 | TARGET_DEVICE_ARGS="--target-device iphone" 21 | ;; 22 | 2) 23 | TARGET_DEVICE_ARGS="--target-device ipad" 24 | ;; 25 | 3) 26 | TARGET_DEVICE_ARGS="--target-device tv" 27 | ;; 28 | 4) 29 | TARGET_DEVICE_ARGS="--target-device watch" 30 | ;; 31 | *) 32 | TARGET_DEVICE_ARGS="--target-device mac" 33 | ;; 34 | esac 35 | 36 | install_resource() 37 | { 38 | if [[ "$1" = /* ]] ; then 39 | RESOURCE_PATH="$1" 40 | else 41 | RESOURCE_PATH="${PODS_ROOT}/$1" 42 | fi 43 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 44 | cat << EOM 45 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 46 | EOM 47 | exit 1 48 | fi 49 | case $RESOURCE_PATH in 50 | *.storyboard) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.xib) 55 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 56 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 57 | ;; 58 | *.framework) 59 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 60 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 61 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 62 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 63 | ;; 64 | *.xcdatamodel) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 67 | ;; 68 | *.xcdatamodeld) 69 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true 70 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 71 | ;; 72 | *.xcmappingmodel) 73 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true 74 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 75 | ;; 76 | *.xcassets) 77 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 78 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 79 | ;; 80 | *) 81 | echo "$RESOURCE_PATH" || true 82 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 83 | ;; 84 | esac 85 | } 86 | 87 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 89 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 90 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 91 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 92 | fi 93 | rm -f "$RESOURCES_TO_COPY" 94 | 95 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 96 | then 97 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 98 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 99 | while read line; do 100 | if [[ $line != "${PODS_ROOT}*" ]]; then 101 | XCASSET_FILES+=("$line") 102 | fi 103 | done <<<"$OTHER_XCASSETS" 104 | 105 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 106 | fi 107 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/WLRRoute" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/WLRRoute" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/WLRRoute" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"WLRRoute" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/WLRRoute" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/WLRRoute" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/WLRRoute" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"WLRRoute" 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_WLRRoute_Tests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_WLRRoute_Tests 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | # Used as a return value for each invocation of `strip_invalid_archs` function. 10 | STRIP_BINARY_RETVAL=0 11 | 12 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 13 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 14 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 15 | 16 | # Copies and strips a vendored framework 17 | install_framework() 18 | { 19 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 20 | local source="${BUILT_PRODUCTS_DIR}/$1" 21 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 22 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 23 | elif [ -r "$1" ]; then 24 | local source="$1" 25 | fi 26 | 27 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 28 | 29 | if [ -L "${source}" ]; then 30 | echo "Symlinked..." 31 | source="$(readlink "${source}")" 32 | fi 33 | 34 | # Use filter instead of exclude so missing patterns don't throw errors. 35 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 36 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 37 | 38 | local basename 39 | basename="$(basename -s .framework "$1")" 40 | binary="${destination}/${basename}.framework/${basename}" 41 | if ! [ -r "$binary" ]; then 42 | binary="${destination}/${basename}" 43 | fi 44 | 45 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 46 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 47 | strip_invalid_archs "$binary" 48 | fi 49 | 50 | # Resign the code if required by the build settings to avoid unstable apps 51 | code_sign_if_enabled "${destination}/$(basename "$1")" 52 | 53 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 54 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 55 | local swift_runtime_libs 56 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 57 | for lib in $swift_runtime_libs; do 58 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 59 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 60 | code_sign_if_enabled "${destination}/${lib}" 61 | done 62 | fi 63 | } 64 | 65 | # Copies and strips a vendored dSYM 66 | install_dsym() { 67 | local source="$1" 68 | if [ -r "$source" ]; then 69 | # Copy the dSYM into a the targets temp dir. 70 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" 71 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" 72 | 73 | local basename 74 | basename="$(basename -s .framework.dSYM "$source")" 75 | binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" 76 | 77 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 78 | if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then 79 | strip_invalid_archs "$binary" 80 | fi 81 | 82 | if [[ $STRIP_BINARY_RETVAL == 1 ]]; then 83 | # Move the stripped file into its final destination. 84 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" 85 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" 86 | else 87 | # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. 88 | touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" 89 | fi 90 | fi 91 | } 92 | 93 | # Signs a framework with the provided identity 94 | code_sign_if_enabled() { 95 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 96 | # Use the current code_sign_identitiy 97 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 98 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 99 | 100 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 101 | code_sign_cmd="$code_sign_cmd &" 102 | fi 103 | echo "$code_sign_cmd" 104 | eval "$code_sign_cmd" 105 | fi 106 | } 107 | 108 | # Strip invalid architectures 109 | strip_invalid_archs() { 110 | binary="$1" 111 | # Get architectures for current target binary 112 | binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" 113 | # Intersect them with the architectures we are building for 114 | intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" 115 | # If there are no archs supported by this binary then warn the user 116 | if [[ -z "$intersected_archs" ]]; then 117 | echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." 118 | STRIP_BINARY_RETVAL=0 119 | return 120 | fi 121 | stripped="" 122 | for arch in $binary_archs; do 123 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 124 | # Strip non-valid architectures in-place 125 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 126 | stripped="$stripped $arch" 127 | fi 128 | done 129 | if [[ "$stripped" ]]; then 130 | echo "Stripped $binary of architectures:$stripped" 131 | fi 132 | STRIP_BINARY_RETVAL=1 133 | } 134 | 135 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 136 | wait 137 | fi 138 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 12 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 13 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 14 | 15 | case "${TARGETED_DEVICE_FAMILY}" in 16 | 1,2) 17 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 18 | ;; 19 | 1) 20 | TARGET_DEVICE_ARGS="--target-device iphone" 21 | ;; 22 | 2) 23 | TARGET_DEVICE_ARGS="--target-device ipad" 24 | ;; 25 | 3) 26 | TARGET_DEVICE_ARGS="--target-device tv" 27 | ;; 28 | 4) 29 | TARGET_DEVICE_ARGS="--target-device watch" 30 | ;; 31 | *) 32 | TARGET_DEVICE_ARGS="--target-device mac" 33 | ;; 34 | esac 35 | 36 | install_resource() 37 | { 38 | if [[ "$1" = /* ]] ; then 39 | RESOURCE_PATH="$1" 40 | else 41 | RESOURCE_PATH="${PODS_ROOT}/$1" 42 | fi 43 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 44 | cat << EOM 45 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 46 | EOM 47 | exit 1 48 | fi 49 | case $RESOURCE_PATH in 50 | *.storyboard) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.xib) 55 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 56 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 57 | ;; 58 | *.framework) 59 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 60 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 61 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 62 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 63 | ;; 64 | *.xcdatamodel) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 67 | ;; 68 | *.xcdatamodeld) 69 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true 70 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 71 | ;; 72 | *.xcmappingmodel) 73 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true 74 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 75 | ;; 76 | *.xcassets) 77 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 78 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 79 | ;; 80 | *) 81 | echo "$RESOURCE_PATH" || true 82 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 83 | ;; 84 | esac 85 | } 86 | 87 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 89 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 90 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 91 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 92 | fi 93 | rm -f "$RESOURCES_TO_COPY" 94 | 95 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 96 | then 97 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 98 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 99 | while read line; do 100 | if [[ $line != "${PODS_ROOT}*" ]]; then 101 | XCASSET_FILES+=("$line") 102 | fi 103 | done <<<"$OTHER_XCASSETS" 104 | 105 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 106 | fi 107 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/WLRRoute" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/WLRRoute" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/WLRRoute" 5 | OTHER_LDFLAGS = $(inherited) -ObjC 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/WLRRoute" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/WLRRoute" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/WLRRoute" 5 | OTHER_LDFLAGS = $(inherited) -ObjC 6 | PODS_BUILD_DIR = ${BUILD_DIR} 7 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/WLRRoute/WLRRoute-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_WLRRoute : NSObject 3 | @end 4 | @implementation PodsDummy_WLRRoute 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/WLRRoute/WLRRoute-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/WLRRoute/WLRRoute.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/WLRRoute 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/WLRRoute" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/WLRRoute" 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Example/Tests/Tests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/Tests/Tests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // The contents of this file are implicitly included at the beginning of every test case source file. 2 | 3 | #ifdef __OBJC__ 4 | 5 | 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /Example/Tests/Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouteTests.m 3 | // WLRRouteTests 4 | // 5 | // Created by Neo on 12/18/2016. 6 | // Copyright (c) 2016 Neo. All rights reserved. 7 | // 8 | 9 | @import XCTest; 10 | #import 11 | #import "HBXCALLBACKHandler.h" 12 | @interface Tests : XCTestCase 13 | @property(nonatomic,strong)WLRRouter * router; 14 | 15 | @end 16 | 17 | @implementation Tests 18 | 19 | - (void)setUp 20 | { 21 | self.router = [[WLRRouter alloc]init]; 22 | [super setUp]; 23 | // Put setup code here. This method is called before the invocation of each test method in the class. 24 | } 25 | 26 | - (void)tearDown 27 | { 28 | // Put teardown code here. This method is called after the invocation of each test method in the class. 29 | [super tearDown]; 30 | } 31 | 32 | - (void)testExample 33 | { 34 | self.router = [[WLRRouter alloc]init]; 35 | [self.router registerHandler:[[HBXCALLBACKHandler alloc]init] forRoute:@"x-call-back/:path(.*)"]; 36 | NSURL * url = [NSURL URLWithString:@"WLRDemo://x-call-back/user/register?x-success=WLRDemo%3a%2f%2fx-call-back%2fuser%2fregister_success&x-error=WLRDemo%3a%2f%2fx-call-back%2falert%26message%3dregister+fail&phone=15890077643"]; 37 | [self.router handleURL:url primitiveParameters:nil targetCallBack:^(NSError *error, id responseObject) { 38 | 39 | } withCompletionBlock:^(BOOL handled, NSError *error) { 40 | 41 | }]; 42 | } 43 | 44 | @end 45 | 46 | -------------------------------------------------------------------------------- /Example/Tests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/WLRRoute.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4B17C2FB283B5E0EDF457674 /* libPods-WLRRoute_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 345940877F636B03192F1CA8 /* libPods-WLRRoute_Example.a */; }; 11 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 12 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; }; 13 | 6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 14 | 6003F598195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F596195388D20070C39A /* InfoPlist.strings */; }; 15 | 6003F59A195388D20070C39A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F599195388D20070C39A /* main.m */; }; 16 | 6003F59E195388D20070C39A /* WLRAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F59D195388D20070C39A /* WLRAppDelegate.m */; }; 17 | 6003F5A7195388D20070C39A /* WLRViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5A6195388D20070C39A /* WLRViewController.m */; }; 18 | 6003F5A9195388D20070C39A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5A8195388D20070C39A /* Images.xcassets */; }; 19 | 6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F5AF195388D20070C39A /* XCTest.framework */; }; 20 | 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 21 | 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 22 | 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; }; 23 | 6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; }; 24 | 71E5C937227B410332C10DF9 /* libPods-WLRRoute_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F6F3137D472ABCEDDC83CDD /* libPods-WLRRoute_Tests.a */; }; 25 | 76B4BC821E06A18400D1E590 /* WLRSignHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 76B4BC811E06A18400D1E590 /* WLRSignHandler.m */; }; 26 | 76B4BC851E06A18E00D1E590 /* WLRUserHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 76B4BC841E06A18E00D1E590 /* WLRUserHandler.m */; }; 27 | 76B4BC881E06A1A100D1E590 /* WLRSignViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 76B4BC871E06A1A100D1E590 /* WLRSignViewController.m */; }; 28 | 76B4BC8B1E06A1AA00D1E590 /* WLRUserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 76B4BC8A1E06A1AA00D1E590 /* WLRUserViewController.m */; }; 29 | 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; 30 | B539A64D207DA1B9006B789B /* HBXCALLBACKHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = B539A64C207DA1B9006B789B /* HBXCALLBACKHandler.m */; }; 31 | /* End PBXBuildFile section */ 32 | 33 | /* Begin PBXContainerItemProxy section */ 34 | 6003F5B3195388D20070C39A /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = 6003F582195388D10070C39A /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = 6003F589195388D20070C39A; 39 | remoteInfo = WLRRoute; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | 345940877F636B03192F1CA8 /* libPods-WLRRoute_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-WLRRoute_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 59B886F0E311760DF80A2263 /* Pods-WLRRoute_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WLRRoute_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example.debug.xcconfig"; sourceTree = ""; }; 46 | 5F6F3137D472ABCEDDC83CDD /* libPods-WLRRoute_Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-WLRRoute_Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | 6003F58A195388D20070C39A /* WLRRoute_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WLRRoute_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 49 | 6003F58F195388D20070C39A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 50 | 6003F591195388D20070C39A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 51 | 6003F595195388D20070C39A /* WLRRoute-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "WLRRoute-Info.plist"; sourceTree = ""; }; 52 | 6003F597195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 53 | 6003F599195388D20070C39A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 54 | 6003F59B195388D20070C39A /* WLRRoute-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WLRRoute-Prefix.pch"; sourceTree = ""; }; 55 | 6003F59C195388D20070C39A /* WLRAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WLRAppDelegate.h; sourceTree = ""; }; 56 | 6003F59D195388D20070C39A /* WLRAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WLRAppDelegate.m; sourceTree = ""; }; 57 | 6003F5A5195388D20070C39A /* WLRViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WLRViewController.h; sourceTree = ""; }; 58 | 6003F5A6195388D20070C39A /* WLRViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WLRViewController.m; sourceTree = ""; }; 59 | 6003F5A8195388D20070C39A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 60 | 6003F5AE195388D20070C39A /* WLRRoute_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WLRRoute_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | 6003F5AF195388D20070C39A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 62 | 6003F5B7195388D20070C39A /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = ""; }; 63 | 6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 64 | 6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; 65 | 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; 66 | 6332ECC62B1D02852DBA1093 /* Pods-WLRRoute_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WLRRoute_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example.release.xcconfig"; sourceTree = ""; }; 67 | 76B4BC801E06A18400D1E590 /* WLRSignHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WLRSignHandler.h; sourceTree = ""; }; 68 | 76B4BC811E06A18400D1E590 /* WLRSignHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WLRSignHandler.m; sourceTree = ""; }; 69 | 76B4BC831E06A18E00D1E590 /* WLRUserHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WLRUserHandler.h; sourceTree = ""; }; 70 | 76B4BC841E06A18E00D1E590 /* WLRUserHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WLRUserHandler.m; sourceTree = ""; }; 71 | 76B4BC861E06A1A100D1E590 /* WLRSignViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WLRSignViewController.h; sourceTree = ""; }; 72 | 76B4BC871E06A1A100D1E590 /* WLRSignViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WLRSignViewController.m; sourceTree = ""; }; 73 | 76B4BC891E06A1AA00D1E590 /* WLRUserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WLRUserViewController.h; sourceTree = ""; }; 74 | 76B4BC8A1E06A1AA00D1E590 /* WLRUserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WLRUserViewController.m; sourceTree = ""; }; 75 | 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 76 | A51FE03D28BD66089799BAAB /* Pods-WLRRoute_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WLRRoute_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests.debug.xcconfig"; sourceTree = ""; }; 77 | A70B44062FFC608A80874DF9 /* WLRRoute.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = WLRRoute.podspec; path = ../WLRRoute.podspec; sourceTree = ""; }; 78 | B302507AE219196694EE98E8 /* Pods-WLRRoute_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WLRRoute_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests.release.xcconfig"; sourceTree = ""; }; 79 | B539A64B207DA1B9006B789B /* HBXCALLBACKHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBXCALLBACKHandler.h; sourceTree = ""; }; 80 | B539A64C207DA1B9006B789B /* HBXCALLBACKHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HBXCALLBACKHandler.m; sourceTree = ""; }; 81 | C510FB8F4568A3C6FF99CC18 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 82 | F95F48B9A76F6072E199C0FC /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 83 | /* End PBXFileReference section */ 84 | 85 | /* Begin PBXFrameworksBuildPhase section */ 86 | 6003F587195388D20070C39A /* Frameworks */ = { 87 | isa = PBXFrameworksBuildPhase; 88 | buildActionMask = 2147483647; 89 | files = ( 90 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */, 91 | 6003F592195388D20070C39A /* UIKit.framework in Frameworks */, 92 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */, 93 | 4B17C2FB283B5E0EDF457674 /* libPods-WLRRoute_Example.a in Frameworks */, 94 | ); 95 | runOnlyForDeploymentPostprocessing = 0; 96 | }; 97 | 6003F5AB195388D20070C39A /* Frameworks */ = { 98 | isa = PBXFrameworksBuildPhase; 99 | buildActionMask = 2147483647; 100 | files = ( 101 | 6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */, 102 | 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */, 103 | 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */, 104 | 71E5C937227B410332C10DF9 /* libPods-WLRRoute_Tests.a in Frameworks */, 105 | ); 106 | runOnlyForDeploymentPostprocessing = 0; 107 | }; 108 | /* End PBXFrameworksBuildPhase section */ 109 | 110 | /* Begin PBXGroup section */ 111 | 6003F581195388D10070C39A = { 112 | isa = PBXGroup; 113 | children = ( 114 | 60FF7A9C1954A5C5007DD14C /* Podspec Metadata */, 115 | 6003F593195388D20070C39A /* Example for WLRRoute */, 116 | 6003F5B5195388D20070C39A /* Tests */, 117 | 6003F58C195388D20070C39A /* Frameworks */, 118 | 6003F58B195388D20070C39A /* Products */, 119 | B21821B13EC01A655E28660F /* Pods */, 120 | ); 121 | sourceTree = ""; 122 | }; 123 | 6003F58B195388D20070C39A /* Products */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 6003F58A195388D20070C39A /* WLRRoute_Example.app */, 127 | 6003F5AE195388D20070C39A /* WLRRoute_Tests.xctest */, 128 | ); 129 | name = Products; 130 | sourceTree = ""; 131 | }; 132 | 6003F58C195388D20070C39A /* Frameworks */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 6003F58D195388D20070C39A /* Foundation.framework */, 136 | 6003F58F195388D20070C39A /* CoreGraphics.framework */, 137 | 6003F591195388D20070C39A /* UIKit.framework */, 138 | 6003F5AF195388D20070C39A /* XCTest.framework */, 139 | 345940877F636B03192F1CA8 /* libPods-WLRRoute_Example.a */, 140 | 5F6F3137D472ABCEDDC83CDD /* libPods-WLRRoute_Tests.a */, 141 | ); 142 | name = Frameworks; 143 | sourceTree = ""; 144 | }; 145 | 6003F593195388D20070C39A /* Example for WLRRoute */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | 6003F59C195388D20070C39A /* WLRAppDelegate.h */, 149 | 6003F59D195388D20070C39A /* WLRAppDelegate.m */, 150 | 76B4BC801E06A18400D1E590 /* WLRSignHandler.h */, 151 | 76B4BC811E06A18400D1E590 /* WLRSignHandler.m */, 152 | 76B4BC831E06A18E00D1E590 /* WLRUserHandler.h */, 153 | 76B4BC841E06A18E00D1E590 /* WLRUserHandler.m */, 154 | 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */, 155 | 6003F5A5195388D20070C39A /* WLRViewController.h */, 156 | 6003F5A6195388D20070C39A /* WLRViewController.m */, 157 | 76B4BC861E06A1A100D1E590 /* WLRSignViewController.h */, 158 | 76B4BC871E06A1A100D1E590 /* WLRSignViewController.m */, 159 | 76B4BC891E06A1AA00D1E590 /* WLRUserViewController.h */, 160 | 76B4BC8A1E06A1AA00D1E590 /* WLRUserViewController.m */, 161 | B539A64B207DA1B9006B789B /* HBXCALLBACKHandler.h */, 162 | B539A64C207DA1B9006B789B /* HBXCALLBACKHandler.m */, 163 | 6003F5A8195388D20070C39A /* Images.xcassets */, 164 | 6003F594195388D20070C39A /* Supporting Files */, 165 | ); 166 | name = "Example for WLRRoute"; 167 | path = WLRRoute; 168 | sourceTree = ""; 169 | }; 170 | 6003F594195388D20070C39A /* Supporting Files */ = { 171 | isa = PBXGroup; 172 | children = ( 173 | 6003F595195388D20070C39A /* WLRRoute-Info.plist */, 174 | 6003F596195388D20070C39A /* InfoPlist.strings */, 175 | 6003F599195388D20070C39A /* main.m */, 176 | 6003F59B195388D20070C39A /* WLRRoute-Prefix.pch */, 177 | ); 178 | name = "Supporting Files"; 179 | sourceTree = ""; 180 | }; 181 | 6003F5B5195388D20070C39A /* Tests */ = { 182 | isa = PBXGroup; 183 | children = ( 184 | 6003F5BB195388D20070C39A /* Tests.m */, 185 | 6003F5B6195388D20070C39A /* Supporting Files */, 186 | ); 187 | path = Tests; 188 | sourceTree = ""; 189 | }; 190 | 6003F5B6195388D20070C39A /* Supporting Files */ = { 191 | isa = PBXGroup; 192 | children = ( 193 | 6003F5B7195388D20070C39A /* Tests-Info.plist */, 194 | 6003F5B8195388D20070C39A /* InfoPlist.strings */, 195 | 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */, 196 | ); 197 | name = "Supporting Files"; 198 | sourceTree = ""; 199 | }; 200 | 60FF7A9C1954A5C5007DD14C /* Podspec Metadata */ = { 201 | isa = PBXGroup; 202 | children = ( 203 | A70B44062FFC608A80874DF9 /* WLRRoute.podspec */, 204 | F95F48B9A76F6072E199C0FC /* README.md */, 205 | C510FB8F4568A3C6FF99CC18 /* LICENSE */, 206 | ); 207 | name = "Podspec Metadata"; 208 | sourceTree = ""; 209 | }; 210 | B21821B13EC01A655E28660F /* Pods */ = { 211 | isa = PBXGroup; 212 | children = ( 213 | 59B886F0E311760DF80A2263 /* Pods-WLRRoute_Example.debug.xcconfig */, 214 | 6332ECC62B1D02852DBA1093 /* Pods-WLRRoute_Example.release.xcconfig */, 215 | A51FE03D28BD66089799BAAB /* Pods-WLRRoute_Tests.debug.xcconfig */, 216 | B302507AE219196694EE98E8 /* Pods-WLRRoute_Tests.release.xcconfig */, 217 | ); 218 | name = Pods; 219 | sourceTree = ""; 220 | }; 221 | /* End PBXGroup section */ 222 | 223 | /* Begin PBXNativeTarget section */ 224 | 6003F589195388D20070C39A /* WLRRoute_Example */ = { 225 | isa = PBXNativeTarget; 226 | buildConfigurationList = 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "WLRRoute_Example" */; 227 | buildPhases = ( 228 | A2B1765A7794B254AC866883 /* [CP] Check Pods Manifest.lock */, 229 | 6003F586195388D20070C39A /* Sources */, 230 | 6003F587195388D20070C39A /* Frameworks */, 231 | 6003F588195388D20070C39A /* Resources */, 232 | 8612F947377B3134604C6753 /* [CP] Embed Pods Frameworks */, 233 | A8BC8FD0F0FEE36DA1874CE3 /* [CP] Copy Pods Resources */, 234 | ); 235 | buildRules = ( 236 | ); 237 | dependencies = ( 238 | ); 239 | name = WLRRoute_Example; 240 | productName = WLRRoute; 241 | productReference = 6003F58A195388D20070C39A /* WLRRoute_Example.app */; 242 | productType = "com.apple.product-type.application"; 243 | }; 244 | 6003F5AD195388D20070C39A /* WLRRoute_Tests */ = { 245 | isa = PBXNativeTarget; 246 | buildConfigurationList = 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "WLRRoute_Tests" */; 247 | buildPhases = ( 248 | A601401B611ABE8D5EB685AE /* [CP] Check Pods Manifest.lock */, 249 | 6003F5AA195388D20070C39A /* Sources */, 250 | 6003F5AB195388D20070C39A /* Frameworks */, 251 | 6003F5AC195388D20070C39A /* Resources */, 252 | E4AD52EB0164C6EA2BC6D1AB /* [CP] Embed Pods Frameworks */, 253 | 3FE611E10424252C64F7E3DD /* [CP] Copy Pods Resources */, 254 | ); 255 | buildRules = ( 256 | ); 257 | dependencies = ( 258 | 6003F5B4195388D20070C39A /* PBXTargetDependency */, 259 | ); 260 | name = WLRRoute_Tests; 261 | productName = WLRRouteTests; 262 | productReference = 6003F5AE195388D20070C39A /* WLRRoute_Tests.xctest */; 263 | productType = "com.apple.product-type.bundle.unit-test"; 264 | }; 265 | /* End PBXNativeTarget section */ 266 | 267 | /* Begin PBXProject section */ 268 | 6003F582195388D10070C39A /* Project object */ = { 269 | isa = PBXProject; 270 | attributes = { 271 | CLASSPREFIX = WLR; 272 | LastUpgradeCheck = 0720; 273 | ORGANIZATIONNAME = Neo; 274 | TargetAttributes = { 275 | 6003F5AD195388D20070C39A = { 276 | TestTargetID = 6003F589195388D20070C39A; 277 | }; 278 | }; 279 | }; 280 | buildConfigurationList = 6003F585195388D10070C39A /* Build configuration list for PBXProject "WLRRoute" */; 281 | compatibilityVersion = "Xcode 3.2"; 282 | developmentRegion = English; 283 | hasScannedForEncodings = 0; 284 | knownRegions = ( 285 | en, 286 | Base, 287 | ); 288 | mainGroup = 6003F581195388D10070C39A; 289 | productRefGroup = 6003F58B195388D20070C39A /* Products */; 290 | projectDirPath = ""; 291 | projectRoot = ""; 292 | targets = ( 293 | 6003F589195388D20070C39A /* WLRRoute_Example */, 294 | 6003F5AD195388D20070C39A /* WLRRoute_Tests */, 295 | ); 296 | }; 297 | /* End PBXProject section */ 298 | 299 | /* Begin PBXResourcesBuildPhase section */ 300 | 6003F588195388D20070C39A /* Resources */ = { 301 | isa = PBXResourcesBuildPhase; 302 | buildActionMask = 2147483647; 303 | files = ( 304 | 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */, 305 | 6003F5A9195388D20070C39A /* Images.xcassets in Resources */, 306 | 6003F598195388D20070C39A /* InfoPlist.strings in Resources */, 307 | ); 308 | runOnlyForDeploymentPostprocessing = 0; 309 | }; 310 | 6003F5AC195388D20070C39A /* Resources */ = { 311 | isa = PBXResourcesBuildPhase; 312 | buildActionMask = 2147483647; 313 | files = ( 314 | 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */, 315 | ); 316 | runOnlyForDeploymentPostprocessing = 0; 317 | }; 318 | /* End PBXResourcesBuildPhase section */ 319 | 320 | /* Begin PBXShellScriptBuildPhase section */ 321 | 3FE611E10424252C64F7E3DD /* [CP] Copy Pods Resources */ = { 322 | isa = PBXShellScriptBuildPhase; 323 | buildActionMask = 2147483647; 324 | files = ( 325 | ); 326 | inputPaths = ( 327 | ); 328 | name = "[CP] Copy Pods Resources"; 329 | outputPaths = ( 330 | ); 331 | runOnlyForDeploymentPostprocessing = 0; 332 | shellPath = /bin/sh; 333 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests-resources.sh\"\n"; 334 | showEnvVarsInLog = 0; 335 | }; 336 | 8612F947377B3134604C6753 /* [CP] Embed Pods Frameworks */ = { 337 | isa = PBXShellScriptBuildPhase; 338 | buildActionMask = 2147483647; 339 | files = ( 340 | ); 341 | inputPaths = ( 342 | ); 343 | name = "[CP] Embed Pods Frameworks"; 344 | outputPaths = ( 345 | ); 346 | runOnlyForDeploymentPostprocessing = 0; 347 | shellPath = /bin/sh; 348 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example-frameworks.sh\"\n"; 349 | showEnvVarsInLog = 0; 350 | }; 351 | A2B1765A7794B254AC866883 /* [CP] Check Pods Manifest.lock */ = { 352 | isa = PBXShellScriptBuildPhase; 353 | buildActionMask = 2147483647; 354 | files = ( 355 | ); 356 | inputPaths = ( 357 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 358 | "${PODS_ROOT}/Manifest.lock", 359 | ); 360 | name = "[CP] Check Pods Manifest.lock"; 361 | outputPaths = ( 362 | "$(DERIVED_FILE_DIR)/Pods-WLRRoute_Example-checkManifestLockResult.txt", 363 | ); 364 | runOnlyForDeploymentPostprocessing = 0; 365 | shellPath = /bin/sh; 366 | 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"; 367 | showEnvVarsInLog = 0; 368 | }; 369 | A601401B611ABE8D5EB685AE /* [CP] Check Pods Manifest.lock */ = { 370 | isa = PBXShellScriptBuildPhase; 371 | buildActionMask = 2147483647; 372 | files = ( 373 | ); 374 | inputPaths = ( 375 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 376 | "${PODS_ROOT}/Manifest.lock", 377 | ); 378 | name = "[CP] Check Pods Manifest.lock"; 379 | outputPaths = ( 380 | "$(DERIVED_FILE_DIR)/Pods-WLRRoute_Tests-checkManifestLockResult.txt", 381 | ); 382 | runOnlyForDeploymentPostprocessing = 0; 383 | shellPath = /bin/sh; 384 | 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"; 385 | showEnvVarsInLog = 0; 386 | }; 387 | A8BC8FD0F0FEE36DA1874CE3 /* [CP] Copy Pods Resources */ = { 388 | isa = PBXShellScriptBuildPhase; 389 | buildActionMask = 2147483647; 390 | files = ( 391 | ); 392 | inputPaths = ( 393 | ); 394 | name = "[CP] Copy Pods Resources"; 395 | outputPaths = ( 396 | ); 397 | runOnlyForDeploymentPostprocessing = 0; 398 | shellPath = /bin/sh; 399 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-WLRRoute_Example/Pods-WLRRoute_Example-resources.sh\"\n"; 400 | showEnvVarsInLog = 0; 401 | }; 402 | E4AD52EB0164C6EA2BC6D1AB /* [CP] Embed Pods Frameworks */ = { 403 | isa = PBXShellScriptBuildPhase; 404 | buildActionMask = 2147483647; 405 | files = ( 406 | ); 407 | inputPaths = ( 408 | ); 409 | name = "[CP] Embed Pods Frameworks"; 410 | outputPaths = ( 411 | ); 412 | runOnlyForDeploymentPostprocessing = 0; 413 | shellPath = /bin/sh; 414 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-WLRRoute_Tests/Pods-WLRRoute_Tests-frameworks.sh\"\n"; 415 | showEnvVarsInLog = 0; 416 | }; 417 | /* End PBXShellScriptBuildPhase section */ 418 | 419 | /* Begin PBXSourcesBuildPhase section */ 420 | 6003F586195388D20070C39A /* Sources */ = { 421 | isa = PBXSourcesBuildPhase; 422 | buildActionMask = 2147483647; 423 | files = ( 424 | 6003F59E195388D20070C39A /* WLRAppDelegate.m in Sources */, 425 | 6003F5A7195388D20070C39A /* WLRViewController.m in Sources */, 426 | 76B4BC851E06A18E00D1E590 /* WLRUserHandler.m in Sources */, 427 | 76B4BC8B1E06A1AA00D1E590 /* WLRUserViewController.m in Sources */, 428 | B539A64D207DA1B9006B789B /* HBXCALLBACKHandler.m in Sources */, 429 | 6003F59A195388D20070C39A /* main.m in Sources */, 430 | 76B4BC821E06A18400D1E590 /* WLRSignHandler.m in Sources */, 431 | 76B4BC881E06A1A100D1E590 /* WLRSignViewController.m in Sources */, 432 | ); 433 | runOnlyForDeploymentPostprocessing = 0; 434 | }; 435 | 6003F5AA195388D20070C39A /* Sources */ = { 436 | isa = PBXSourcesBuildPhase; 437 | buildActionMask = 2147483647; 438 | files = ( 439 | 6003F5BC195388D20070C39A /* Tests.m in Sources */, 440 | ); 441 | runOnlyForDeploymentPostprocessing = 0; 442 | }; 443 | /* End PBXSourcesBuildPhase section */ 444 | 445 | /* Begin PBXTargetDependency section */ 446 | 6003F5B4195388D20070C39A /* PBXTargetDependency */ = { 447 | isa = PBXTargetDependency; 448 | target = 6003F589195388D20070C39A /* WLRRoute_Example */; 449 | targetProxy = 6003F5B3195388D20070C39A /* PBXContainerItemProxy */; 450 | }; 451 | /* End PBXTargetDependency section */ 452 | 453 | /* Begin PBXVariantGroup section */ 454 | 6003F596195388D20070C39A /* InfoPlist.strings */ = { 455 | isa = PBXVariantGroup; 456 | children = ( 457 | 6003F597195388D20070C39A /* en */, 458 | ); 459 | name = InfoPlist.strings; 460 | sourceTree = ""; 461 | }; 462 | 6003F5B8195388D20070C39A /* InfoPlist.strings */ = { 463 | isa = PBXVariantGroup; 464 | children = ( 465 | 6003F5B9195388D20070C39A /* en */, 466 | ); 467 | name = InfoPlist.strings; 468 | sourceTree = ""; 469 | }; 470 | /* End PBXVariantGroup section */ 471 | 472 | /* Begin XCBuildConfiguration section */ 473 | 6003F5BD195388D20070C39A /* Debug */ = { 474 | isa = XCBuildConfiguration; 475 | buildSettings = { 476 | ALWAYS_SEARCH_USER_PATHS = NO; 477 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 478 | CLANG_CXX_LIBRARY = "libc++"; 479 | CLANG_ENABLE_MODULES = YES; 480 | CLANG_ENABLE_OBJC_ARC = YES; 481 | CLANG_WARN_BOOL_CONVERSION = YES; 482 | CLANG_WARN_CONSTANT_CONVERSION = YES; 483 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 484 | CLANG_WARN_EMPTY_BODY = YES; 485 | CLANG_WARN_ENUM_CONVERSION = YES; 486 | CLANG_WARN_INT_CONVERSION = YES; 487 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 488 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 489 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 490 | COPY_PHASE_STRIP = NO; 491 | ENABLE_TESTABILITY = YES; 492 | GCC_C_LANGUAGE_STANDARD = gnu99; 493 | GCC_DYNAMIC_NO_PIC = NO; 494 | GCC_OPTIMIZATION_LEVEL = 0; 495 | GCC_PREPROCESSOR_DEFINITIONS = ( 496 | "DEBUG=1", 497 | "$(inherited)", 498 | ); 499 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 500 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 501 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 502 | GCC_WARN_UNDECLARED_SELECTOR = YES; 503 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 504 | GCC_WARN_UNUSED_FUNCTION = YES; 505 | GCC_WARN_UNUSED_VARIABLE = YES; 506 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 507 | ONLY_ACTIVE_ARCH = YES; 508 | SDKROOT = iphoneos; 509 | TARGETED_DEVICE_FAMILY = "1,2"; 510 | }; 511 | name = Debug; 512 | }; 513 | 6003F5BE195388D20070C39A /* Release */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | ALWAYS_SEARCH_USER_PATHS = NO; 517 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 518 | CLANG_CXX_LIBRARY = "libc++"; 519 | CLANG_ENABLE_MODULES = YES; 520 | CLANG_ENABLE_OBJC_ARC = YES; 521 | CLANG_WARN_BOOL_CONVERSION = YES; 522 | CLANG_WARN_CONSTANT_CONVERSION = YES; 523 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 524 | CLANG_WARN_EMPTY_BODY = YES; 525 | CLANG_WARN_ENUM_CONVERSION = YES; 526 | CLANG_WARN_INT_CONVERSION = YES; 527 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 528 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 529 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 530 | COPY_PHASE_STRIP = YES; 531 | ENABLE_NS_ASSERTIONS = NO; 532 | GCC_C_LANGUAGE_STANDARD = gnu99; 533 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 534 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 535 | GCC_WARN_UNDECLARED_SELECTOR = YES; 536 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 537 | GCC_WARN_UNUSED_FUNCTION = YES; 538 | GCC_WARN_UNUSED_VARIABLE = YES; 539 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 540 | SDKROOT = iphoneos; 541 | TARGETED_DEVICE_FAMILY = "1,2"; 542 | VALIDATE_PRODUCT = YES; 543 | }; 544 | name = Release; 545 | }; 546 | 6003F5C0195388D20070C39A /* Debug */ = { 547 | isa = XCBuildConfiguration; 548 | baseConfigurationReference = 59B886F0E311760DF80A2263 /* Pods-WLRRoute_Example.debug.xcconfig */; 549 | buildSettings = { 550 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 551 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 552 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 553 | GCC_PREFIX_HEADER = "WLRRoute/WLRRoute-Prefix.pch"; 554 | INFOPLIST_FILE = "WLRRoute/WLRRoute-Info.plist"; 555 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 556 | MODULE_NAME = ExampleApp; 557 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 558 | PRODUCT_NAME = "$(TARGET_NAME)"; 559 | WRAPPER_EXTENSION = app; 560 | }; 561 | name = Debug; 562 | }; 563 | 6003F5C1195388D20070C39A /* Release */ = { 564 | isa = XCBuildConfiguration; 565 | baseConfigurationReference = 6332ECC62B1D02852DBA1093 /* Pods-WLRRoute_Example.release.xcconfig */; 566 | buildSettings = { 567 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 568 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 569 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 570 | GCC_PREFIX_HEADER = "WLRRoute/WLRRoute-Prefix.pch"; 571 | INFOPLIST_FILE = "WLRRoute/WLRRoute-Info.plist"; 572 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 573 | MODULE_NAME = ExampleApp; 574 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 575 | PRODUCT_NAME = "$(TARGET_NAME)"; 576 | WRAPPER_EXTENSION = app; 577 | }; 578 | name = Release; 579 | }; 580 | 6003F5C3195388D20070C39A /* Debug */ = { 581 | isa = XCBuildConfiguration; 582 | baseConfigurationReference = A51FE03D28BD66089799BAAB /* Pods-WLRRoute_Tests.debug.xcconfig */; 583 | buildSettings = { 584 | BUNDLE_LOADER = "$(TEST_HOST)"; 585 | FRAMEWORK_SEARCH_PATHS = ( 586 | "$(SDKROOT)/Developer/Library/Frameworks", 587 | "$(inherited)", 588 | "$(DEVELOPER_FRAMEWORKS_DIR)", 589 | ); 590 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 591 | GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch"; 592 | GCC_PREPROCESSOR_DEFINITIONS = ( 593 | "DEBUG=1", 594 | "$(inherited)", 595 | ); 596 | INFOPLIST_FILE = "Tests/Tests-Info.plist"; 597 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 598 | PRODUCT_NAME = "$(TARGET_NAME)"; 599 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WLRRoute_Example.app/WLRRoute_Example"; 600 | WRAPPER_EXTENSION = xctest; 601 | }; 602 | name = Debug; 603 | }; 604 | 6003F5C4195388D20070C39A /* Release */ = { 605 | isa = XCBuildConfiguration; 606 | baseConfigurationReference = B302507AE219196694EE98E8 /* Pods-WLRRoute_Tests.release.xcconfig */; 607 | buildSettings = { 608 | BUNDLE_LOADER = "$(TEST_HOST)"; 609 | FRAMEWORK_SEARCH_PATHS = ( 610 | "$(SDKROOT)/Developer/Library/Frameworks", 611 | "$(inherited)", 612 | "$(DEVELOPER_FRAMEWORKS_DIR)", 613 | ); 614 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 615 | GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch"; 616 | INFOPLIST_FILE = "Tests/Tests-Info.plist"; 617 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 618 | PRODUCT_NAME = "$(TARGET_NAME)"; 619 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WLRRoute_Example.app/WLRRoute_Example"; 620 | WRAPPER_EXTENSION = xctest; 621 | }; 622 | name = Release; 623 | }; 624 | /* End XCBuildConfiguration section */ 625 | 626 | /* Begin XCConfigurationList section */ 627 | 6003F585195388D10070C39A /* Build configuration list for PBXProject "WLRRoute" */ = { 628 | isa = XCConfigurationList; 629 | buildConfigurations = ( 630 | 6003F5BD195388D20070C39A /* Debug */, 631 | 6003F5BE195388D20070C39A /* Release */, 632 | ); 633 | defaultConfigurationIsVisible = 0; 634 | defaultConfigurationName = Release; 635 | }; 636 | 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "WLRRoute_Example" */ = { 637 | isa = XCConfigurationList; 638 | buildConfigurations = ( 639 | 6003F5C0195388D20070C39A /* Debug */, 640 | 6003F5C1195388D20070C39A /* Release */, 641 | ); 642 | defaultConfigurationIsVisible = 0; 643 | defaultConfigurationName = Release; 644 | }; 645 | 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "WLRRoute_Tests" */ = { 646 | isa = XCConfigurationList; 647 | buildConfigurations = ( 648 | 6003F5C3195388D20070C39A /* Debug */, 649 | 6003F5C4195388D20070C39A /* Release */, 650 | ); 651 | defaultConfigurationIsVisible = 0; 652 | defaultConfigurationName = Release; 653 | }; 654 | /* End XCConfigurationList section */ 655 | }; 656 | rootObject = 6003F582195388D10070C39A /* Project object */; 657 | } 658 | -------------------------------------------------------------------------------- /Example/WLRRoute.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/WLRRoute.xcodeproj/xcshareddata/xcschemes/WLRRoute-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /Example/WLRRoute.xcodeproj/xcuserdata/Neo.xcuserdatad/xcschemes/WLRRoute_Tests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 14 | 15 | 17 | 23 | 24 | 25 | 26 | 27 | 33 | 34 | 35 | 36 | 37 | 38 | 48 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Example/WLRRoute.xcodeproj/xcuserdata/Neo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | WLRRoute-Example.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 3 11 | 12 | WLRRoute_Tests.xcscheme 13 | 14 | orderHint 15 | 4 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 6003F589195388D20070C39A 21 | 22 | primary 23 | 24 | 25 | 6003F5AD195388D20070C39A 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Example/WLRRoute.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/WLRRoute.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/WLRRoute.xcworkspace/xcuserdata/Neo.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Neojoke/WLRRoute/b490dd04308825afec8ed8b9d0b2e594f61a0666/Example/WLRRoute.xcworkspace/xcuserdata/Neo.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example/WLRRoute.xcworkspace/xcuserdata/Neo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 56 | 68 | 69 | 70 | 72 | 84 | 85 | 86 | 88 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /Example/WLRRoute/HBXCALLBACKHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // HBXCALLBACKHandler.h 3 | // WLRRoute_Example 4 | // 5 | // Created by Neo on 2018/4/11. 6 | // Copyright © 2018年 Neo. All rights reserved. 7 | // 8 | 9 | #import "WLRRouteHandler.h" 10 | #import 11 | @protocol HBModuleProtocol 12 | +(BOOL)handleRequest:(WLRRouteRequest *)request actionName:(NSString *)actionName completionHandler:(WLRRouteCompletionHandler)completionHandler; 13 | @optional 14 | +(UIViewController *)targetViewControllerWithRequest:(WLRRouteRequest *)request actionName:(NSString *)actionName completionHandler:(WLRRouteCompletionHandler)completionHandler; 15 | +(void)transitionWithTargetViewController:(UIViewController *)ViewController request:(WLRRouteRequest *)request actionName:(NSString *)actionName; 16 | @end 17 | @class WLRRouter; 18 | @interface HBXCALLBACKHandler : WLRRouteHandler 19 | @property(nonatomic,weak)WLRRouter * router; 20 | @property(nonatomic)BOOL enableException; 21 | -(void)registeModuleProtocol:(Protocol *)moduleProtocol implClass:(Class)implClass forActionName:(NSString *)actionName; 22 | @end 23 | -------------------------------------------------------------------------------- /Example/WLRRoute/HBXCALLBACKHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // HBXCALLBACKHandler.m 3 | // WLRRoute_Example 4 | // 5 | // Created by Neo on 2018/4/11. 6 | // Copyright © 2018年 Neo. All rights reserved. 7 | // 8 | 9 | #import "HBXCALLBACKHandler.h" 10 | #import 11 | #import 12 | #import 13 | @interface HBXCALLBACKHandler() 14 | @property (nonatomic, strong) NSMutableDictionary *allModuleDict; 15 | @property(nonatomic,strong)NSMutableDictionary * actionsMap; 16 | @property (nonatomic, strong) NSRecursiveLock *lock; 17 | @end 18 | @implementation HBXCALLBACKHandler 19 | -(NSMutableDictionary *)actionsMap{ 20 | if (!_actionsMap) { 21 | _actionsMap = [NSMutableDictionary dictionary]; 22 | } 23 | return _actionsMap; 24 | } 25 | - (NSMutableDictionary *)allModuleDict 26 | { 27 | if (!_allModuleDict) { 28 | _allModuleDict = [NSMutableDictionary dictionary]; 29 | } 30 | return _allModuleDict; 31 | } 32 | - (NSDictionary *)moduleDict{ 33 | [self.lock lock]; 34 | NSDictionary *dict = [self.allModuleDict copy]; 35 | [self.lock unlock]; 36 | return dict; 37 | } 38 | 39 | - (NSRecursiveLock *)lock 40 | { 41 | if (!_lock) { 42 | _lock = [[NSRecursiveLock alloc] init]; 43 | } 44 | return _lock; 45 | } 46 | -(BOOL)shouldHandleWithRequest:(WLRRouteRequest *)request{ 47 | return YES; 48 | } 49 | -(UIViewController *)targetViewControllerWithRequest:(WLRRouteRequest *)request{ 50 | 51 | return [[NSClassFromString(@"HBTestViewController") alloc]init]; 52 | } 53 | -(UIViewController *)sourceViewControllerForTransitionWithRequest:(WLRRouteRequest *)request{ 54 | return [UIApplication sharedApplication].windows[0].rootViewController; 55 | } 56 | 57 | -(BOOL)transitionWithWithRequest:(WLRRouteRequest *)request sourceViewController:(UIViewController *)sourceViewController targetViewController:(UIViewController *)targetViewController isPreferModal:(BOOL)isPreferModal error:(NSError *__autoreleasing *)error{ 58 | if (isPreferModal||![sourceViewController isKindOfClass:[UINavigationController class]]) { 59 | [sourceViewController presentViewController:targetViewController animated:YES completion:nil]; 60 | } 61 | else if ([sourceViewController isKindOfClass:[UINavigationController class]]){ 62 | UINavigationController * nav = (UINavigationController *)sourceViewController; 63 | [nav pushViewController:targetViewController animated:YES]; 64 | } 65 | return YES; 66 | } 67 | 68 | - (BOOL)preferModalPresentationWithRequest:(WLRRouteRequest *)request;{ 69 | return NO; 70 | } 71 | -(void)registeModuleProtocol:(Protocol *)moduleProtocol implClass:(Class)implClass forActionName:(NSString *)actionName;{ 72 | NSParameterAssert(moduleProtocol != nil); 73 | NSParameterAssert(implClass != nil); 74 | NSParameterAssert(actionName != nil); 75 | if (![implClass conformsToProtocol:moduleProtocol]) { 76 | if (self.enableException) { 77 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[NSString stringWithFormat:@"%@ module does not comply with %@ protocol", NSStringFromClass(implClass), NSStringFromProtocol(moduleProtocol)] userInfo:nil]; 78 | } 79 | return; 80 | } 81 | 82 | if ([self checkValidModuleProtocol:moduleProtocol actionName:actionName]) { 83 | if (self.enableException) { 84 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[NSString stringWithFormat:@"%@ protocol has been registed", NSStringFromProtocol(moduleProtocol)] userInfo:nil]; 85 | } 86 | return; 87 | } 88 | NSString *key = [NSString stringWithFormat:@"%@_%@",actionName,NSStringFromProtocol(moduleProtocol)]; 89 | NSString *value = NSStringFromClass(implClass); 90 | 91 | if (key.length > 0 && value.length > 0 && [actionName isKindOfClass:[NSString class]] && actionName.length>0) { 92 | [self.lock lock]; 93 | [self.allModuleDict addEntriesFromDictionary:@{key:value}]; 94 | [self.actionsMap addEntriesFromDictionary:@{actionName:key}]; 95 | [self.lock unlock]; 96 | } 97 | } 98 | - (BOOL)checkValidModuleProtocol:(Protocol *)moduleProtocol actionName:(NSString *)actionName 99 | { 100 | NSString * action_protocol = [NSString stringWithFormat:@"%@_%@",actionName,NSStringFromProtocol(moduleProtocol)]; 101 | NSString *moduleImpl = [[self moduleDict] objectForKey:action_protocol]; 102 | if (moduleImpl.length > 0) { 103 | return YES; 104 | } 105 | return NO; 106 | } 107 | -(BOOL)handleRequest:(WLRRouteRequest *)request error:(NSError *__autoreleasing *)error{ 108 | NSLog(@"%@",request.queryParameters); 109 | NSString * x_success =request.queryParameters[@"x-success"]; 110 | NSString * x_error = request.queryParameters[@"x-error"]; 111 | NSURL * x_error_url = [NSURL URLWithString:x_error]; 112 | NSURL * x_success_url = [NSURL URLWithString:x_success]; 113 | NSString * actionName = request.URL.path; 114 | WLRRouteCompletionHandler originalCallBack = request.targetCallBack; 115 | __weak typeof(self) weakSelf = self; 116 | WLRRouteCompletionHandler callBack = ^(NSError *callback_error,NSDictionary * responseObject){ 117 | if (originalCallBack) { 118 | originalCallBack(callback_error,responseObject); 119 | } 120 | if (callback_error && x_error_url) { 121 | if (weakSelf.router) { 122 | [weakSelf.router handleURL:x_error_url primitiveParameters:responseObject targetCallBack:nil withCompletionBlock:nil]; 123 | } 124 | } 125 | else if(x_success_url){ 126 | if (weakSelf.router) { 127 | [weakSelf.router handleURL:x_success_url primitiveParameters:responseObject targetCallBack:nil withCompletionBlock:nil]; 128 | } 129 | } 130 | 131 | }; 132 | request.targetCallBack = callBack; 133 | Class impl = [self implClassWithActionName:actionName]; 134 | if (impl == nil) { 135 | *error = [NSError WLRHandleRequestErrorWithMessage:[NSString stringWithFormat:@"not found module with actionName:%@",actionName]]; 136 | return NO; 137 | } 138 | BOOL isHandle = [impl handleRequest:request actionName:actionName completionHandler:callBack]; 139 | return isHandle; 140 | } 141 | -(Class)implClassWithActionName:(NSString *)actionName{ 142 | NSString * key = [self.actionsMap objectForKey:actionName]; 143 | if (!key) { 144 | return nil; 145 | } 146 | NSString * implClassString = [[self moduleDict] objectForKey:key]; 147 | if (implClassString.length>0) { 148 | return NSClassFromString(implClassString); 149 | } 150 | else{ 151 | return nil; 152 | } 153 | } 154 | @end 155 | -------------------------------------------------------------------------------- /Example/WLRRoute/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /Example/WLRRoute/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Example/WLRRoute/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 40 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 120 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRAppDelegate.h 3 | // WLRRoute 4 | // 5 | // Created by Neo on 12/18/2016. 6 | // Copyright (c) 2016 Neo. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | @class WLRRouter; 11 | @interface WLRAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | @property(nonatomic,strong)WLRRouter * router; 15 | @end 16 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRAppDelegate.m 3 | // WLRRoute 4 | // 5 | // Created by Neo on 12/18/2016. 6 | // Copyright (c) 2016 Neo. All rights reserved. 7 | // 8 | 9 | #import "WLRAppDelegate.h" 10 | #import 11 | #import "WLRSignHandler.h" 12 | #import "WLRUserHandler.h" 13 | #import "HBXCALLBACKHandler.h" 14 | #import "WLRSignViewController.h" 15 | @interface WLRAppDelegate() 16 | @end 17 | @implementation WLRAppDelegate 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 20 | { 21 | // Override point for customization after application launch. 22 | self.router = [[WLRRouter alloc]init]; 23 | [self.router registerHandler:[[WLRSignHandler alloc]init] forRoute:@"/signin/:phone([0-9]+)"]; 24 | [self.router registerHandler:[[WLRUserHandler alloc]init] forRoute:@"/user"]; 25 | HBXCALLBACKHandler * x_call_back_handler =[[HBXCALLBACKHandler alloc]init]; 26 | x_call_back_handler.enableException = YES; 27 | Class signModuleImplClass = NSClassFromString(@"WLRSignViewController"); 28 | Class userModuleImplClass = NSClassFromString(@"WLRUserViewController"); 29 | 30 | [x_call_back_handler registeModuleProtocol:@protocol(HBSignModuleProtocol) implClass:signModuleImplClass forActionName:@"/signin"]; 31 | [x_call_back_handler registeModuleProtocol:@protocol(HBModuleProtocol) implClass:userModuleImplClass forActionName:@"/user"]; 32 | [self.router registerHandler:x_call_back_handler forRoute:@"x-call-back/:path(.*)"]; 33 | x_call_back_handler.router = self.router; 34 | return YES; 35 | } 36 | 37 | - (void)applicationWillResignActive:(UIApplication *)application 38 | { 39 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 40 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 41 | } 42 | 43 | - (void)applicationDidEnterBackground:(UIApplication *)application 44 | { 45 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 46 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 47 | } 48 | 49 | - (void)applicationWillEnterForeground:(UIApplication *)application 50 | { 51 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 52 | } 53 | 54 | - (void)applicationDidBecomeActive:(UIApplication *)application 55 | { 56 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 57 | } 58 | 59 | - (void)applicationWillTerminate:(UIApplication *)application 60 | { 61 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 62 | } 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRRoute-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleURLTypes 24 | 25 | 26 | CFBundleTypeRole 27 | Editor 28 | CFBundleURLSchemes 29 | 30 | WLRDemo 31 | 32 | 33 | 34 | CFBundleVersion 35 | 1.0 36 | LSRequiresIPhoneOS 37 | 38 | UILaunchStoryboardName 39 | Main 40 | UIMainStoryboardFile 41 | Main 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRRoute-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | @import UIKit; 15 | @import Foundation; 16 | #endif 17 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRSignHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRSignHandler.h 3 | // WLRRoute 4 | // 5 | // Created by Neo on 2016/12/18. 6 | // Copyright © 2016年 Neo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WLRSignHandler : WLRRouteHandler 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRSignHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRSignHandler.m 3 | // WLRRoute 4 | // 5 | // Created by Neo on 2016/12/18. 6 | // Copyright © 2016年 Neo. All rights reserved. 7 | // 8 | 9 | #import "WLRSignHandler.h" 10 | 11 | @implementation WLRSignHandler 12 | -(UIViewController *)targetViewControllerWithRequest:(WLRRouteRequest *)request{ 13 | UIStoryboard * story = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 14 | UIViewController * vc = [story instantiateViewControllerWithIdentifier:@"WLRSignViewController"]; 15 | return vc; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRSignViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRSignViewController.h 3 | // WLRRoute 4 | // 5 | // Created by Neo on 2016/12/18. 6 | // Copyright © 2016年 Neo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HBXCALLBACKHandler.h" 11 | @protocol HBSignModuleProtocol 12 | +(UIViewController *)signViewControllerWithPhone:(NSString *)phone; 13 | @end 14 | @interface WLRSignViewController : UIViewController 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRSignViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRSignViewController.m 3 | // WLRRoute 4 | // 5 | // Created by Neo on 2016/12/18. 6 | // Copyright © 2016年 Neo. All rights reserved. 7 | // 8 | 9 | #import "WLRSignViewController.h" 10 | #import 11 | @interface WLRSignViewController () 12 | @property (weak, nonatomic) IBOutlet UITextField *Phone; 13 | @property (weak, nonatomic) IBOutlet UITextField *password; 14 | 15 | @end 16 | 17 | @implementation WLRSignViewController 18 | #pragma mark -Module Protocol impl 19 | +(BOOL)handleRequest:(WLRRouteRequest *)request actionName:(NSString *)actionName completionHandler:(WLRRouteCompletionHandler)completionHandler{ 20 | UIViewController * controller = [self targetViewControllerWithRequest:request actionName:actionName completionHandler:completionHandler]; 21 | if (!controller) { 22 | return NO; 23 | } 24 | controller.wlr_request = request; 25 | [self transitionWithTargetViewController:controller request:request actionName:actionName]; 26 | return YES; 27 | } 28 | +(UIViewController *)targetViewControllerWithRequest:(WLRRouteRequest *)request actionName:(NSString *)actionName completionHandler:(WLRRouteCompletionHandler)completionHandler{ 29 | UIViewController * vc = [self signViewControllerWithPhone:request[@"phone"]]; 30 | return vc; 31 | } 32 | +(UIViewController *)signViewControllerWithPhone:(NSString *)phone{ 33 | UIStoryboard * story = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 34 | WLRSignViewController * vc = [story instantiateViewControllerWithIdentifier:@"WLRSignViewController"]; 35 | vc.Phone.text = phone; 36 | return vc; 37 | } 38 | +(void)transitionWithTargetViewController:(UIViewController *)ViewController request:(WLRRouteRequest *)request actionName:(NSString *)actionName{ 39 | UIViewController * sourceViewController =[UIApplication sharedApplication].windows[0].rootViewController; 40 | if ([sourceViewController isKindOfClass:[UINavigationController class]]){ 41 | UINavigationController * nav = (UINavigationController *)sourceViewController; 42 | [nav pushViewController:ViewController animated:YES]; 43 | } 44 | } 45 | - (IBAction)go:(UIButton *)sender { 46 | 47 | } 48 | 49 | - (void)viewDidLoad { 50 | [super viewDidLoad]; 51 | self.Phone.text = self.wlr_request[@"phone"]; 52 | // Do any additional setup after loading the view. 53 | } 54 | -(void)viewDidDisappear:(BOOL)animated{ 55 | 56 | } 57 | - (void)didReceiveMemoryWarning { 58 | [super didReceiveMemoryWarning]; 59 | // Dispose of any resources that can be recreated. 60 | } 61 | 62 | /* 63 | #pragma mark - Navigation 64 | 65 | // In a storyboard-based application, you will often want to do a little preparation before navigation 66 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 67 | // Get the new view controller using [segue destinationViewController]. 68 | // Pass the selected object to the new view controller. 69 | } 70 | */ 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRUserHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRUserHandler.h 3 | // WLRRoute 4 | // 5 | // Created by Neo on 2016/12/18. 6 | // Copyright © 2016年 Neo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WLRUserHandler : WLRRouteHandler 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRUserHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRUserHandler.m 3 | // WLRRoute 4 | // 5 | // Created by Neo on 2016/12/18. 6 | // Copyright © 2016年 Neo. All rights reserved. 7 | // 8 | 9 | #import "WLRUserHandler.h" 10 | 11 | @implementation WLRUserHandler 12 | -(UIViewController *)targetViewControllerWithRequest:(WLRRouteRequest *)request{ 13 | UIStoryboard * story = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 14 | UIViewController * vc = [story instantiateViewControllerWithIdentifier:@"WLRUserViewController"]; 15 | return vc; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRUserViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRUserViewController.h 3 | // WLRRoute 4 | // 5 | // Created by Neo on 2016/12/18. 6 | // Copyright © 2016年 Neo. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HBXCALLBACKHandler.h" 11 | @interface WLRUserViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRUserViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRUserViewController.m 3 | // WLRRoute 4 | // 5 | // Created by Neo on 2016/12/18. 6 | // Copyright © 2016年 Neo. All rights reserved. 7 | // 8 | 9 | #import "WLRUserViewController.h" 10 | #import 11 | @interface WLRUserViewController () 12 | 13 | @property (weak, nonatomic) IBOutlet UILabel *user; 14 | 15 | @end 16 | 17 | @implementation WLRUserViewController 18 | +(BOOL)handleRequest:(WLRRouteRequest *)request actionName:(NSString *)actionName completionHandler:(WLRRouteCompletionHandler)completionHandler{ 19 | UIViewController * controller = [self targetViewControllerWithRequest:request actionName:actionName completionHandler:completionHandler]; 20 | if (!controller) { 21 | return NO; 22 | } 23 | controller.wlr_request = request; 24 | [self transitionWithTargetViewController:controller request:request actionName:actionName]; 25 | return YES; 26 | } 27 | +(UIViewController *)targetViewControllerWithRequest:(WLRRouteRequest *)request actionName:(NSString *)actionName completionHandler:(WLRRouteCompletionHandler)completionHandler{ 28 | UIStoryboard * story = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 29 | UIViewController * vc = [story instantiateViewControllerWithIdentifier:@"WLRUserViewController"]; 30 | return vc; 31 | } 32 | +(void)transitionWithTargetViewController:(UIViewController *)ViewController request:(WLRRouteRequest *)request actionName:(NSString *)actionName{ 33 | UIViewController * sourceViewController =[UIApplication sharedApplication].windows[0].rootViewController; 34 | if ([sourceViewController isKindOfClass:[UINavigationController class]]){ 35 | UINavigationController * nav = (UINavigationController *)sourceViewController; 36 | [nav pushViewController:ViewController animated:YES]; 37 | } 38 | } 39 | - (void)viewDidLoad { 40 | [super viewDidLoad]; 41 | NSString * user = self.wlr_request[@"user"]; 42 | self.user.text = user; 43 | // Do any additional setup after loading the view. 44 | } 45 | 46 | - (void)didReceiveMemoryWarning { 47 | [super didReceiveMemoryWarning]; 48 | // Dispose of any resources that can be recreated. 49 | } 50 | 51 | /* 52 | #pragma mark - Navigation 53 | 54 | // In a storyboard-based application, you will often want to do a little preparation before navigation 55 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 56 | // Get the new view controller using [segue destinationViewController]. 57 | // Pass the selected object to the new view controller. 58 | } 59 | */ 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRViewController.h 3 | // WLRRoute 4 | // 5 | // Created by Neo on 12/18/2016. 6 | // Copyright (c) 2016 Neo. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | 11 | @interface WLRViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/WLRRoute/WLRViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRViewController.m 3 | // WLRRoute 4 | // 5 | // Created by Neo on 12/18/2016. 6 | // Copyright (c) 2016 Neo. All rights reserved. 7 | // 8 | 9 | #import "WLRViewController.h" 10 | #import 11 | #import "WLRAppDelegate.h" 12 | @interface WLRViewController () 13 | @property(nonatomic,weak)WLRRouter * router; 14 | @end 15 | 16 | @implementation WLRViewController 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | self.router = ((WLRAppDelegate *)[UIApplication sharedApplication].delegate).router; 22 | [self.router addMiddleware:self]; 23 | // Do any additional setup after loading the view, typically from a nib. 24 | } 25 | -(NSDictionary *)middlewareHandleRequestWith:(WLRRouteRequest *__autoreleasing *)primitiveRequest error:(NSError *__autoreleasing *)error{ 26 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 27 | [self.router removeMiddleware:self]; 28 | }); 29 | return nil; 30 | //test: 31 | // *error = [NSError WLRMiddlewareRaiseErrorWithMsg:[NSString stringWithFormat:@"%@ raise error",NSStringFromClass([self class])]]; 32 | // return @{@"result":@"yes"}; 33 | } 34 | - (IBAction)userClick:(UIButton *)sender { 35 | [self.router handleURL:[NSURL URLWithString:@"WLRDemo://com.wlrroute.demo/user"] primitiveParameters:@{@"user":@"Neo~🙃🙃"} targetCallBack:^(NSError *error, id responseObject) { 36 | NSLog(@"UserCallBack"); 37 | } withCompletionBlock:^(BOOL handled, NSError *error) { 38 | NSLog(@"UserHandleCompletion"); 39 | }]; 40 | } 41 | - (IBAction)SiginClick:(UIButton *)sender { 42 | [self.router handleURL:[NSURL URLWithString:@"WLRDemo://x-call-back/signin?x-success=WLRDemo%3A%2F%2Fx-call-back%2Fuser&phone=17621425586"] primitiveParameters:nil targetCallBack:^(NSError *error, id responseObject) { 43 | NSLog(@"SiginCallBack"); 44 | } withCompletionBlock:^(BOOL handled, NSError *error) { 45 | NSLog(@"SiginHandleCompletion"); 46 | }]; 47 | } 48 | 49 | - (void)didReceiveMemoryWarning 50 | { 51 | [super didReceiveMemoryWarning]; 52 | // Dispose of any resources that can be recreated. 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Example/WLRRoute/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/WLRRoute/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WLRRoute 4 | // 5 | // Created by Neo on 12/18/2016. 6 | // Copyright (c) 2016 Neo. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | #import "WLRAppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) 13 | { 14 | @autoreleasepool { 15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([WLRAppDelegate class])); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Neo <394570610@qq.com> 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WLRRoute 2 | 3 | [![CI Status](http://img.shields.io/travis/Neo/WLRRoute.svg?style=flat)](https://travis-ci.org/Neo/WLRRoute) 4 | [![Version](https://img.shields.io/cocoapods/v/WLRRoute.svg?style=flat)](http://cocoapods.org/pods/WLRRoute) 5 | [![License](https://img.shields.io/cocoapods/l/WLRRoute.svg?style=flat)](http://cocoapods.org/pods/WLRRoute) 6 | [![Platform](https://img.shields.io/cocoapods/p/WLRRoute.svg?style=flat)](http://cocoapods.org/pods/WLRRoute) 7 | 8 | ## Example 9 | 10 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 11 | 12 | ## Requirements 13 | 14 | ## Installation 15 | 16 | WLRRoute is available through [CocoaPods](http://cocoapods.org). To install 17 | it, simply add the following line to your Podfile: 18 | 19 | ```ruby 20 | pod "WLRRoute" 21 | ``` 22 | ## Architecture 23 | ![RouteClassMap](http://upload-images.jianshu.io/upload_images/24274-e05a8d382f2841e5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 24 | 25 | ## 中文介绍 26 | WLRRoute是一个简单的iOS路由组件 27 | 详情请移步文章介绍: 28 | [移动端路由层设计](http://www.jianshu.com/p/be7da3ed4100) 29 | [一步步构建iOS路由](http://www.jianshu.com/p/3a902f274a3d) 30 | 本代码会随着大家的讨论逐步更新,喜欢的来个星✨~谢谢 31 | ##Usage 32 | 33 | ``` 34 | self.router = [[WLRRouter alloc]init]; 35 | [self.router registerHandler:[[WLRSignHandler alloc]init] forRoute:@"/signin/:phone([0-9]+)"]; 36 | [self.router handleURL:[NSURL URLWithString:@"WLRDemo://com.wlrroute.demo/signin/13812345432"] primitiveParameters:nil targetCallBack:^(NSError *error, id responseObject) { 37 | NSLog(@"SiginCallBack"); 38 | } withCompletionBlock:^(BOOL handled, NSError *error) { 39 | NSLog(@"SiginHandleCompletion"); 40 | }]; 41 | 42 | [self.router registerHandler:[[WLRUserHandler alloc]init] forRoute:@"/user"]; 43 | [self.router handleURL:[NSURL URLWithString:@"WLRDemo://com.wlrroute.demo/user"] primitiveParameters:@{@"user":@"Neo~🙃🙃"} targetCallBack:^(NSError *error, id responseObject) { 44 | NSLog(@"UserCallBack"); 45 | } withCompletionBlock:^(BOOL handled, NSError *error) { 46 | NSLog(@"UserHandleCompletion"); 47 | }]; 48 | 49 | ``` 50 | 51 | ## Author 52 | 53 | Neo, 394570610@qq.com 54 | 55 | ## License 56 | 57 | WLRRoute is available under the MIT license. See the LICENSE file for more info. 58 | -------------------------------------------------------------------------------- /WLRRoute.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint WLRRoute.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'WLRRoute' 11 | s.version = '0.1.0' 12 | s.summary = 'WLRRoute is a simple route,it can provide Url matching and custom handler~' 13 | 14 | # This description is used to generate tags and improve search results. 15 | # * Think: What does it do? Why did you write it? What is the focus? 16 | # * Try to keep it short, snappy and to the point. 17 | # * Write the description between the DESC delimiters below. 18 | # * Finally, don't worry about the indent, CocoaPods strips it! 19 | 20 | s.description = <<-DESC 21 | It is used to show how to build a route system in iOS app, and I keep it simple and clear.WLRRoute provide url matching , primitive parameters transfer, target callback block , custom handler can overwrite transitionWithRequest to navigate source to target. 22 | DESC 23 | 24 | s.homepage = 'https://github.com/Neojoke/WLRRoute' 25 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' 26 | s.license = { :type => 'MIT', :file => 'LICENSE' } 27 | s.author = { 'Neo' => '394570610@qq.com' } 28 | s.source = { :git => 'https://github.com/Neojoke/WLRRoute.git', :tag => s.version.to_s } 29 | # s.social_media_url = 'https://twitter.com/' 30 | 31 | s.ios.deployment_target = '7.0' 32 | 33 | s.source_files = 'WLRRoute/Classes/**/*' 34 | 35 | # s.resource_bundles = { 36 | # 'WLRRoute' => ['WLRRoute/Assets/*.png'] 37 | # } 38 | 39 | # s.public_header_files = 'Pod/Classes/**/*.h' 40 | # s.frameworks = 'UIKit', 'MapKit' 41 | # s.dependency 'AFNetworking', '~> 2.3' 42 | end 43 | -------------------------------------------------------------------------------- /WLRRoute/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Neojoke/WLRRoute/b490dd04308825afec8ed8b9d0b2e594f61a0666/WLRRoute/Assets/.gitkeep -------------------------------------------------------------------------------- /WLRRoute/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Neojoke/WLRRoute/b490dd04308825afec8ed8b9d0b2e594f61a0666/WLRRoute/Classes/.gitkeep -------------------------------------------------------------------------------- /WLRRoute/Classes/NSError+WLRError.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+WLRError.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import 10 | typedef NS_ENUM(NSInteger, WLRError) { 11 | 12 | /** The passed URL does not match a registered route. */ 13 | WLRErrorNotFound = 45150, 14 | 15 | /** The matched route handler does not specify a target view controller. */ 16 | WLRErrorHandlerTargetOrSourceViewControllerNotSpecified = 45151, 17 | WLRErrorBlockHandleNoReturnRequest = 45152, 18 | WLRErrorMiddlewareRaiseError = 45153, 19 | WLRErrorHandleRequestError = 45154 20 | }; 21 | @interface NSError (WLRError) 22 | +(NSError *)WLRNotFoundError; 23 | +(NSError *)WLRTransitionError; 24 | +(NSError *)WLRHandleBlockNoTeturnRequest; 25 | +(NSError *)WLRMiddlewareRaiseErrorWithMsg:(NSString *)error; 26 | +(NSError *)WLRHandleRequestErrorWithMessage:(NSString *)errorMsg; 27 | @end 28 | -------------------------------------------------------------------------------- /WLRRoute/Classes/NSError+WLRError.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+WLRError.m 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import "NSError+WLRError.h" 10 | NSString * const WLRErrorDomain = @"com.wlrroute.error"; 11 | 12 | @implementation NSError (WLRError) 13 | +(NSError *)WLRNotFoundError{ 14 | return [self WLRErrorWithCode:WLRErrorNotFound msg:@"The passed URL does not match a registered route."]; 15 | } 16 | +(NSError *)WLRTransitionError{ 17 | 18 | return [self WLRErrorWithCode:WLRErrorHandlerTargetOrSourceViewControllerNotSpecified msg:@"TargetViewController or SourceViewController not correct"]; 19 | } 20 | +(NSError *)WLRHandleBlockNoTeturnRequest 21 | { 22 | return [self WLRErrorWithCode:WLRErrorBlockHandleNoReturnRequest msg:@"Block handle no turn WLRRouteRequest object"]; 23 | } 24 | 25 | +(NSError *)WLRMiddlewareRaiseErrorWithMsg:(NSString *)error{ 26 | return [self WLRErrorWithCode:WLRErrorMiddlewareRaiseError msg:[NSString stringWithFormat:@"WLRRouteMiddle raise a error:%@",error]]; 27 | } 28 | +(NSError *)WLRHandleRequestErrorWithMessage:(NSString *)errorMsg; 29 | { 30 | return [self WLRErrorWithCode:WLRErrorHandleRequestError msg:[NSString stringWithFormat:@"WLRHandler raise a error:%@",errorMsg]]; 31 | } 32 | +(NSError *)WLRErrorWithCode:(NSInteger)code msg:(NSString *)msg{ 33 | NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: NSLocalizedString(msg, nil) }; 34 | return [NSError errorWithDomain:WLRErrorDomain code:code userInfo:userInfo]; 35 | } 36 | @end 37 | -------------------------------------------------------------------------------- /WLRRoute/Classes/NSString+WLRQuery.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+WLRQuery.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/16. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (WLRQuery) 12 | + (NSString *)WLRQueryStringWithParameters:(NSDictionary *)parameters ; 13 | - (NSDictionary *)WLRParametersFromQueryString ; 14 | - (NSString *)WLRStringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding ; 15 | - (NSString *)WLRStringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding; 16 | @end 17 | -------------------------------------------------------------------------------- /WLRRoute/Classes/NSString+WLRQuery.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+WLRQuery.m 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/16. 6 | // 7 | // 8 | 9 | #import "NSString+WLRQuery.h" 10 | 11 | @implementation NSString (WLRQuery) 12 | + (NSString *)WLRQueryStringWithParameters:(NSDictionary *)parameters { 13 | NSMutableString *query = [NSMutableString string]; 14 | [[parameters allKeys] enumerateObjectsUsingBlock:^(NSString *key, NSUInteger idx, BOOL *stop) { 15 | NSString *value = [parameters[key] description]; 16 | key = [key WLRStringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 17 | value = [value WLRStringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 18 | [query appendFormat:@"%@%@%@%@", (idx > 0) ? @"&" : @"", key, (value.length > 0) ? @"=" : @"", value]; 19 | }]; 20 | return [query copy]; 21 | } 22 | 23 | 24 | - (NSDictionary *)WLRParametersFromQueryString { 25 | NSArray *params = [self componentsSeparatedByString:@"&"]; 26 | NSMutableDictionary *paramsDict = [NSMutableDictionary dictionaryWithCapacity:[params count]]; 27 | for (NSString *param in params) { 28 | NSArray *pairs = [param componentsSeparatedByString:@"="]; 29 | if (pairs.count == 2) { 30 | // e.g. ?key=value 31 | NSString *key = [pairs[0] WLRStringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 32 | NSString *value = [pairs[1] WLRStringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 33 | paramsDict[key] = value; 34 | } 35 | else if (pairs.count == 1) { 36 | // e.g. ?key 37 | NSString *key = [[pairs firstObject] WLRStringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 38 | paramsDict[key] = @""; 39 | } 40 | } 41 | return [paramsDict copy]; 42 | } 43 | 44 | 45 | #pragma mark - URL Encoding/Decoding 46 | 47 | - (NSString *)WLRStringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding { 48 | NSCharacterSet *allowedCharactersSet = [NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~"]; 49 | return [self stringByAddingPercentEncodingWithAllowedCharacters:allowedCharactersSet]; 50 | } 51 | 52 | 53 | - (NSString *)WLRStringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding { 54 | return [self stringByRemovingPercentEncoding]; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /WLRRoute/Classes/UIViewController+WLRRoute.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+WLRRoute.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/16. 6 | // 7 | // 8 | 9 | #import 10 | @class WLRRouteRequest; 11 | @interface UIViewController (WLRRoute) 12 | @property(nonatomic,strong)WLRRouteRequest * wlr_request; 13 | @end 14 | -------------------------------------------------------------------------------- /WLRRoute/Classes/UIViewController+WLRRoute.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+WLRRoute.m 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/16. 6 | // 7 | // 8 | 9 | #import "UIViewController+WLRRoute.h" 10 | #import 11 | #import "WLRRouteRequest.h" 12 | @implementation UIViewController (WLRRoute) 13 | @dynamic wlr_request; 14 | -(WLRRouteRequest *)wlr_request{ 15 | WLRRouteRequest * dict = objc_getAssociatedObject(self, "wlr_request"); 16 | return dict; 17 | } 18 | -(void)setWlr_request:(WLRRouteRequest *)wlr_request{ 19 | objc_setAssociatedObject(self, "wlr_request", wlr_request, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 20 | } 21 | +(void)load{ 22 | [self exchangeMethodWithClass:[self class] originalSelector:sel_getUid("viewDidDisappear:") swizzledSelector:@selector(wlr_viewDidDisappearSwzzled:)]; 23 | } 24 | -(void)wlr_viewDidDisappearSwzzled:(BOOL)animated{ 25 | NSLog(@"wlr_viewDidDisappearSwzzled"); 26 | if (self.wlr_request != nil && self.wlr_request.isConsumed == NO) { 27 | [self.wlr_request defaultFinishTargetCallBack]; 28 | } 29 | self.wlr_request = nil; 30 | [self wlr_viewDidDisappearSwzzled:animated]; 31 | } 32 | +(void)exchangeMethodWithClass:(Class)class originalSelector:(SEL)originalSelector swizzledSelector:(SEL)swizzledSelector{ 33 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 34 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 35 | /* 36 | 如果这个类没有实现 originalSelector ,但其父类实现了,那 class_getInstanceMethod 会返回父类的方法。这样 method_exchangeImplementations 替换的是父类的那个方法,这当然不是你想要的。所以我们先尝试添加 orginalSelector ,如果已经存在,再用 method_exchangeImplementations 把原方法的实现跟新的方法实现给交换掉。 37 | */ 38 | BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); 39 | if (didAddMethod) { 40 | class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); 41 | } 42 | else{ 43 | method_exchangeImplementations(originalMethod, swizzledMethod); 44 | } 45 | 46 | } 47 | @end 48 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRMatchResult.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRMatchResult.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import 10 | /** 11 | The WLRMatchResult object is a result of whether a request url is matching for a handler or handleBlock. 12 | 该对象是一个url是否匹配的结果对象,paramProperties字典包含了url上的匹配参数。 13 | */ 14 | 15 | @interface WLRMatchResult : NSObject 16 | /** 17 | If matched,value is YES. 18 | */ 19 | @property (nonatomic, assign, getter=isMatch) BOOL match; 20 | /** 21 | If matched,the paramProperties dictionary will store url's path keyword paramaters away. 22 | 如果匹配成功,url路径中的关键字对应的值将存储在该字典中. 23 | */ 24 | @property (nonatomic, strong) NSDictionary *paramProperties; 25 | @end 26 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRMatchResult.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRMatchResult.m 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import "WLRMatchResult.h" 10 | 11 | @implementation WLRMatchResult 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRegularExpression.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRegularExpression.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import 10 | @class WLRMatchResult; 11 | /** 12 | This object is a regularExpression,it can match a url and return the result with WLRMatchResult object. 13 | */ 14 | @interface WLRRegularExpression : NSRegularExpression 15 | 16 | /** 17 | This method can return a WLRMatchResult object to check a url string is matched. 18 | 19 | @param string a url string 20 | @return matching result 21 | */ 22 | -(WLRMatchResult *)matchResultForString:(NSString *)string; 23 | +(WLRRegularExpression *)expressionWithPattern:(NSString *)pattern; 24 | @end 25 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRegularExpression.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRegularExpression.m 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import "WLRRegularExpression.h" 10 | #import "WLRMatchResult.h" 11 | static NSString * const WLRRouteParamPattern=@":[a-zA-Z0-9-_][^/]+"; 12 | static NSString * const WLRRouteParamNamePattern=@":[a-zA-Z0-9-_]+"; 13 | static NSString * const WLPRouteParamMatchPattern=@"([^/]+)"; 14 | @interface WLRRegularExpression () 15 | @property(nonatomic,strong)NSArray * routerParamNamesArr; 16 | @end 17 | @implementation WLRRegularExpression 18 | +(WLRRegularExpression *)expressionWithPattern:(NSString *)pattern{ 19 | NSError *error; 20 | WLRRegularExpression * exp =[[WLRRegularExpression alloc]initWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:&error]; 21 | if (error) { 22 | NSLog(@"%@",error); 23 | } 24 | return exp; 25 | } 26 | -(instancetype)initWithPattern:(NSString *)pattern options:(NSRegularExpressionOptions)options error:(NSError * _Nullable __autoreleasing *)error{ 27 | //将url匹配表达式转换成去掉:***的正则表达式 28 | NSString *transformedPattern = [WLRRegularExpression transfromFromPattern:pattern]; 29 | if (self = [super initWithPattern:transformedPattern options:options error:error]) { 30 | self.routerParamNamesArr = [[self class] routeParamNamesFromPattern:pattern]; 31 | } 32 | return self; 33 | } 34 | 35 | /** 36 | 通过一个url生产出一个WLRMatchResult,检查是否匹配,并且将url路径中的关键字参数对应的值放入WLRMatchResult对象中 37 | 38 | @param string 一个需要匹配的url 39 | @return 匹配结果WLRMatchResult对象 40 | */ 41 | -(WLRMatchResult *)matchResultForString:(NSString *)string{ 42 | NSArray * array = [self matchesInString:string options:0 range:NSMakeRange(0, string.length)]; 43 | WLRMatchResult * result = [[WLRMatchResult alloc]init]; 44 | if (array.count == 0) { 45 | return result; 46 | } 47 | result.match = YES; 48 | NSMutableDictionary * paramDict = [NSMutableDictionary dictionary]; 49 | for (NSTextCheckingResult * paramResult in array) { 50 | for (int i = 1; i * )paramPatternStringsFromPattern:(NSString *)pattern{ 96 | NSError *err; 97 | NSRegularExpression * paramPatternEx = [NSRegularExpression regularExpressionWithPattern:WLRRouteParamPattern options:NSRegularExpressionCaseInsensitive error:&err]; 98 | NSArray * paramPatternResults = [paramPatternEx matchesInString:pattern options:NSMatchingReportProgress range:NSMakeRange(0, pattern.length)]; 99 | NSMutableArray * array = [NSMutableArray array]; 100 | for (NSTextCheckingResult * paramPattern in paramPatternResults) { 101 | NSString * paramPatternString = [pattern substringWithRange:paramPattern.range]; 102 | [array addObject:paramPatternString]; 103 | } 104 | return array; 105 | } 106 | 107 | /** 108 | 将原表达式中':name()'中的name全部过滤出来形成数组 109 | 110 | @param pattern url的匹配表达式 111 | @return url中匹配的路径中的关键字数组 112 | */ 113 | +(NSArray *)routeParamNamesFromPattern:(NSString *)pattern{ 114 | NSRegularExpression *paramNameEx = [NSRegularExpression regularExpressionWithPattern:WLRRouteParamNamePattern options:NSRegularExpressionCaseInsensitive error:nil]; 115 | NSArray * routeParamStrings = [self paramPatternStringsFromPattern:pattern]; 116 | NSMutableArray *routeParamNames = [[NSMutableArray alloc]init]; 117 | for (NSString *routeParamSting in routeParamStrings) { 118 | NSTextCheckingResult * foundRouteParamNameResult = [[paramNameEx matchesInString:routeParamSting options:NSMatchingReportProgress range:NSMakeRange(0, routeParamSting.length)] firstObject]; 119 | if (foundRouteParamNameResult) { 120 | NSString *routeParamNameSting = [routeParamSting substringWithRange:foundRouteParamNameResult.range]; 121 | routeParamNameSting = [routeParamNameSting stringByReplacingOccurrencesOfString:@":" withString:@""]; 122 | [routeParamNames addObject:routeParamNameSting]; 123 | } 124 | } 125 | return routeParamNames; 126 | } 127 | @end 128 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRoute.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRoute.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/18. 6 | // 7 | // 8 | 9 | #ifndef WLRRoute_h 10 | #define WLRRoute_h 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #endif /* WLRRoute_h */ 22 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRouteHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouteHandler.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import 10 | @class WLRRouteRequest; 11 | /** 12 | This is a handler object, if a WLRRouteRequest object matched, WLRRouter object will invoke shouldHandleWithRequest、handleRequest method and transitionWithWithRequest method,you can overwrite some method to complete viewcontroller transition. 13 | WLRRouteHandler对象与WLRRouteMatcher对象相对应,如果一个WLRRouteRequest对象匹配到该handler对象,则WLRRouter将触发 handleRequest 方法和transitionWithWithRequest方法,完成一次视图控制器的转场. 14 | */ 15 | @interface WLRRouteHandler : NSObject 16 | - (BOOL)shouldHandleWithRequest:(WLRRouteRequest *)request; 17 | -(UIViewController *)targetViewControllerWithRequest:(WLRRouteRequest *)request; 18 | -(UIViewController *)sourceViewControllerForTransitionWithRequest:(WLRRouteRequest *)request; 19 | -(BOOL)handleRequest:(WLRRouteRequest *)request error:(NSError *__autoreleasing *)error; 20 | -(BOOL)transitionWithWithRequest:(WLRRouteRequest *)request sourceViewController:(UIViewController *)sourceViewController targetViewController:(UIViewController *)targetViewController isPreferModal:(BOOL)isPreferModal error:(NSError *__autoreleasing *)error; 21 | - (BOOL)preferModalPresentationWithRequest:(WLRRouteRequest *)request; 22 | @end 23 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRouteHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouteHandler.m 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import "WLRRouteHandler.h" 10 | #import "WLRMatchResult.h" 11 | #import "UIViewController+WLRRoute.h" 12 | #import "NSError+WLRError.h" 13 | @implementation WLRRouteHandler 14 | -(BOOL)shouldHandleWithRequest:(WLRRouteRequest *)request{ 15 | return YES; 16 | } 17 | -(UIViewController *)targetViewControllerWithRequest:(WLRRouteRequest *)request{ 18 | 19 | return [[NSClassFromString(@"HBTestViewController") alloc]init]; 20 | } 21 | -(UIViewController *)sourceViewControllerForTransitionWithRequest:(WLRRouteRequest *)request{ 22 | return [UIApplication sharedApplication].windows[0].rootViewController; 23 | } 24 | -(BOOL)handleRequest:(WLRRouteRequest *)request error:(NSError *__autoreleasing *)error{ 25 | UIViewController * sourceViewController = [self sourceViewControllerForTransitionWithRequest:request]; 26 | UIViewController * targetViewController = [self targetViewControllerWithRequest:request]; 27 | if ((![sourceViewController isKindOfClass:[UIViewController class]])||(![targetViewController isKindOfClass:[UIViewController class]])) { 28 | *error = [NSError WLRTransitionError]; 29 | return NO; 30 | } 31 | if (targetViewController != nil) { 32 | targetViewController.wlr_request = request; 33 | } 34 | BOOL isPreferModal = [self preferModalPresentationWithRequest:request]; 35 | return [self transitionWithWithRequest:request sourceViewController:sourceViewController targetViewController:targetViewController isPreferModal:isPreferModal error:error]; 36 | } 37 | -(BOOL)transitionWithWithRequest:(WLRRouteRequest *)request sourceViewController:(UIViewController *)sourceViewController targetViewController:(UIViewController *)targetViewController isPreferModal:(BOOL)isPreferModal error:(NSError *__autoreleasing *)error{ 38 | if (isPreferModal||![sourceViewController isKindOfClass:[UINavigationController class]]) { 39 | [sourceViewController presentViewController:targetViewController animated:YES completion:nil]; 40 | } 41 | else if ([sourceViewController isKindOfClass:[UINavigationController class]]){ 42 | UINavigationController * nav = (UINavigationController *)sourceViewController; 43 | [nav pushViewController:targetViewController animated:YES]; 44 | } 45 | return YES; 46 | } 47 | 48 | - (BOOL)preferModalPresentationWithRequest:(WLRRouteRequest *)request;{ 49 | return NO; 50 | } 51 | @end 52 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRouteMatcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouteMatcher.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import 10 | @class WLRRouteRequest; 11 | /** 12 | This object create a route WLRRouteRequest object with url matched string,it store the routeExpressionPattern and originalRouteExpression. 13 | 该对象会根据url匹配表达式生成一个WLRRouteRequest路由请求对象,如果为nil则说明不匹配,如果不为nil则说明该url可以匹配. 14 | */ 15 | @interface WLRRouteMatcher : NSObject 16 | /** 17 | a url matched regex pattern string. 18 | */ 19 | @property(nonatomic,copy)NSString * routeExpressionPattern; 20 | /** 21 | original route url matched pattern string 22 | */ 23 | @property(nonatomic,copy)NSString * originalRouteExpression; 24 | +(instancetype)matcherWithRouteExpression:(NSString *)expression; 25 | /** 26 | If a NSURL object matched with routeExpressionPattern,return a WLRRouteRequest object or,otherwise return nil. 27 | 28 | @param URL a request url string. 29 | @param primitiveParameters some primitive parameters like UIImage object and so on. 30 | @param targetCallBack if complete handle or complete block progress,it will call targetCallBack. 31 | @return a WLRRouteRequest request object. 32 | */ 33 | -(WLRRouteRequest *)createRequestWithURL:(NSURL *)URL primitiveParameters:(NSDictionary *)primitiveParameters targetCallBack:(void(^)(NSError *, id responseObject))targetCallBack; 34 | @end 35 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRouteMatcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouteMatcher.m 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import "WLRRouteMatcher.h" 10 | #import "WLRRegularExpression.h" 11 | #import "WLRRouteRequest.h" 12 | #import "WLRMatchResult.h" 13 | @interface WLRRouteMatcher() 14 | @property(nonatomic,copy) NSString * scheme; 15 | @property(nonatomic,strong)WLRRegularExpression * regexMatcher; 16 | @end 17 | @implementation WLRRouteMatcher 18 | +(instancetype)matcherWithRouteExpression:(NSString *)expression{ 19 | return [[self alloc]initWithRouteExpression:expression]; 20 | } 21 | -(instancetype)initWithRouteExpression:(NSString *)routeExpression{ 22 | if (![routeExpression length]) { 23 | return nil; 24 | } 25 | if (self = [super init]) { 26 | /* 27 | 将路由的url匹配表达式进行分割,分割出scheme和后续部分,后续部分形成WLRRegularExpression对象,并将url匹配表达式保存在_originalRouteExpression变量中 28 | */ 29 | NSArray * parts = [routeExpression componentsSeparatedByString:@"://"]; 30 | _scheme = parts.count>1?[parts firstObject]:nil; 31 | _routeExpressionPattern =[parts lastObject]; 32 | _regexMatcher = [WLRRegularExpression expressionWithPattern:_routeExpressionPattern]; 33 | _originalRouteExpression = routeExpression; 34 | } 35 | return self; 36 | } 37 | -(WLRRouteRequest *)createRequestWithURL:(NSURL *)URL primitiveParameters:(NSDictionary *)primitiveParameters targetCallBack:(void (^)(NSError *, id))targetCallBack{ 38 | NSString * urlString = [NSString stringWithFormat:@"%@%@",URL.host,URL.path]; 39 | if (self.scheme.length && ![self.scheme isEqualToString:URL.scheme]) { 40 | return nil; 41 | } 42 | WLRMatchResult * result = [self.regexMatcher matchResultForString:urlString]; 43 | if (!result.isMatch) { 44 | return nil; 45 | } 46 | WLRRouteRequest * request = [[WLRRouteRequest alloc]initWithURL:URL routeExpression:self.routeExpressionPattern routeParameters:result.paramProperties primitiveParameters:primitiveParameters targetCallBack:targetCallBack]; 47 | return request; 48 | 49 | } 50 | @end 51 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRouteMiddlewareProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouteMiddlewareProtocol.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import 10 | @class WLRRouteRequest; 11 | @protocol WLRRouteMiddleware 12 | 13 | 14 | /** 15 | middleware handle a request, if middleware can handle this request, should return a response object, middleware could modify primitiveRequest inner, router will check and capture error and return dictionary, if return nil, router will transfer this request from current middleware to other 16 | 17 | @param primitiveRequest primitive request, middleware can modify this request 18 | @param error if middleware can handle this request and raise a error, router will handle this request with error and no long transfer. 19 | @return if middleware can handle this request and return a responseObject, 20 | router will handle this request with responseObject and no long transfer. 21 | */ 22 | -(NSDictionary *)middlewareHandleRequestWith:(WLRRouteRequest *__autoreleasing *)primitiveRequest error:(NSError *__autoreleasing *)error; 23 | @end 24 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRouteRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouteRequest.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import 10 | typedef void(^WLRRouteCompletionHandler)(NSError *error,NSDictionary * responseObject); 11 | @interface WLRRouteRequest : NSObject 12 | /** 13 | 请求的URL 14 | */ 15 | @property (nonatomic, copy, readonly) NSURL *URL; 16 | @property(nonatomic,copy)NSString * routeExpression; 17 | @property (nonatomic, copy, readonly) NSDictionary *queryParameters; 18 | @property (nonatomic, copy, readonly) NSDictionary *routeParameters; 19 | @property (nonatomic, copy, readonly) NSDictionary *primitiveParams; 20 | 21 | @property (nonatomic, strong) NSURL *callbackURL; 22 | @property(nonatomic,copy)WLRRouteCompletionHandler targetCallBack; 23 | @property(nonatomic)BOOL isConsumed; 24 | - (id)objectForKeyedSubscript:(NSString *)key; 25 | -(instancetype)initWithURL:(NSURL *)URL routeExpression:(NSString *)routeExpression routeParameters:(NSDictionary *)routeParameters primitiveParameters:(NSDictionary *)primitiveParameters targetCallBack:(void(^)(NSError * error,id responseObject))targetCallBack; 26 | -(instancetype)initWithURL:(NSURL *)URL; 27 | -(void)defaultFinishTargetCallBack; 28 | @end 29 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRouteRequest.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouteRequest.m 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import "WLRRouteRequest.h" 10 | #import "NSString+WLRQuery.h" 11 | @interface WLRRouteRequest() 12 | 13 | @end 14 | @implementation WLRRouteRequest 15 | -(void)setTargetCallBack:(WLRRouteCompletionHandler)targetCallBack{ 16 | __weak WLRRouteRequest * weakRequest = self; 17 | if (targetCallBack == nil) { 18 | return; 19 | } 20 | self.isConsumed = NO; 21 | _targetCallBack = ^(NSError *error, NSDictionary * responseObject){ 22 | weakRequest.isConsumed = YES; 23 | targetCallBack(error,responseObject); 24 | }; 25 | 26 | } 27 | -(void)defaultFinishTargetCallBack{ 28 | if (self.targetCallBack && self.isConsumed == NO) { 29 | self.targetCallBack(nil,@{@"message":@"call back success"}); 30 | } 31 | } 32 | -(instancetype)initWithURL:(NSURL *)URL{ 33 | if (!URL) { 34 | return nil; 35 | } 36 | self = [super init]; 37 | if (self) { 38 | _URL = URL; 39 | _queryParameters = [[_URL query] WLRParametersFromQueryString]; 40 | } 41 | return self; 42 | } 43 | -(instancetype)initWithURL:(NSURL *)URL routeExpression:(NSString *)routeExpression routeParameters:(NSDictionary *)routeParameters primitiveParameters:(NSDictionary *)primitiveParameters targetCallBack:(void (^)(NSError *, id))targetCallBack{ 44 | if (!URL) { 45 | return nil; 46 | } 47 | self = [super init]; 48 | if (self) { 49 | _URL = URL; 50 | _queryParameters = [[_URL query] WLRParametersFromQueryString]; 51 | _routeExpression = routeExpression; 52 | _routeParameters = routeParameters; 53 | _primitiveParams = primitiveParameters; 54 | self.targetCallBack = targetCallBack; 55 | } 56 | return self; 57 | } 58 | -(void)setRouteParameters:(NSDictionary *)routeParameters{ 59 | _routeParameters = routeParameters; 60 | 61 | } 62 | -(void)setPrimitiveParams:(NSDictionary *)primitiveParams{ 63 | _primitiveParams = primitiveParams; 64 | } 65 | - (NSString *)description { 66 | return [NSString stringWithFormat: 67 | @"\n<%@ %p\n" 68 | @"\t URL: \"%@\"\n" 69 | @"\t queryParameters: \"%@\"\n" 70 | @"\t routeParameters: \"%@\"\n" 71 | @"\t PrimitiveParam: \"%@\"\n" 72 | @">", 73 | NSStringFromClass([self class]), 74 | self, 75 | [self.URL description], 76 | self.queryParameters, 77 | self.routeParameters, 78 | self.primitiveParams]; 79 | } 80 | -(id)objectForKeyedSubscript:(NSString *)key{ 81 | id value = self.routeParameters[key]; 82 | if (!value) { 83 | value = self.queryParameters[key]; 84 | } 85 | if (!value) { 86 | value = self.primitiveParams[key]; 87 | } 88 | return value; 89 | } 90 | -(NSURL *)callbackURL{ 91 | if (!_callbackURL) { 92 | for (NSString * key in self.routeParameters.allKeys) { 93 | if ([[key lowercaseString] rangeOfString:@"callback"].location != NSNotFound) { 94 | NSString * urlstring = self.routeParameters[key]; 95 | NSURL * url = [NSURL URLWithString:urlstring]; 96 | if (url) { 97 | _callbackURL = url; 98 | return _callbackURL; 99 | } 100 | } 101 | } 102 | for (NSString * key in self.queryParameters.allKeys) { 103 | if ([[key lowercaseString] rangeOfString:@"callback"].location != NSNotFound) { 104 | NSString * urlstring = self.queryParameters[key]; 105 | NSURL * url = [NSURL URLWithString:urlstring]; 106 | if (url) { 107 | _callbackURL = url; 108 | return _callbackURL; 109 | } 110 | } 111 | } 112 | for (NSString * key in self.primitiveParams.allKeys) { 113 | if ([[key lowercaseString] rangeOfString:@"callback"].location != NSNotFound) { 114 | NSString * urlstring = self.primitiveParams[key]; 115 | NSURL * url = [NSURL URLWithString:urlstring]; 116 | if (url) { 117 | _callbackURL = url; 118 | return _callbackURL; 119 | } 120 | } 121 | } 122 | } 123 | return _callbackURL; 124 | } 125 | -(id)copyWithZone:(NSZone *)zone{ 126 | WLRRouteRequest * copyRequest = [[WLRRouteRequest alloc]initWithURL:self.URL]; 127 | copyRequest.routeParameters = self.routeParameters; 128 | copyRequest.routeExpression = self.routeExpression; 129 | copyRequest.primitiveParams = self.primitiveParams; 130 | copyRequest.targetCallBack = self.targetCallBack; 131 | copyRequest.isConsumed = self.isConsumed; 132 | self.isConsumed = YES; 133 | return copyRequest; 134 | } 135 | @end 136 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRouter.h: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouter.h 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import 10 | #import "WLRRouteMiddlewareProtocol.h" 11 | @class WLRRouteRequest; 12 | @class WLRRouteHandler; 13 | 14 | /** 15 | Main route object,it can register a route pattern for a handler or block,manage middlewares,provide Subscription. 16 | 路由对象实体,提供注册route表达式和对应handler、block功能,提供中间件注册,提供下标访问的快捷方法 17 | */ 18 | @interface WLRRouter : NSObject 19 | 20 | /** 21 | 注册一个route表达式并与一个block处理相关联 22 | 23 | @param routeHandlerBlock block用以处理匹配route表达式的url的请求 24 | @param route url的路由表达式,支持正则表达式的分组,例如app://login/:phone({0,9+})是一个表达式,:phone代表该路径值对应的key,可以在WLRRouteRequest对象中的routeParameters中获取 25 | */ 26 | -(void)registerBlock:(WLRRouteRequest *(^)(WLRRouteRequest * request))routeHandlerBlock forRoute:(NSString *)route; 27 | /** 28 | 注册一个route表达式并与一个block处理相关联 29 | 30 | @param routeHandlerBlock handler对象用以处理匹配route表达式的url的请求 31 | @param route url的路由表达式,支持正则表达式的分组,例如app://login/:phone({0,9+})是一个表达式,:phone代表该路径值对应的key,可以在WLRRouteRequest对象中的routeParameters中获取 32 | */ 33 | -(void)registerHandler:(WLRRouteHandler *)handler forRoute:(NSString *)route; 34 | 35 | /** 36 | 检测url是否能够被处理,不包含中间件的检查 37 | 38 | @param url 请求的url 39 | @return 是否可以handle 40 | */ 41 | -(BOOL)canHandleWithURL:(NSURL *)url; 42 | -(void)setObject:(id)obj forKeyedSubscript:(NSString *)key; 43 | -(id)objectForKeyedSubscript:(NSString *)key; 44 | 45 | /** 46 | 处理url请求 47 | 48 | @param URL 调用的url 49 | @param primitiveParameters 携带的原生对象 50 | @param targetCallBack 传给目标对象的回调block 51 | @param completionBlock 完成路由中转的block 52 | @return 是否能够handle 53 | */ 54 | -(BOOL)handleURL:(NSURL *)URL primitiveParameters:(NSDictionary *)primitiveParameters targetCallBack:(void(^)(NSError *, id responseObject))targetCallBack withCompletionBlock:(void(^)(BOOL handled, NSError *error))completionBlock; 55 | -(void)addMiddleware:(id)middleware; 56 | -(void)removeMiddleware:(id)middleware; 57 | @end 58 | -------------------------------------------------------------------------------- /WLRRoute/Classes/WLRRouter.m: -------------------------------------------------------------------------------- 1 | // 2 | // WLRRouter.m 3 | // Pods 4 | // 5 | // Created by Neo on 2016/12/15. 6 | // 7 | // 8 | 9 | #import "WLRRouter.h" 10 | #import 11 | #import "WLRRouteHandler.h" 12 | #import "WLRRouteMatcher.h" 13 | #import "WLRRouteRequest.h" 14 | #import "NSError+WLRError.h" 15 | @interface WLRRouter() 16 | @property(nonatomic,strong)NSMutableDictionary * routeMatchers; 17 | @property(nonatomic,strong)NSMutableDictionary * routeHandles; 18 | @property(nonatomic,strong)NSMutableDictionary * routeblocks; 19 | @property(nonatomic,strong)NSHashTable * middlewares; 20 | @end 21 | @implementation WLRRouter 22 | -(NSHashTable *)middlewares{ 23 | if (!_middlewares) { 24 | _middlewares = [NSHashTable hashTableWithOptions:NSPointerFunctionsWeakMemory]; 25 | } 26 | return _middlewares; 27 | } 28 | -(void)addMiddleware:(id)middleware{ 29 | if (middleware) { 30 | [self.middlewares addObject:middleware]; 31 | } 32 | } 33 | -(void)removeMiddleware:(id)middleware{ 34 | if ([self.middlewares containsObject:middleware]) { 35 | [self.middlewares removeObject:middleware]; 36 | } 37 | } 38 | -(instancetype)init{ 39 | if (self = [super init]) { 40 | _routeblocks = [NSMutableDictionary dictionary]; 41 | _routeHandles = [NSMutableDictionary dictionary]; 42 | _routeMatchers = [NSMutableDictionary dictionary]; 43 | } 44 | return self; 45 | } 46 | -(void)registerBlock:(WLRRouteRequest *(^)(WLRRouteRequest *))routeHandlerBlock forRoute:(NSString *)route{ 47 | if (routeHandlerBlock && [route length]) { 48 | [self.routeMatchers setObject:[WLRRouteMatcher matcherWithRouteExpression:route] forKey:route]; 49 | [self.routeHandles removeObjectForKey:route]; 50 | self.routeblocks[route] = routeHandlerBlock; 51 | } 52 | } 53 | -(void)registerHandler:(WLRRouteHandler *)handler forRoute:(NSString *)route{ 54 | if (handler && [route length]) { 55 | [self.routeMatchers setObject:[WLRRouteMatcher matcherWithRouteExpression:route] forKey:route]; 56 | [self.routeblocks removeObjectForKey:route]; 57 | self.routeHandles[route] = handler; 58 | } 59 | } 60 | -(id)objectForKeyedSubscript:(NSString *)key{ 61 | NSString * route = (NSString *)key; 62 | id obj = nil; 63 | if ([route isKindOfClass:[NSString class]] && [route length]) { 64 | obj = self.routeHandles[route]; 65 | if (obj == nil) { 66 | obj = self.routeblocks[route]; 67 | } 68 | } 69 | return obj; 70 | } 71 | -(void)setObject:(id)obj forKeyedSubscript:(NSString *)key{ 72 | NSString * route = (NSString *)key; 73 | if (!([route isKindOfClass:[NSString class]] && [route length])) { 74 | return; 75 | } 76 | if (!obj) { 77 | [self.routeblocks removeObjectForKey:route]; 78 | [self.routeHandles removeObjectForKey:route]; 79 | [self.routeMatchers removeObjectForKey:route]; 80 | } 81 | else if ([obj isKindOfClass:NSClassFromString(@"NSBlock")]){ 82 | [self registerBlock:obj forRoute:route]; 83 | } 84 | else if ([obj isKindOfClass:[WLRRouteHandler class]]){ 85 | [self registerHandler:obj forRoute:route]; 86 | } 87 | } 88 | -(BOOL)canHandleWithURL:(NSURL *)url{ 89 | for (NSString * route in self.routeMatchers.allKeys) { 90 | WLRRouteMatcher * matcher = [self.routeMatchers objectForKey:route]; 91 | WLRRouteRequest * request = [matcher createRequestWithURL:url primitiveParameters:nil targetCallBack:nil]; 92 | if (request) { 93 | return YES; 94 | } 95 | } 96 | return NO; 97 | } 98 | -(BOOL)handleURL:(NSURL *)URL primitiveParameters:(NSDictionary *)primitiveParameters targetCallBack:(void(^)(NSError *error, id responseObject))targetCallBack withCompletionBlock:(void(^)(BOOL handled, NSError *error))completionBlock{ 99 | if (!URL) { 100 | return NO; 101 | } 102 | NSError * error; 103 | WLRRouteRequest * request; 104 | __block BOOL isHandled = NO; 105 | for (NSString * route in self.routeMatchers.allKeys) { 106 | WLRRouteMatcher * matcher = [self.routeMatchers objectForKey:route]; 107 | request = [matcher createRequestWithURL:URL primitiveParameters:primitiveParameters targetCallBack:targetCallBack]; 108 | if (request) { 109 | NSDictionary * responseObject; 110 | for (idmiddleware in self.middlewares){ 111 | if (middleware != NULL &&[middleware respondsToSelector:@selector(middlewareHandleRequestWith:error:)]) { 112 | responseObject = [middleware middlewareHandleRequestWith:&request error:&error]; 113 | if ((responseObject != nil )||(error != nil)) { 114 | isHandled = YES; 115 | if (request.targetCallBack) { 116 | dispatch_async(dispatch_get_main_queue(), ^{ 117 | request.targetCallBack(error,responseObject); 118 | }); 119 | } 120 | break; 121 | } 122 | } 123 | } 124 | if (isHandled == NO) { 125 | isHandled = [self handleRouteExpression:route withRequest:request error:&error]; 126 | } 127 | break; 128 | } 129 | } 130 | if (!request) { 131 | error = [NSError WLRNotFoundError]; 132 | } 133 | [self completeRouteWithSuccess:isHandled error:error completionHandler:completionBlock]; 134 | return isHandled; 135 | } 136 | -(BOOL)handleRouteExpression:(NSString *)routeExpression withRequest:(WLRRouteRequest *)request error:(NSError *__autoreleasing *)error { 137 | id handler = self[routeExpression]; 138 | if ([handler isKindOfClass:NSClassFromString(@"NSBlock")]) { 139 | WLRRouteRequest *(^blcok)(WLRRouteRequest *) = handler; 140 | WLRRouteRequest * backRequest = blcok(request); 141 | if (backRequest.isConsumed==NO) { 142 | if (backRequest) { 143 | backRequest.isConsumed = YES; 144 | if (backRequest.targetCallBack) { 145 | dispatch_async(dispatch_get_main_queue(), ^{ 146 | backRequest.targetCallBack(nil,nil); 147 | }); 148 | } 149 | } 150 | else{ 151 | request.isConsumed = YES; 152 | if (request.targetCallBack) { 153 | dispatch_async(dispatch_get_main_queue(), ^{ 154 | backRequest.targetCallBack([NSError WLRHandleBlockNoTeturnRequest],nil); 155 | }); 156 | } 157 | } 158 | } 159 | return YES; 160 | } 161 | else if ([handler isKindOfClass:[WLRRouteHandler class]]){ 162 | WLRRouteHandler * rHandler = (WLRRouteHandler *)handler; 163 | if (![rHandler shouldHandleWithRequest:request]) { 164 | return NO; 165 | } 166 | return [rHandler handleRequest:request error:error]; 167 | } 168 | return YES; 169 | } 170 | - (void)completeRouteWithSuccess:(BOOL)handled error:(NSError *)error completionHandler:(void(^)(BOOL handled, NSError *error))completionHandler { 171 | if (completionHandler) { 172 | dispatch_async(dispatch_get_main_queue(), ^{ 173 | completionHandler(handled, error); 174 | }); 175 | } 176 | } 177 | @end 178 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj --------------------------------------------------------------------------------