├── banner.png ├── Infographics.png ├── Router.framework.zip ├── .swiftpm └── xcode │ └── package.xcworkspace │ └── contents.xcworkspacedata ├── Router.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── xcshareddata │ └── xcschemes │ │ └── Router.xcscheme └── project.pbxproj ├── Package.swift ├── Sources ├── Router.h ├── Info.plist └── Router │ └── Router.swift ├── LICENSE ├── .gitignore ├── CODE_OF_CONDUCT.md └── README.md /banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freshOS/Router-deprecated/HEAD/banner.png -------------------------------------------------------------------------------- /Infographics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freshOS/Router-deprecated/HEAD/Infographics.png -------------------------------------------------------------------------------- /Router.framework.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freshOS/Router-deprecated/HEAD/Router.framework.zip -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Router.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Router.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.1 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "Router", 8 | platforms: [.iOS(.v8)], 9 | products: [.library(name: "Router", targets: ["Router"])], 10 | targets: [.target(name: "Router")] 11 | ) 12 | -------------------------------------------------------------------------------- /Sources/Router.h: -------------------------------------------------------------------------------- 1 | // 2 | // Router.h 3 | // Router 4 | // 5 | // Created by Sacha Durand Saint Omer on 27/02/2017. 6 | // Copyright © 2017 freshOS. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Router. 12 | FOUNDATION_EXPORT double RouterVersionNumber; 13 | 14 | //! Project version string for Router. 15 | FOUNDATION_EXPORT const unsigned char RouterVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Sources/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 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 freshOS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /Sources/Router/Router.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Router.swift 3 | // Router 4 | // 5 | // Created by Sacha Durand Saint Omer on 27/02/2017. 6 | // Copyright © 2017 freshOS. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class Router { 12 | public static let `default`:IsRouter = DefaultRouter() 13 | } 14 | 15 | public protocol Navigation { } 16 | 17 | public protocol AppNavigation { 18 | func viewcontrollerForNavigation(navigation: Navigation) -> UIViewController 19 | func navigate(_ navigation: Navigation, from: UIViewController, to: UIViewController) 20 | } 21 | 22 | public protocol IsRouter { 23 | func setupAppNavigation(appNavigation: AppNavigation) 24 | func navigate(_ navigation: Navigation, from: UIViewController) 25 | func didNavigate(block: @escaping (Navigation) -> Void) 26 | var appNavigation: AppNavigation? { get } 27 | } 28 | 29 | public extension UIViewController { 30 | func navigate(_ navigation: Navigation) { 31 | Router.default.navigate(navigation, from: self) 32 | } 33 | } 34 | 35 | public class DefaultRouter: IsRouter { 36 | 37 | public var appNavigation: AppNavigation? 38 | var didNavigateBlocks = [((Navigation) -> Void)] () 39 | 40 | public func setupAppNavigation(appNavigation: AppNavigation) { 41 | self.appNavigation = appNavigation 42 | } 43 | 44 | public func navigate(_ navigation: Navigation, from: UIViewController) { 45 | if let toVC = appNavigation?.viewcontrollerForNavigation(navigation: navigation) { 46 | appNavigation?.navigate(navigation, from: from, to: toVC) 47 | for b in didNavigateBlocks { 48 | b(navigation) 49 | } 50 | } 51 | } 52 | 53 | public func didNavigate(block: @escaping (Navigation) -> Void) { 54 | didNavigateBlocks.append(block) 55 | } 56 | } 57 | 58 | // Injection helper 59 | public protocol Initializable { init() } 60 | open class RuntimeInjectable: NSObject, Initializable { 61 | public required override init() {} 62 | } 63 | 64 | public func appNavigationFromString(_ appNavigationClassString: String) -> AppNavigation { 65 | let appNavClass = NSClassFromString(appNavigationClassString) as! RuntimeInjectable.Type 66 | let appNav = appNavClass.init() 67 | return appNav as! AppNavigation 68 | } 69 | 70 | -------------------------------------------------------------------------------- /Router.xcodeproj/xcshareddata/xcschemes/Router.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at sachadso@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /Router.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 997ECB531E645B5700384E63 /* Router.h in Headers */ = {isa = PBXBuildFile; fileRef = 997ECB501E645B5700384E63 /* Router.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 99F87A5823B1029700E16A4C /* Router.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99F87A5723B1029700E16A4C /* Router.swift */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXFileReference section */ 15 | 997CC2551E64079100250EB1 /* Router.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Router.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 16 | 997ECB4F1E645B5700384E63 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Sources/Info.plist; sourceTree = SOURCE_ROOT; }; 17 | 997ECB501E645B5700384E63 /* Router.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Router.h; path = Sources/Router.h; sourceTree = SOURCE_ROOT; }; 18 | 99F87A5723B1029700E16A4C /* Router.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Router.swift; path = Sources/Router/Router.swift; sourceTree = SOURCE_ROOT; }; 19 | /* End PBXFileReference section */ 20 | 21 | /* Begin PBXFrameworksBuildPhase section */ 22 | 997CC2511E64079100250EB1 /* Frameworks */ = { 23 | isa = PBXFrameworksBuildPhase; 24 | buildActionMask = 2147483647; 25 | files = ( 26 | ); 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXFrameworksBuildPhase section */ 30 | 31 | /* Begin PBXGroup section */ 32 | 997CC24B1E64079100250EB1 = { 33 | isa = PBXGroup; 34 | children = ( 35 | 997CC2571E64079100250EB1 /* Router */, 36 | 997CC2561E64079100250EB1 /* Products */, 37 | ); 38 | sourceTree = ""; 39 | }; 40 | 997CC2561E64079100250EB1 /* Products */ = { 41 | isa = PBXGroup; 42 | children = ( 43 | 997CC2551E64079100250EB1 /* Router.framework */, 44 | ); 45 | name = Products; 46 | sourceTree = ""; 47 | }; 48 | 997CC2571E64079100250EB1 /* Router */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 997ECB4F1E645B5700384E63 /* Info.plist */, 52 | 997ECB501E645B5700384E63 /* Router.h */, 53 | 99F87A5723B1029700E16A4C /* Router.swift */, 54 | ); 55 | path = Router; 56 | sourceTree = ""; 57 | }; 58 | /* End PBXGroup section */ 59 | 60 | /* Begin PBXHeadersBuildPhase section */ 61 | 997CC2521E64079100250EB1 /* Headers */ = { 62 | isa = PBXHeadersBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | 997ECB531E645B5700384E63 /* Router.h in Headers */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXHeadersBuildPhase section */ 70 | 71 | /* Begin PBXNativeTarget section */ 72 | 997CC2541E64079100250EB1 /* Router */ = { 73 | isa = PBXNativeTarget; 74 | buildConfigurationList = 997CC25D1E64079100250EB1 /* Build configuration list for PBXNativeTarget "Router" */; 75 | buildPhases = ( 76 | 997CC2501E64079100250EB1 /* Sources */, 77 | 997CC2511E64079100250EB1 /* Frameworks */, 78 | 997CC2521E64079100250EB1 /* Headers */, 79 | 997CC2531E64079100250EB1 /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = Router; 86 | productName = Router; 87 | productReference = 997CC2551E64079100250EB1 /* Router.framework */; 88 | productType = "com.apple.product-type.framework"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | 997CC24C1E64079100250EB1 /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastUpgradeCheck = 0930; 97 | ORGANIZATIONNAME = freshOS; 98 | TargetAttributes = { 99 | 997CC2541E64079100250EB1 = { 100 | CreatedOnToolsVersion = 8.2.1; 101 | LastSwiftMigration = 1130; 102 | ProvisioningStyle = Automatic; 103 | }; 104 | }; 105 | }; 106 | buildConfigurationList = 997CC24F1E64079100250EB1 /* Build configuration list for PBXProject "Router" */; 107 | compatibilityVersion = "Xcode 3.2"; 108 | developmentRegion = English; 109 | hasScannedForEncodings = 0; 110 | knownRegions = ( 111 | English, 112 | en, 113 | ); 114 | mainGroup = 997CC24B1E64079100250EB1; 115 | productRefGroup = 997CC2561E64079100250EB1 /* Products */; 116 | projectDirPath = ""; 117 | projectRoot = ""; 118 | targets = ( 119 | 997CC2541E64079100250EB1 /* Router */, 120 | ); 121 | }; 122 | /* End PBXProject section */ 123 | 124 | /* Begin PBXResourcesBuildPhase section */ 125 | 997CC2531E64079100250EB1 /* Resources */ = { 126 | isa = PBXResourcesBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | ); 130 | runOnlyForDeploymentPostprocessing = 0; 131 | }; 132 | /* End PBXResourcesBuildPhase section */ 133 | 134 | /* Begin PBXSourcesBuildPhase section */ 135 | 997CC2501E64079100250EB1 /* Sources */ = { 136 | isa = PBXSourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 99F87A5823B1029700E16A4C /* Router.swift in Sources */, 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | /* End PBXSourcesBuildPhase section */ 144 | 145 | /* Begin XCBuildConfiguration section */ 146 | 997CC25B1E64079100250EB1 /* Debug */ = { 147 | isa = XCBuildConfiguration; 148 | buildSettings = { 149 | ALWAYS_SEARCH_USER_PATHS = NO; 150 | CLANG_ANALYZER_NONNULL = YES; 151 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 152 | CLANG_CXX_LIBRARY = "libc++"; 153 | CLANG_ENABLE_MODULES = YES; 154 | CLANG_ENABLE_OBJC_ARC = YES; 155 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 156 | CLANG_WARN_BOOL_CONVERSION = YES; 157 | CLANG_WARN_COMMA = YES; 158 | CLANG_WARN_CONSTANT_CONVERSION = YES; 159 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 160 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 161 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 162 | CLANG_WARN_EMPTY_BODY = YES; 163 | CLANG_WARN_ENUM_CONVERSION = YES; 164 | CLANG_WARN_INFINITE_RECURSION = YES; 165 | CLANG_WARN_INT_CONVERSION = YES; 166 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 167 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 168 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 169 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 170 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 171 | CLANG_WARN_STRICT_PROTOTYPES = YES; 172 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 173 | CLANG_WARN_UNREACHABLE_CODE = YES; 174 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 175 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 176 | COPY_PHASE_STRIP = NO; 177 | CURRENT_PROJECT_VERSION = 1; 178 | DEBUG_INFORMATION_FORMAT = dwarf; 179 | ENABLE_STRICT_OBJC_MSGSEND = YES; 180 | ENABLE_TESTABILITY = YES; 181 | GCC_C_LANGUAGE_STANDARD = gnu99; 182 | GCC_DYNAMIC_NO_PIC = NO; 183 | GCC_NO_COMMON_BLOCKS = YES; 184 | GCC_OPTIMIZATION_LEVEL = 0; 185 | GCC_PREPROCESSOR_DEFINITIONS = ( 186 | "DEBUG=1", 187 | "$(inherited)", 188 | ); 189 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 190 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 191 | GCC_WARN_UNDECLARED_SELECTOR = YES; 192 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 193 | GCC_WARN_UNUSED_FUNCTION = YES; 194 | GCC_WARN_UNUSED_VARIABLE = YES; 195 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 196 | MTL_ENABLE_DEBUG_INFO = YES; 197 | ONLY_ACTIVE_ARCH = YES; 198 | SDKROOT = iphoneos; 199 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 200 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 201 | SWIFT_VERSION = 4.2; 202 | TARGETED_DEVICE_FAMILY = "1,2"; 203 | VERSIONING_SYSTEM = "apple-generic"; 204 | VERSION_INFO_PREFIX = ""; 205 | }; 206 | name = Debug; 207 | }; 208 | 997CC25C1E64079100250EB1 /* Release */ = { 209 | isa = XCBuildConfiguration; 210 | buildSettings = { 211 | ALWAYS_SEARCH_USER_PATHS = NO; 212 | CLANG_ANALYZER_NONNULL = YES; 213 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 214 | CLANG_CXX_LIBRARY = "libc++"; 215 | CLANG_ENABLE_MODULES = YES; 216 | CLANG_ENABLE_OBJC_ARC = YES; 217 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 218 | CLANG_WARN_BOOL_CONVERSION = YES; 219 | CLANG_WARN_COMMA = YES; 220 | CLANG_WARN_CONSTANT_CONVERSION = YES; 221 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 222 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 223 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 224 | CLANG_WARN_EMPTY_BODY = YES; 225 | CLANG_WARN_ENUM_CONVERSION = YES; 226 | CLANG_WARN_INFINITE_RECURSION = YES; 227 | CLANG_WARN_INT_CONVERSION = YES; 228 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 229 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 230 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 231 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 232 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 233 | CLANG_WARN_STRICT_PROTOTYPES = YES; 234 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 235 | CLANG_WARN_UNREACHABLE_CODE = YES; 236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 237 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 238 | COPY_PHASE_STRIP = NO; 239 | CURRENT_PROJECT_VERSION = 1; 240 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 241 | ENABLE_NS_ASSERTIONS = NO; 242 | ENABLE_STRICT_OBJC_MSGSEND = YES; 243 | GCC_C_LANGUAGE_STANDARD = gnu99; 244 | GCC_NO_COMMON_BLOCKS = YES; 245 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 246 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 247 | GCC_WARN_UNDECLARED_SELECTOR = YES; 248 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 249 | GCC_WARN_UNUSED_FUNCTION = YES; 250 | GCC_WARN_UNUSED_VARIABLE = YES; 251 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 252 | MTL_ENABLE_DEBUG_INFO = NO; 253 | SDKROOT = iphoneos; 254 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 255 | SWIFT_VERSION = 4.2; 256 | TARGETED_DEVICE_FAMILY = "1,2"; 257 | VALIDATE_PRODUCT = YES; 258 | VERSIONING_SYSTEM = "apple-generic"; 259 | VERSION_INFO_PREFIX = ""; 260 | }; 261 | name = Release; 262 | }; 263 | 997CC25E1E64079100250EB1 /* Debug */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | CLANG_ENABLE_MODULES = YES; 267 | CODE_SIGN_IDENTITY = ""; 268 | DEFINES_MODULE = YES; 269 | DYLIB_COMPATIBILITY_VERSION = 1; 270 | DYLIB_CURRENT_VERSION = 1; 271 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 272 | INFOPLIST_FILE = Sources/Info.plist; 273 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 274 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 275 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 276 | MARKETING_VERSION = 1.3.0; 277 | PRODUCT_BUNDLE_IDENTIFIER = com.freshOS.Router; 278 | PRODUCT_NAME = "$(TARGET_NAME)"; 279 | SKIP_INSTALL = YES; 280 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 281 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 282 | SWIFT_VERSION = 4.2; 283 | }; 284 | name = Debug; 285 | }; 286 | 997CC25F1E64079100250EB1 /* Release */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | CLANG_ENABLE_MODULES = YES; 290 | CODE_SIGN_IDENTITY = ""; 291 | DEFINES_MODULE = YES; 292 | DYLIB_COMPATIBILITY_VERSION = 1; 293 | DYLIB_CURRENT_VERSION = 1; 294 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 295 | INFOPLIST_FILE = Sources/Info.plist; 296 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 297 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 298 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 299 | MARKETING_VERSION = 1.3.0; 300 | PRODUCT_BUNDLE_IDENTIFIER = com.freshOS.Router; 301 | PRODUCT_NAME = "$(TARGET_NAME)"; 302 | SKIP_INSTALL = YES; 303 | SWIFT_SWIFT3_OBJC_INFERENCE = Off; 304 | SWIFT_VERSION = 4.2; 305 | }; 306 | name = Release; 307 | }; 308 | /* End XCBuildConfiguration section */ 309 | 310 | /* Begin XCConfigurationList section */ 311 | 997CC24F1E64079100250EB1 /* Build configuration list for PBXProject "Router" */ = { 312 | isa = XCConfigurationList; 313 | buildConfigurations = ( 314 | 997CC25B1E64079100250EB1 /* Debug */, 315 | 997CC25C1E64079100250EB1 /* Release */, 316 | ); 317 | defaultConfigurationIsVisible = 0; 318 | defaultConfigurationName = Release; 319 | }; 320 | 997CC25D1E64079100250EB1 /* Build configuration list for PBXNativeTarget "Router" */ = { 321 | isa = XCConfigurationList; 322 | buildConfigurations = ( 323 | 997CC25E1E64079100250EB1 /* Debug */, 324 | 997CC25F1E64079100250EB1 /* Release */, 325 | ); 326 | defaultConfigurationIsVisible = 0; 327 | defaultConfigurationName = Release; 328 | }; 329 | /* End XCConfigurationList section */ 330 | }; 331 | rootObject = 997CC24C1E64079100250EB1 /* Project object */; 332 | } 333 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Router](https://raw.githubusercontent.com/freshOS/Router/master/banner.png) 2 | 3 | ⚠️ Deprecated and no longer supported. Use at your own risks. 4 | This has been used extensively and after weighing up pros and cons, we now favour the use of native Flow Controllers or Coordinators as explained [here](https://www.hackingwithswift.com/articles/71/how-to-use-the-coordinator-pattern-in-ios-apps). 5 | The native route (pun intended) should always be favoured and we believe less dependencies is something we should always strive for. 6 | 7 | # Router 8 | [![Language: Swift](https://img.shields.io/badge/language-swift-f48041.svg?style=flat)](https://developer.apple.com/swift) 9 | ![Platform: iOS 8+](https://img.shields.io/badge/platform-iOS%208%2B-blue.svg?style=flat) 10 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 11 | [![Build Status](https://app.bitrise.io/app/11b4cd282c1d70b3/status.svg?token=TFKzkSx6pehcZOj5ouWrFg&branch=master)](https://app.bitrise.io/app/11b4cd282c1d70b3) 12 | [![License: MIT](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/freshOS/then/blob/master/LICENSE) 13 | ![Release version](https://img.shields.io/github/release/freshos/router.svg) 14 | 15 | [Reason](#why) - [Get Started](#get-started) - [Installation](#installation) 16 | 17 | ![Router](https://raw.githubusercontent.com/freshOS/Router/master/Infographics.png) 18 | 19 | ## Why 20 | Because **classic App Navigation** introduces **tight coupling** between ViewControllers. 21 | Complex Apps navigation can look like a **gigantic spider web**. 22 | 23 | Besides the fact that **Navigation responsibility is split** among ViewControllers, modifying a ViewController can cascade recompiles and produce **slow compile times.** 24 | 25 | ## How 26 | By using a Navigation `enum` to navigate we decouple ViewControllers between them. Aka they don't know each other anymore. So modifying `VCA` won't trigger `VCB` to recompile anymore \o/ 27 | 28 | ```swift 29 | // navigationController?.pushViewController(AboutViewController(), animated: true) 30 | navigate(.about) 31 | ``` 32 | 33 | Navigation code is now encapsulated in a `AppNavigation` object. 34 | 35 | ## Benefits 36 | - [x] Decouples ViewControllers 37 | - [x] Makes navigation Testable 38 | - [x] Faster compile times 39 | 40 | ## Get started 41 | 42 | ### 1 - Declare your Navigation enum 43 | ```swift 44 | enum MyNavigation: Navigation { 45 | case about 46 | case profile(Person) 47 | } 48 | ``` 49 | Swift enum can take params! 50 | Awesome for us because that's how we will pass data between ViewControllers :) 51 | 52 | ### 2 - Declare your App Navigation 53 | 54 | ```swift 55 | struct MyAppNavigation: AppNavigation { 56 | 57 | func viewcontrollerForNavigation(navigation: Navigation) -> UIViewController { 58 | if let navigation = navigation as? MyNavigation { 59 | switch navigation { 60 | case .about: 61 | return AboutViewController() 62 | case .profile(let p): 63 | return ProfileViewController(person: p) 64 | } 65 | } 66 | return UIViewController() 67 | } 68 | 69 | func navigate(_ navigation: Navigation, from: UIViewController, to: UIViewController) { 70 | from.navigationController?.pushViewController(to, animated: true) 71 | } 72 | } 73 | ``` 74 | 75 | A cool thing is that the swift compiler will produce an error if a navigation 76 | case is not handled ! Which would'nt be the case with string URLs by the way ;) 77 | 78 | 79 | ### 3 - Register your navigation on App Launch 80 | 81 | In `AppDelegate.swift`, before everything : 82 | ```swift 83 | Router.default.setupAppNavigation(appNavigation: MyAppNavigation()) 84 | ``` 85 | 86 | ### 4 - Replace navigations in your View Controllers 87 | 88 | You can now call nagivations from you view controllers : 89 | 90 | ```swift 91 | navigate(MyNavigation.about) 92 | ``` 93 | 94 | Bridge `Navigation` with your own enum type, here `MyNavigation` so that we don't have to type our own. 95 | ```swift 96 | extension UIViewController { 97 | 98 | func navigate(_ navigation: MyNavigation) { 99 | navigate(navigation as Navigation) 100 | } 101 | } 102 | ``` 103 | You can now write : 104 | ```swift 105 | navigate(.about) 106 | ``` 107 | 108 | 109 | ### Bonus - Tracking 110 | Another cool thing about decoupling navigation is that you can now extract traking code from view Controllers as well. You can be notified by the router whenever a navigation happened. 111 | 112 | ```swift 113 | Router.default.didNavigate { navigation in 114 | // Plug Analytics for instance 115 | GoogleAnalitcs.trackPage(navigation) 116 | } 117 | 118 | ``` 119 | 120 | ## Shave off compilation times 121 | 122 | There is a nasty bug in Swift 3 compiler where the compiler rebuilds files even though they haven't changed. 123 | This is documented here : https://forums.developer.apple.com/thread/62737?tstart=0 124 | 125 | Due to this bug, the compilation can go like this : 126 | 127 | Change `ViewController1` -> `Build` 128 | -> Compiles `ViewController1`, referenced in `MyAppNavigation` so 129 | `MyAppNavigation` gets recompiled. `MyAppNavigation` is referenced in `AppDelegate` which gets recompiled which references ... 130 | `App` -> `ViewController2` -> `ViewController3` -> `ViewControllerX` you get the point. 131 | Before you know it the entire App gets rebuilt :/ 132 | 133 | A good this is that most of the app coupling usually comes from navigation. which Router decouples. 134 | 135 | We can stop this nonsense until this gets fixed in a future release of Xcode. 136 | Router can help us manage this issue by injecting our AppNavigation implementation at runtime. 137 | 138 | 139 | In your `AppDelegate.swift` 140 | 141 | ```swift 142 | // Inject your AppNavigation at runtime to avoid recompilation of AppDelegate :) 143 | Router.default.setupAppNavigation(appNavigation: appNavigationFromString("YourAppName.MyAppNavigation")) 144 | ``` 145 | 146 | And make sure your `AppNavigation` implementation is now a `class` that is `RuntimeInjectable` 147 | ```swift 148 | class MyAppNavigation: RuntimeInjectable, AppNavigation { 149 | ``` 150 | 151 | ## Installation 152 | 153 | #### Carthage 154 | ``` 155 | github "freshOS/Router" 156 | ``` 157 | #### Manually 158 | Simply Copy and Paste `Router.swift` files in your Xcode Project :) 159 | 160 | #### As A Framework 161 | Grab this repository and build the Framework target on the example project. Then Link against this framework. 162 | 163 | 164 | ### Backers 165 | Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :) 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | ### Sponsors 199 | Become a sponsor and get your logo on our README on Github with a link to your site :) 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 | --------------------------------------------------------------------------------