├── .gitignore ├── ControllerFactory.podspec ├── ControllerFactory.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ └── ControllerFactory.xcscheme ├── ControllerFactory ├── Constants.swift ├── ControllerFactory.h ├── ControllerFactory.swift ├── ControllerFactoryTableViewController.swift ├── ControllerListTableViewController.swift ├── ControllerName.swift ├── Info.plist ├── Storyboard.storyboard └── Utils.swift ├── ControllerFactoryDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── ControllerFactoryDemo ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-57x57@1x.png │ │ ├── Icon-App-57x57@2x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-72x72@1x.png │ │ ├── Icon-App-72x72@2x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ ├── Icon-App-83.5x83.5@2x.png │ │ ├── Icon-Small-50x50@1x.png │ │ ├── Icon-Small-50x50@2x.png │ │ └── ItunesArtwork@2x.png │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── ControllerFactoryDemo-Bridging-Header.h ├── Controllers │ ├── AboutViewController.swift │ ├── AboutViewController.xib │ ├── Base │ │ ├── BaseViewController.h │ │ └── BaseViewController.m │ ├── DashboardViewController.h │ ├── DashboardViewController.m │ ├── DashboardViewController.xib │ ├── LoginViewController.swift │ ├── LoginViewController.xib │ ├── ProductsViewController.h │ ├── ProductsViewController.m │ └── ProductsViewController.xib ├── Info.plist └── MainViewController.swift ├── LICENSE ├── README.md └── readme-images ├── after.png ├── before.png ├── controllerFactory.png ├── controllerList.png └── icon.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | /Docs/ 20 | .DS_Store 21 | 22 | # fastlane 23 | # 24 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 25 | # screenshots whenever they are needed. 26 | # For more information about the recommended setup visit: 27 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 28 | 29 | fastlane/report.xml 30 | fastlane/Preview.html 31 | fastlane/screenshots 32 | fastlane/test_output 33 | fastlane/artefacts 34 | UserInterfaceState.xcuserstate 35 | -------------------------------------------------------------------------------- /ControllerFactory.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint ControllerFactory.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 = 'ControllerFactory' 11 | s.version = '1.0.1' 12 | s.summary = 'This framework generates a debug view, which allows the instantiation of any view controller in the app.' 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 | This frameworks provides you with a debug view to pick any view controller within your app or any other bundle. 22 | You can then instantiate this controller, with or without use cases. 23 | DESC 24 | 25 | s.homepage = 'https://github.com/worldline/ControllerFactory' 26 | s.license = { :type => 'MIT', :file => 'LICENSE' } 27 | s.author = { 'Benoit Caron' => 'benoit.caron@wordline.com' } 28 | s.source = { :git => 'https://github.com/worldline/ControllerFactory.git', :tag => s.version.to_s } 29 | 30 | s.ios.deployment_target = '8.0' 31 | 32 | s.swift_version = '4.1' 33 | 34 | s.source_files = 'ControllerFactory/**/*.{h,swift}' 35 | 36 | s.resources = ['ControllerFactory/**/*.{storyboard,plist}'] 37 | 38 | s.frameworks = 'UIKit' 39 | 40 | end -------------------------------------------------------------------------------- /ControllerFactory.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C783D3E02134143A000AC835 /* ControllerFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = C783D3DE2134143A000AC835 /* ControllerFactory.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | C783D3ED21341476000AC835 /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C783D3E621341475000AC835 /* Storyboard.storyboard */; }; 12 | C783D3EE21341476000AC835 /* ControllerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D3E721341475000AC835 /* ControllerFactory.swift */; }; 13 | C783D3EF21341476000AC835 /* ControllerListTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D3E821341475000AC835 /* ControllerListTableViewController.swift */; }; 14 | C783D3F021341476000AC835 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D3E921341475000AC835 /* Constants.swift */; }; 15 | C783D3F121341476000AC835 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D3EA21341475000AC835 /* Utils.swift */; }; 16 | C783D3F221341476000AC835 /* ControllerFactoryTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D3EB21341476000AC835 /* ControllerFactoryTableViewController.swift */; }; 17 | C783D3F321341476000AC835 /* ControllerName.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D3EC21341476000AC835 /* ControllerName.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | C783D3DB2134143A000AC835 /* ControllerFactory.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ControllerFactory.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | C783D3DE2134143A000AC835 /* ControllerFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ControllerFactory.h; sourceTree = ""; }; 23 | C783D3DF2134143A000AC835 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | C783D3E621341475000AC835 /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard.storyboard; sourceTree = ""; }; 25 | C783D3E721341475000AC835 /* ControllerFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControllerFactory.swift; sourceTree = ""; }; 26 | C783D3E821341475000AC835 /* ControllerListTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControllerListTableViewController.swift; sourceTree = ""; }; 27 | C783D3E921341475000AC835 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 28 | C783D3EA21341475000AC835 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; 29 | C783D3EB21341476000AC835 /* ControllerFactoryTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControllerFactoryTableViewController.swift; sourceTree = ""; }; 30 | C783D3EC21341476000AC835 /* ControllerName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControllerName.swift; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | C783D3D72134143A000AC835 /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | C783D3D12134143A000AC835 = { 45 | isa = PBXGroup; 46 | children = ( 47 | C783D3DD2134143A000AC835 /* ControllerFactory */, 48 | C783D3DC2134143A000AC835 /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | C783D3DC2134143A000AC835 /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | C783D3DB2134143A000AC835 /* ControllerFactory.framework */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | C783D3DD2134143A000AC835 /* ControllerFactory */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | C783D3E921341475000AC835 /* Constants.swift */, 64 | C783D3E721341475000AC835 /* ControllerFactory.swift */, 65 | C783D3EB21341476000AC835 /* ControllerFactoryTableViewController.swift */, 66 | C783D3E821341475000AC835 /* ControllerListTableViewController.swift */, 67 | C783D3EC21341476000AC835 /* ControllerName.swift */, 68 | C783D3E621341475000AC835 /* Storyboard.storyboard */, 69 | C783D3EA21341475000AC835 /* Utils.swift */, 70 | C783D3DE2134143A000AC835 /* ControllerFactory.h */, 71 | C783D3DF2134143A000AC835 /* Info.plist */, 72 | ); 73 | path = ControllerFactory; 74 | sourceTree = ""; 75 | }; 76 | /* End PBXGroup section */ 77 | 78 | /* Begin PBXHeadersBuildPhase section */ 79 | C783D3D82134143A000AC835 /* Headers */ = { 80 | isa = PBXHeadersBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | C783D3E02134143A000AC835 /* ControllerFactory.h in Headers */, 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | /* End PBXHeadersBuildPhase section */ 88 | 89 | /* Begin PBXNativeTarget section */ 90 | C783D3DA2134143A000AC835 /* ControllerFactory */ = { 91 | isa = PBXNativeTarget; 92 | buildConfigurationList = C783D3E32134143A000AC835 /* Build configuration list for PBXNativeTarget "ControllerFactory" */; 93 | buildPhases = ( 94 | C783D3D62134143A000AC835 /* Sources */, 95 | C783D3D72134143A000AC835 /* Frameworks */, 96 | C783D3D82134143A000AC835 /* Headers */, 97 | C783D3D92134143A000AC835 /* Resources */, 98 | ); 99 | buildRules = ( 100 | ); 101 | dependencies = ( 102 | ); 103 | name = ControllerFactory; 104 | productName = ControllerFactory; 105 | productReference = C783D3DB2134143A000AC835 /* ControllerFactory.framework */; 106 | productType = "com.apple.product-type.framework"; 107 | }; 108 | /* End PBXNativeTarget section */ 109 | 110 | /* Begin PBXProject section */ 111 | C783D3D22134143A000AC835 /* Project object */ = { 112 | isa = PBXProject; 113 | attributes = { 114 | LastUpgradeCheck = 0940; 115 | ORGANIZATIONNAME = Worldline; 116 | TargetAttributes = { 117 | C783D3DA2134143A000AC835 = { 118 | CreatedOnToolsVersion = 9.4.1; 119 | LastSwiftMigration = 0940; 120 | }; 121 | }; 122 | }; 123 | buildConfigurationList = C783D3D52134143A000AC835 /* Build configuration list for PBXProject "ControllerFactory" */; 124 | compatibilityVersion = "Xcode 9.3"; 125 | developmentRegion = en; 126 | hasScannedForEncodings = 0; 127 | knownRegions = ( 128 | en, 129 | ); 130 | mainGroup = C783D3D12134143A000AC835; 131 | productRefGroup = C783D3DC2134143A000AC835 /* Products */; 132 | projectDirPath = ""; 133 | projectRoot = ""; 134 | targets = ( 135 | C783D3DA2134143A000AC835 /* ControllerFactory */, 136 | ); 137 | }; 138 | /* End PBXProject section */ 139 | 140 | /* Begin PBXResourcesBuildPhase section */ 141 | C783D3D92134143A000AC835 /* Resources */ = { 142 | isa = PBXResourcesBuildPhase; 143 | buildActionMask = 2147483647; 144 | files = ( 145 | C783D3ED21341476000AC835 /* Storyboard.storyboard in Resources */, 146 | ); 147 | runOnlyForDeploymentPostprocessing = 0; 148 | }; 149 | /* End PBXResourcesBuildPhase section */ 150 | 151 | /* Begin PBXSourcesBuildPhase section */ 152 | C783D3D62134143A000AC835 /* Sources */ = { 153 | isa = PBXSourcesBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | C783D3F321341476000AC835 /* ControllerName.swift in Sources */, 157 | C783D3EE21341476000AC835 /* ControllerFactory.swift in Sources */, 158 | C783D3EF21341476000AC835 /* ControllerListTableViewController.swift in Sources */, 159 | C783D3F221341476000AC835 /* ControllerFactoryTableViewController.swift in Sources */, 160 | C783D3F021341476000AC835 /* Constants.swift in Sources */, 161 | C783D3F121341476000AC835 /* Utils.swift in Sources */, 162 | ); 163 | runOnlyForDeploymentPostprocessing = 0; 164 | }; 165 | /* End PBXSourcesBuildPhase section */ 166 | 167 | /* Begin XCBuildConfiguration section */ 168 | C783D3E12134143A000AC835 /* Debug */ = { 169 | isa = XCBuildConfiguration; 170 | buildSettings = { 171 | ALWAYS_SEARCH_USER_PATHS = NO; 172 | CLANG_ANALYZER_NONNULL = YES; 173 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 174 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 175 | CLANG_CXX_LIBRARY = "libc++"; 176 | CLANG_ENABLE_MODULES = YES; 177 | CLANG_ENABLE_OBJC_ARC = YES; 178 | CLANG_ENABLE_OBJC_WEAK = YES; 179 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 180 | CLANG_WARN_BOOL_CONVERSION = YES; 181 | CLANG_WARN_COMMA = YES; 182 | CLANG_WARN_CONSTANT_CONVERSION = YES; 183 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 184 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 185 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 186 | CLANG_WARN_EMPTY_BODY = YES; 187 | CLANG_WARN_ENUM_CONVERSION = YES; 188 | CLANG_WARN_INFINITE_RECURSION = YES; 189 | CLANG_WARN_INT_CONVERSION = YES; 190 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 191 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 192 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 193 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 194 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 195 | CLANG_WARN_STRICT_PROTOTYPES = YES; 196 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 197 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 198 | CLANG_WARN_UNREACHABLE_CODE = YES; 199 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 200 | CODE_SIGN_IDENTITY = "iPhone Developer"; 201 | COPY_PHASE_STRIP = NO; 202 | CURRENT_PROJECT_VERSION = 1; 203 | DEBUG_INFORMATION_FORMAT = dwarf; 204 | ENABLE_STRICT_OBJC_MSGSEND = YES; 205 | ENABLE_TESTABILITY = YES; 206 | GCC_C_LANGUAGE_STANDARD = gnu11; 207 | GCC_DYNAMIC_NO_PIC = NO; 208 | GCC_NO_COMMON_BLOCKS = YES; 209 | GCC_OPTIMIZATION_LEVEL = 0; 210 | GCC_PREPROCESSOR_DEFINITIONS = ( 211 | "DEBUG=1", 212 | "$(inherited)", 213 | ); 214 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 215 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 216 | GCC_WARN_UNDECLARED_SELECTOR = YES; 217 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 218 | GCC_WARN_UNUSED_FUNCTION = YES; 219 | GCC_WARN_UNUSED_VARIABLE = YES; 220 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 221 | MTL_ENABLE_DEBUG_INFO = YES; 222 | ONLY_ACTIVE_ARCH = YES; 223 | SDKROOT = iphoneos; 224 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 225 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 226 | VERSIONING_SYSTEM = "apple-generic"; 227 | VERSION_INFO_PREFIX = ""; 228 | }; 229 | name = Debug; 230 | }; 231 | C783D3E22134143A000AC835 /* Release */ = { 232 | isa = XCBuildConfiguration; 233 | buildSettings = { 234 | ALWAYS_SEARCH_USER_PATHS = NO; 235 | CLANG_ANALYZER_NONNULL = YES; 236 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 237 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 238 | CLANG_CXX_LIBRARY = "libc++"; 239 | CLANG_ENABLE_MODULES = YES; 240 | CLANG_ENABLE_OBJC_ARC = YES; 241 | CLANG_ENABLE_OBJC_WEAK = YES; 242 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 243 | CLANG_WARN_BOOL_CONVERSION = YES; 244 | CLANG_WARN_COMMA = YES; 245 | CLANG_WARN_CONSTANT_CONVERSION = YES; 246 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 247 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 248 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 261 | CLANG_WARN_UNREACHABLE_CODE = YES; 262 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 263 | CODE_SIGN_IDENTITY = "iPhone Developer"; 264 | COPY_PHASE_STRIP = NO; 265 | CURRENT_PROJECT_VERSION = 1; 266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 267 | ENABLE_NS_ASSERTIONS = NO; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu11; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 278 | MTL_ENABLE_DEBUG_INFO = NO; 279 | SDKROOT = iphoneos; 280 | SWIFT_COMPILATION_MODE = wholemodule; 281 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 282 | VALIDATE_PRODUCT = YES; 283 | VERSIONING_SYSTEM = "apple-generic"; 284 | VERSION_INFO_PREFIX = ""; 285 | }; 286 | name = Release; 287 | }; 288 | C783D3E42134143A000AC835 /* Debug */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | CLANG_ENABLE_MODULES = YES; 292 | CODE_SIGN_IDENTITY = ""; 293 | CODE_SIGN_STYLE = Automatic; 294 | DEFINES_MODULE = YES; 295 | DYLIB_COMPATIBILITY_VERSION = 1; 296 | DYLIB_CURRENT_VERSION = 1; 297 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 298 | INFOPLIST_FILE = "$(SRCROOT)/ControllerFactory/Info.plist"; 299 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 300 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 301 | LD_RUNPATH_SEARCH_PATHS = ( 302 | "$(inherited)", 303 | "@executable_path/Frameworks", 304 | "@loader_path/Frameworks", 305 | ); 306 | PRODUCT_BUNDLE_IDENTIFIER = com.worldline.ControllerFactory; 307 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 308 | SKIP_INSTALL = YES; 309 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 310 | SWIFT_VERSION = 4.0; 311 | TARGETED_DEVICE_FAMILY = "1,2"; 312 | }; 313 | name = Debug; 314 | }; 315 | C783D3E52134143A000AC835 /* Release */ = { 316 | isa = XCBuildConfiguration; 317 | buildSettings = { 318 | CLANG_ENABLE_MODULES = YES; 319 | CODE_SIGN_IDENTITY = ""; 320 | CODE_SIGN_STYLE = Automatic; 321 | DEFINES_MODULE = YES; 322 | DYLIB_COMPATIBILITY_VERSION = 1; 323 | DYLIB_CURRENT_VERSION = 1; 324 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 325 | INFOPLIST_FILE = "$(SRCROOT)/ControllerFactory/Info.plist"; 326 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 327 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 328 | LD_RUNPATH_SEARCH_PATHS = ( 329 | "$(inherited)", 330 | "@executable_path/Frameworks", 331 | "@loader_path/Frameworks", 332 | ); 333 | PRODUCT_BUNDLE_IDENTIFIER = com.worldline.ControllerFactory; 334 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 335 | SKIP_INSTALL = YES; 336 | SWIFT_VERSION = 4.0; 337 | TARGETED_DEVICE_FAMILY = "1,2"; 338 | }; 339 | name = Release; 340 | }; 341 | /* End XCBuildConfiguration section */ 342 | 343 | /* Begin XCConfigurationList section */ 344 | C783D3D52134143A000AC835 /* Build configuration list for PBXProject "ControllerFactory" */ = { 345 | isa = XCConfigurationList; 346 | buildConfigurations = ( 347 | C783D3E12134143A000AC835 /* Debug */, 348 | C783D3E22134143A000AC835 /* Release */, 349 | ); 350 | defaultConfigurationIsVisible = 0; 351 | defaultConfigurationName = Release; 352 | }; 353 | C783D3E32134143A000AC835 /* Build configuration list for PBXNativeTarget "ControllerFactory" */ = { 354 | isa = XCConfigurationList; 355 | buildConfigurations = ( 356 | C783D3E42134143A000AC835 /* Debug */, 357 | C783D3E52134143A000AC835 /* Release */, 358 | ); 359 | defaultConfigurationIsVisible = 0; 360 | defaultConfigurationName = Release; 361 | }; 362 | /* End XCConfigurationList section */ 363 | }; 364 | rootObject = C783D3D22134143A000AC835 /* Project object */; 365 | } 366 | -------------------------------------------------------------------------------- /ControllerFactory.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ControllerFactory.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ControllerFactory.xcodeproj/xcshareddata/xcschemes/ControllerFactory.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 | -------------------------------------------------------------------------------- /ControllerFactory/Constants.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.swift 3 | // ControllerFactory 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | struct Constants { 12 | 13 | static let useCase = "controllerFactoryUseCase" 14 | static let controller = "controllerFactoryController" 15 | } 16 | -------------------------------------------------------------------------------- /ControllerFactory/ControllerFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // ControllerFactory.h 3 | // ControllerFactory 4 | // 5 | // Created by Vincent Pradeilles-24 on 27/08/2018. 6 | // Copyright © 2018 Worldline. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for ControllerFactory. 12 | FOUNDATION_EXPORT double ControllerFactoryVersionNumber; 13 | 14 | //! Project version string for ControllerFactory. 15 | FOUNDATION_EXPORT const unsigned char ControllerFactoryVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /ControllerFactory/ControllerFactory.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ControllerFactory.swift 3 | // ControllerFactory 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public protocol ControllerFactoryInstantiable { 12 | static func initForControllerFactory() -> UIViewController 13 | } 14 | 15 | @objc public protocol ControllerFactoryUseCaseInstantiable { 16 | static func getUseCases() -> [String] 17 | static func initForControllerFactory(useCase: String) -> UIViewController 18 | } 19 | 20 | @objc public protocol ControllerFactoryCompliant { 21 | func prepareForControllerFactory() 22 | } 23 | 24 | @objc public protocol ControllerFactoryUseCaseCompliant { 25 | static func getUseCases() -> [String] 26 | func prepareForControllerFactory(useCase: String) 27 | } 28 | 29 | @objcMembers public class ControllerFactory: NSObject { 30 | 31 | private static let defaultBundle = Bundle.main 32 | private static let defaultExcludedControllers = [String]() 33 | 34 | // We must have all methods explicitely declared instead of using default values for objective c exposure 35 | 36 | public static func instantiate() -> ControllerFactoryTableViewController { 37 | 38 | return ControllerFactory.instantiate(bundle: ControllerFactory.defaultBundle, excludedViewControllers: [String]()) 39 | } 40 | 41 | public static func instantiate(bundle: Bundle) -> ControllerFactoryTableViewController { 42 | 43 | return ControllerFactory.instantiate(bundle: bundle, excludedViewControllers: ControllerFactory.defaultExcludedControllers) 44 | } 45 | 46 | public static func instantiate(excludedViewControllers: [String]) -> ControllerFactoryTableViewController { 47 | 48 | return ControllerFactory.instantiate(bundle: ControllerFactory.defaultBundle, excludedViewControllers: excludedViewControllers) 49 | } 50 | 51 | public static func instantiate(bundle: Bundle, excludedViewControllers: [String]) -> ControllerFactoryTableViewController { 52 | let controller = UIStoryboard(name: "Storyboard", bundle: Bundle(for: ControllerFactory.self)).instantiateViewController(withIdentifier: "ControllerFactoryTableViewController") as! ControllerFactoryTableViewController 53 | 54 | controller.bundle = bundle 55 | controller.excludedControllers = excludedViewControllers 56 | 57 | return controller 58 | } 59 | 60 | // Use this method to select help you choose the controllers to exclude 61 | public static func printControllers() { 62 | print(ControllerFactory.defaultBundle.retrieveAllViewControllers() 63 | .map { $0.className } 64 | .joined(separator:"\n")) 65 | } 66 | 67 | // Use this method to select help you choose the controllers to exclude 68 | public static func printControllers(bundle: Bundle) { 69 | print(bundle.retrieveAllViewControllers() 70 | .map { $0.className } 71 | .joined(separator:"\n")) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /ControllerFactory/ControllerFactoryTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ControllerFactoryTableViewController.swift 3 | // ControllerFactory 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | private enum Sections: String { 12 | 13 | case controller = "Controller" 14 | case useCases = "Use cases" 15 | case action = "Action" 16 | } 17 | 18 | public class ControllerFactoryTableViewController: UITableViewController { 19 | 20 | var bundle = Bundle.main 21 | var excludedControllers = [String]() 22 | 23 | fileprivate var sections: [Sections] { 24 | get { 25 | if useCases.isEmpty { 26 | return [.controller, .action] 27 | } 28 | return [.controller, .useCases, .action] 29 | } 30 | } 31 | 32 | fileprivate var label = "" 33 | fileprivate var useCase: String? = nil 34 | fileprivate var useCases = [String]() 35 | 36 | fileprivate var viewController: UIViewController? = nil 37 | fileprivate var controllerName: ControllerName? = nil 38 | 39 | fileprivate var controllerClass: UIViewController.Type? { 40 | get { 41 | guard let controllerName = controllerName else { return nil } 42 | return classFromControllerName(controllerName) as? UIViewController.Type 43 | } 44 | } 45 | 46 | public final override func viewDidLoad() { 47 | super.viewDidLoad() 48 | 49 | title = "Controller factory" 50 | } 51 | 52 | public final override func viewWillAppear(_ animated: Bool) { 53 | 54 | reset() 55 | configureData() 56 | tableView.reloadData() 57 | } 58 | 59 | private func reset() { 60 | label = "" 61 | useCase = nil 62 | useCases = [String]() 63 | viewController = nil 64 | controllerName = ControllerName.loadFromUserDefaults() 65 | } 66 | 67 | private func configureData() { 68 | 69 | guard let controllerName = controllerName else { return } 70 | 71 | if let useCases = (controllerClass.self as? ControllerFactoryUseCaseInstantiable.Type)?.getUseCases() { 72 | self.useCases = useCases 73 | } 74 | else if let useCases = (controllerClass.self as? ControllerFactoryUseCaseCompliant.Type)?.getUseCases() { 75 | self.useCases = useCases 76 | } 77 | else { 78 | UserDefaults.standard.set(nil, forKey: Constants.useCase) 79 | } 80 | 81 | label = controllerName.displayValue 82 | useCase = UserDefaults.standard.string(forKey: Constants.useCase) 83 | } 84 | 85 | fileprivate func getController() -> UIViewController? { 86 | 87 | if let useCase = useCase, 88 | let controllerClass = controllerClass as? ControllerFactoryUseCaseInstantiable.Type { 89 | viewController = controllerClass.initForControllerFactory(useCase: useCase) 90 | } 91 | else if let controllerClass = controllerClass as? ControllerFactoryInstantiable.Type { 92 | viewController = controllerClass.initForControllerFactory() 93 | } 94 | else { 95 | viewController = controllerClass?.init() 96 | } 97 | 98 | if let useCase = useCase { 99 | (viewController as? ControllerFactoryUseCaseCompliant)?.prepareForControllerFactory(useCase: useCase) 100 | } 101 | else { 102 | (viewController as? ControllerFactoryCompliant)?.prepareForControllerFactory() 103 | } 104 | 105 | return viewController 106 | } 107 | 108 | fileprivate func pushViewController() { 109 | 110 | guard let controller = getController() else { return } 111 | navigationController?.pushViewController(controller, animated: true) 112 | } 113 | 114 | fileprivate func presentViewController() { 115 | 116 | guard let controller = getController() else { return } 117 | present(controller, animated: true, completion: nil) 118 | } 119 | 120 | fileprivate func presentDismissableViewController() { 121 | 122 | guard let controller = getController() else { return } 123 | 124 | let navigationController = UINavigationController(rootViewController: controller) 125 | controller.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Dismiss", style: .done, target: controller, action: #selector(dismissModalAnimated)) 126 | self.present(navigationController, animated: true, completion: nil) 127 | } 128 | 129 | public final override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 130 | 131 | if let controller = segue.destination as? ControllerListTableViewController { 132 | controller.bundle = bundle 133 | controller.excludedControllers = excludedControllers 134 | } 135 | } 136 | } 137 | 138 | //MARK: UITableViewDataSource 139 | 140 | extension ControllerFactoryTableViewController { 141 | 142 | public final override func numberOfSections(in tableView: UITableView) -> Int { 143 | 144 | return sections.count 145 | } 146 | 147 | public final override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 148 | 149 | return sections[section].rawValue 150 | } 151 | 152 | public final override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 153 | 154 | switch sections[section] { 155 | case .controller: 156 | return 1 157 | case .useCases: 158 | return useCases.count 159 | case .action: 160 | return 3 161 | } 162 | } 163 | 164 | public final override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 165 | 166 | let cell = tableView.dequeueReusableCell(withIdentifier: "BasicCell", for: indexPath) 167 | 168 | cell.textLabel?.textAlignment = .left 169 | cell.accessoryType = .none 170 | 171 | switch sections[indexPath.section] { 172 | case .controller: 173 | cell.textLabel?.text = label 174 | cell.accessoryType = .disclosureIndicator 175 | case .useCases: 176 | let useCase = useCases[indexPath.row] 177 | cell.textLabel?.text = useCase 178 | if useCase == self.useCase { 179 | cell.accessoryType = .checkmark 180 | } 181 | case .action: 182 | switch indexPath.row { 183 | case 0: 184 | cell.textLabel?.text = "Push view controller" 185 | case 1: 186 | cell.textLabel?.text = "Present view controller" 187 | case 2: 188 | cell.textLabel?.text = "Present dismissable view controller" 189 | default: 190 | break 191 | } 192 | cell.textLabel?.textAlignment = .center 193 | } 194 | 195 | return cell 196 | } 197 | } 198 | 199 | //MARK: UITableViewDelegate 200 | 201 | extension ControllerFactoryTableViewController { 202 | 203 | public final override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 204 | 205 | tableView.deselectRow(at: indexPath, animated: true) 206 | 207 | switch sections[indexPath.section] { 208 | case .controller: 209 | UserDefaults.standard.removeObject(forKey: Constants.useCase) 210 | performSegue(withIdentifier: "ControllerListSegue", sender: self) 211 | case .useCases: 212 | useCase = useCases[indexPath.row] 213 | UserDefaults.standard.set(useCase, forKey: Constants.useCase) 214 | for i in 0.. [ControllerName] { 75 | 76 | // Demo controllers 77 | // return [ 78 | // ControllerName(className: "AboutViewController", displayValue: "AboutViewController"), 79 | // ControllerName(className: "AccountViewController", displayValue: "AccountViewController"), 80 | // ControllerName(className: "SettingsViewController", displayValue: "SettingsViewController"), 81 | // ControllerName(className: "AuthenticationViewController", displayValue: "AuthenticationViewController"), 82 | // ControllerName(className: "EnrolementStep1ViewController", displayValue: "EnrolementStep1ViewController"), 83 | // ControllerName(className: "EnrolementStep2ViewController", displayValue: "EnrolementStep2ViewController"), 84 | // ControllerName(className: "EnrolementStep3ViewController", displayValue: "EnrolementStep3ViewController"), 85 | // ControllerName(className: "MessageViewController", displayValue: "MessageViewController"), 86 | // ControllerName(className: "DocumentsViewController", displayValue: "DocumentsViewController"), 87 | // ControllerName(className: "SplashScreenViewController", displayValue: "SplashScreenViewController"), 88 | // ControllerName(className: "BaseViewController", displayValue: "BaseViewController"), 89 | // ControllerName(className: "HomeViewController", displayValue: "HomeViewController"), 90 | // ControllerName(className: "MenuViewController", displayValue: "MenuViewController"), 91 | // ControllerName(className: "DebugViewController", displayValue: "DebugViewController") 92 | // ] 93 | 94 | return bundle.retrieveAllViewControllers() 95 | .sorted(by: { $0.displayValue < $1.displayValue }) 96 | .filter { !excludedControllers.contains($0.className) } 97 | } 98 | } 99 | 100 | //MARK: UITableViewDataSource 101 | 102 | extension ControllerListTableViewController { 103 | 104 | override func numberOfSections(in tableView: UITableView) -> Int { 105 | return currentDataSourceSectionTitles.count 106 | } 107 | 108 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 109 | return currentDataSource[currentDataSourceSectionTitles[section]]?.count ?? 0 110 | } 111 | 112 | override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 113 | return 35 114 | } 115 | 116 | override func sectionIndexTitles(for tableView: UITableView) -> [String]? { 117 | return indexTitles 118 | } 119 | 120 | override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 121 | return currentDataSourceSectionTitles[section] 122 | } 123 | 124 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 125 | 126 | let cell = tableView.dequeueReusableCell(withIdentifier: "BasicCell", for: indexPath) 127 | 128 | let controller = currentDataSource[currentDataSourceSectionTitles[indexPath.section]]?[indexPath.row] 129 | 130 | cell.textLabel?.text = controller?.displayValue 131 | cell.textLabel?.font = cell.textLabel?.font.withSize(14) 132 | 133 | if let savedController = savedController, 134 | controller == savedController { 135 | cell.accessoryType = .checkmark 136 | } 137 | else { 138 | cell.accessoryType = .none 139 | } 140 | 141 | return cell 142 | } 143 | } 144 | 145 | //MARK: UITableViewDelegate 146 | 147 | extension ControllerListTableViewController { 148 | 149 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 150 | 151 | let controller = currentDataSource[currentDataSourceSectionTitles[indexPath.section]]?[indexPath.row] 152 | controller?.saveToUserDefaults() 153 | 154 | UserDefaults.standard.set(0, forKey: Constants.useCase) 155 | 156 | searchController.isActive = false 157 | 158 | _ = navigationController?.popViewController(animated: true) 159 | } 160 | 161 | override func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int { 162 | 163 | // Because we can have more indexes than sections, touching an index which has no section counterpart would return 0, 164 | // thus scrolling the tableview to the top. 165 | // This implementation prevents such erratic jumps 166 | 167 | return indexTitles[0...index] 168 | .reversed() 169 | .compactMap { currentDataSourceSectionTitles.index(of: $0) } 170 | .first ?? 0 171 | } 172 | } 173 | 174 | //MARK: UISearchResultsUpdating 175 | 176 | extension ControllerListTableViewController: UISearchResultsUpdating { 177 | 178 | func updateSearchResults(for searchController: UISearchController) { 179 | 180 | var viewControllers = retrieveWantedViewControllers(in: bundle) 181 | 182 | filteredDataSource = [String: [ControllerName]]() 183 | 184 | if let searchString = searchController.searchBar.text, 185 | searchString != "" { 186 | viewControllers = viewControllers.filter { ($0.displayValue as NSString).range(of: searchString, options: .caseInsensitive).location != NSNotFound } 187 | } 188 | 189 | viewControllers.forEach { filteredDataSource[$0.displayValue[0]] = [ControllerName]() } 190 | viewControllers.forEach { filteredDataSource[$0.displayValue[0]]?.append($0) } 191 | 192 | tableView.reloadData() 193 | } 194 | } 195 | 196 | //MARK: UISearchBarDelegate 197 | extension ControllerListTableViewController: UISearchBarDelegate { 198 | 199 | func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { 200 | shouldShowSearchResults = true 201 | tableView.reloadData() 202 | } 203 | 204 | func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { 205 | shouldShowSearchResults = false 206 | tableView.reloadData() 207 | } 208 | 209 | func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { 210 | 211 | if !shouldShowSearchResults { 212 | shouldShowSearchResults = true 213 | tableView.reloadData() 214 | } 215 | 216 | searchController.searchBar.resignFirstResponder() 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /ControllerFactory/ControllerName.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ControllerName.swift 3 | // ControllerFactory 4 | // 5 | // Created by Benoit Caron on 09/05/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ControllerName: NSObject, NSCoding { 12 | 13 | let className: String 14 | let displayValue: String 15 | 16 | init(className: String, displayValue: String) { 17 | self.className = className 18 | self.displayValue = displayValue 19 | } 20 | 21 | override func isEqual(_ object: Any?) -> Bool { 22 | guard let object = object as? ControllerName else { return false } 23 | return self.className == object.className 24 | } 25 | 26 | required convenience init(coder aDecoder: NSCoder) { 27 | let className = aDecoder.decodeObject(forKey: "className") as! String 28 | let displayValue = aDecoder.decodeObject(forKey: "displayValue") as! String 29 | self.init(className: className, displayValue: displayValue) 30 | } 31 | 32 | func encode(with aCoder: NSCoder) { 33 | aCoder.encode(className, forKey: "className") 34 | aCoder.encode(displayValue, forKey: "displayValue") 35 | } 36 | 37 | private func serialized() -> Data? { 38 | return NSKeyedArchiver.archivedData(withRootObject: self) 39 | } 40 | 41 | private static func deserialize(data: Data) -> ControllerName? { 42 | return NSKeyedUnarchiver.unarchiveObject(with: data) as? ControllerName 43 | } 44 | 45 | func saveToUserDefaults() { 46 | UserDefaults.standard.set(self.serialized(), forKey: Constants.controller) 47 | } 48 | 49 | static func loadFromUserDefaults() -> ControllerName? { 50 | guard let data = UserDefaults.standard.data(forKey: Constants.controller) else { return nil } 51 | return ControllerName.deserialize(data: data) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ControllerFactory/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | 1.0.1 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ControllerFactory/Storyboard.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 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /ControllerFactory/Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Utils.swift 3 | // ControllerFactory 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIViewController { 12 | @objc func dismissModalAnimated() { 13 | self.dismiss(animated: true, completion: nil) 14 | } 15 | } 16 | 17 | extension String { 18 | 19 | subscript (i: Int) -> Character { 20 | return self[index(startIndex, offsetBy: i)] 21 | } 22 | 23 | subscript (i: Int) -> String { 24 | return String(self[i] as Character) 25 | } 26 | } 27 | 28 | extension Bundle { 29 | func retrieveAllViewControllers() -> [ControllerName] { 30 | 31 | guard let bundlePath = self.executablePath else { return [] } 32 | 33 | var size: UInt32 = 0 34 | 35 | var viewControllers = [ControllerName]() 36 | 37 | let classes = objc_copyClassNamesForImage(bundlePath, &size) 38 | 39 | for index in 0.. 1 ? split[1] : split[0] 46 | 47 | viewControllers.append(ControllerName(className: name, displayValue: displayValue)) 48 | } 49 | } 50 | 51 | return viewControllers 52 | } 53 | } 54 | 55 | func classFromControllerName(_ controllerName: ControllerName) -> AnyClass? { 56 | 57 | let cls: AnyClass? = NSClassFromString(controllerName.className) 58 | 59 | return cls 60 | } 61 | -------------------------------------------------------------------------------- /ControllerFactoryDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C783D4012134150E000AC835 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D4002134150E000AC835 /* AppDelegate.swift */; }; 11 | C783D4062134150E000AC835 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C783D4042134150E000AC835 /* Main.storyboard */; }; 12 | C783D4082134150F000AC835 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C783D4072134150F000AC835 /* Assets.xcassets */; }; 13 | C783D40B2134150F000AC835 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C783D4092134150F000AC835 /* LaunchScreen.storyboard */; }; 14 | C783D41321341585000AC835 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D41221341585000AC835 /* MainViewController.swift */; }; 15 | C783D42221341590000AC835 /* ProductsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C783D41521341590000AC835 /* ProductsViewController.m */; }; 16 | C783D42321341590000AC835 /* DashboardViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C783D41621341590000AC835 /* DashboardViewController.m */; }; 17 | C783D42421341590000AC835 /* DashboardViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C783D41721341590000AC835 /* DashboardViewController.xib */; }; 18 | C783D42521341590000AC835 /* ProductsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C783D41A21341590000AC835 /* ProductsViewController.xib */; }; 19 | C783D42621341590000AC835 /* LoginViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C783D41B21341590000AC835 /* LoginViewController.xib */; }; 20 | C783D42721341590000AC835 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D41C21341590000AC835 /* LoginViewController.swift */; }; 21 | C783D42821341590000AC835 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C783D41D21341590000AC835 /* AboutViewController.xib */; }; 22 | C783D42921341590000AC835 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C783D41E21341590000AC835 /* AboutViewController.swift */; }; 23 | C783D42A21341590000AC835 /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C783D42021341590000AC835 /* BaseViewController.m */; }; 24 | C783D4342134166B000AC835 /* ControllerFactory.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C783D4312134163B000AC835 /* ControllerFactory.framework */; }; 25 | C783D4352134166B000AC835 /* ControllerFactory.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C783D4312134163B000AC835 /* ControllerFactory.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | C783D4302134163B000AC835 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = C783D42C2134163B000AC835 /* ControllerFactory.xcodeproj */; 32 | proxyType = 2; 33 | remoteGlobalIDString = C783D3DB2134143A000AC835; 34 | remoteInfo = ControllerFactory; 35 | }; 36 | C783D4362134166B000AC835 /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = C783D42C2134163B000AC835 /* ControllerFactory.xcodeproj */; 39 | proxyType = 1; 40 | remoteGlobalIDString = C783D3DA2134143A000AC835; 41 | remoteInfo = ControllerFactory; 42 | }; 43 | /* End PBXContainerItemProxy section */ 44 | 45 | /* Begin PBXCopyFilesBuildPhase section */ 46 | C783D4382134166B000AC835 /* Embed Frameworks */ = { 47 | isa = PBXCopyFilesBuildPhase; 48 | buildActionMask = 2147483647; 49 | dstPath = ""; 50 | dstSubfolderSpec = 10; 51 | files = ( 52 | C783D4352134166B000AC835 /* ControllerFactory.framework in Embed Frameworks */, 53 | ); 54 | name = "Embed Frameworks"; 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXCopyFilesBuildPhase section */ 58 | 59 | /* Begin PBXFileReference section */ 60 | C783D3FD2134150E000AC835 /* ControllerFactoryDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ControllerFactoryDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | C783D4002134150E000AC835 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 62 | C783D4052134150E000AC835 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 63 | C783D4072134150F000AC835 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 64 | C783D40A2134150F000AC835 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 65 | C783D40C2134150F000AC835 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 66 | C783D41221341585000AC835 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 67 | C783D41521341590000AC835 /* ProductsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProductsViewController.m; sourceTree = ""; }; 68 | C783D41621341590000AC835 /* DashboardViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DashboardViewController.m; sourceTree = ""; }; 69 | C783D41721341590000AC835 /* DashboardViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DashboardViewController.xib; sourceTree = ""; }; 70 | C783D41821341590000AC835 /* ProductsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProductsViewController.h; sourceTree = ""; }; 71 | C783D41921341590000AC835 /* DashboardViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DashboardViewController.h; sourceTree = ""; }; 72 | C783D41A21341590000AC835 /* ProductsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ProductsViewController.xib; sourceTree = ""; }; 73 | C783D41B21341590000AC835 /* LoginViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LoginViewController.xib; sourceTree = ""; }; 74 | C783D41C21341590000AC835 /* LoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; 75 | C783D41D21341590000AC835 /* AboutViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AboutViewController.xib; sourceTree = ""; }; 76 | C783D41E21341590000AC835 /* AboutViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = ""; }; 77 | C783D42021341590000AC835 /* BaseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseViewController.m; sourceTree = ""; }; 78 | C783D42121341590000AC835 /* BaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseViewController.h; sourceTree = ""; }; 79 | C783D42B213415F4000AC835 /* ControllerFactoryDemo-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ControllerFactoryDemo-Bridging-Header.h"; sourceTree = ""; }; 80 | C783D42C2134163B000AC835 /* ControllerFactory.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = ControllerFactory.xcodeproj; sourceTree = ""; }; 81 | /* End PBXFileReference section */ 82 | 83 | /* Begin PBXFrameworksBuildPhase section */ 84 | C783D3FA2134150E000AC835 /* Frameworks */ = { 85 | isa = PBXFrameworksBuildPhase; 86 | buildActionMask = 2147483647; 87 | files = ( 88 | C783D4342134166B000AC835 /* ControllerFactory.framework in Frameworks */, 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | /* End PBXFrameworksBuildPhase section */ 93 | 94 | /* Begin PBXGroup section */ 95 | C783D3F42134150E000AC835 = { 96 | isa = PBXGroup; 97 | children = ( 98 | C783D3FF2134150E000AC835 /* ControllerFactoryDemo */, 99 | C783D42C2134163B000AC835 /* ControllerFactory.xcodeproj */, 100 | C783D3FE2134150E000AC835 /* Products */, 101 | ); 102 | sourceTree = ""; 103 | }; 104 | C783D3FE2134150E000AC835 /* Products */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | C783D3FD2134150E000AC835 /* ControllerFactoryDemo.app */, 108 | ); 109 | name = Products; 110 | sourceTree = ""; 111 | }; 112 | C783D3FF2134150E000AC835 /* ControllerFactoryDemo */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | C783D4002134150E000AC835 /* AppDelegate.swift */, 116 | C783D41221341585000AC835 /* MainViewController.swift */, 117 | C783D42B213415F4000AC835 /* ControllerFactoryDemo-Bridging-Header.h */, 118 | C783D41421341590000AC835 /* Controllers */, 119 | C783D4042134150E000AC835 /* Main.storyboard */, 120 | C783D4072134150F000AC835 /* Assets.xcassets */, 121 | C783D4092134150F000AC835 /* LaunchScreen.storyboard */, 122 | C783D40C2134150F000AC835 /* Info.plist */, 123 | ); 124 | path = ControllerFactoryDemo; 125 | sourceTree = ""; 126 | }; 127 | C783D41421341590000AC835 /* Controllers */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | C783D41F21341590000AC835 /* Base */, 131 | C783D41821341590000AC835 /* ProductsViewController.h */, 132 | C783D41521341590000AC835 /* ProductsViewController.m */, 133 | C783D41A21341590000AC835 /* ProductsViewController.xib */, 134 | C783D41921341590000AC835 /* DashboardViewController.h */, 135 | C783D41621341590000AC835 /* DashboardViewController.m */, 136 | C783D41721341590000AC835 /* DashboardViewController.xib */, 137 | C783D41C21341590000AC835 /* LoginViewController.swift */, 138 | C783D41B21341590000AC835 /* LoginViewController.xib */, 139 | C783D41E21341590000AC835 /* AboutViewController.swift */, 140 | C783D41D21341590000AC835 /* AboutViewController.xib */, 141 | ); 142 | path = Controllers; 143 | sourceTree = ""; 144 | }; 145 | C783D41F21341590000AC835 /* Base */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | C783D42021341590000AC835 /* BaseViewController.m */, 149 | C783D42121341590000AC835 /* BaseViewController.h */, 150 | ); 151 | path = Base; 152 | sourceTree = ""; 153 | }; 154 | C783D42D2134163B000AC835 /* Products */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | C783D4312134163B000AC835 /* ControllerFactory.framework */, 158 | ); 159 | name = Products; 160 | sourceTree = ""; 161 | }; 162 | /* End PBXGroup section */ 163 | 164 | /* Begin PBXNativeTarget section */ 165 | C783D3FC2134150E000AC835 /* ControllerFactoryDemo */ = { 166 | isa = PBXNativeTarget; 167 | buildConfigurationList = C783D40F2134150F000AC835 /* Build configuration list for PBXNativeTarget "ControllerFactoryDemo" */; 168 | buildPhases = ( 169 | C783D3F92134150E000AC835 /* Sources */, 170 | C783D3FA2134150E000AC835 /* Frameworks */, 171 | C783D3FB2134150E000AC835 /* Resources */, 172 | C783D4382134166B000AC835 /* Embed Frameworks */, 173 | ); 174 | buildRules = ( 175 | ); 176 | dependencies = ( 177 | C783D4372134166B000AC835 /* PBXTargetDependency */, 178 | ); 179 | name = ControllerFactoryDemo; 180 | productName = ControllerFactoryDemo; 181 | productReference = C783D3FD2134150E000AC835 /* ControllerFactoryDemo.app */; 182 | productType = "com.apple.product-type.application"; 183 | }; 184 | /* End PBXNativeTarget section */ 185 | 186 | /* Begin PBXProject section */ 187 | C783D3F52134150E000AC835 /* Project object */ = { 188 | isa = PBXProject; 189 | attributes = { 190 | LastSwiftUpdateCheck = 0940; 191 | LastUpgradeCheck = 0940; 192 | ORGANIZATIONNAME = Worldline; 193 | TargetAttributes = { 194 | C783D3FC2134150E000AC835 = { 195 | CreatedOnToolsVersion = 9.4.1; 196 | }; 197 | }; 198 | }; 199 | buildConfigurationList = C783D3F82134150E000AC835 /* Build configuration list for PBXProject "ControllerFactoryDemo" */; 200 | compatibilityVersion = "Xcode 9.3"; 201 | developmentRegion = en; 202 | hasScannedForEncodings = 0; 203 | knownRegions = ( 204 | en, 205 | Base, 206 | ); 207 | mainGroup = C783D3F42134150E000AC835; 208 | productRefGroup = C783D3FE2134150E000AC835 /* Products */; 209 | projectDirPath = ""; 210 | projectReferences = ( 211 | { 212 | ProductGroup = C783D42D2134163B000AC835 /* Products */; 213 | ProjectRef = C783D42C2134163B000AC835 /* ControllerFactory.xcodeproj */; 214 | }, 215 | ); 216 | projectRoot = ""; 217 | targets = ( 218 | C783D3FC2134150E000AC835 /* ControllerFactoryDemo */, 219 | ); 220 | }; 221 | /* End PBXProject section */ 222 | 223 | /* Begin PBXReferenceProxy section */ 224 | C783D4312134163B000AC835 /* ControllerFactory.framework */ = { 225 | isa = PBXReferenceProxy; 226 | fileType = wrapper.framework; 227 | path = ControllerFactory.framework; 228 | remoteRef = C783D4302134163B000AC835 /* PBXContainerItemProxy */; 229 | sourceTree = BUILT_PRODUCTS_DIR; 230 | }; 231 | /* End PBXReferenceProxy section */ 232 | 233 | /* Begin PBXResourcesBuildPhase section */ 234 | C783D3FB2134150E000AC835 /* Resources */ = { 235 | isa = PBXResourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | C783D40B2134150F000AC835 /* LaunchScreen.storyboard in Resources */, 239 | C783D42821341590000AC835 /* AboutViewController.xib in Resources */, 240 | C783D4082134150F000AC835 /* Assets.xcassets in Resources */, 241 | C783D42621341590000AC835 /* LoginViewController.xib in Resources */, 242 | C783D4062134150E000AC835 /* Main.storyboard in Resources */, 243 | C783D42421341590000AC835 /* DashboardViewController.xib in Resources */, 244 | C783D42521341590000AC835 /* ProductsViewController.xib in Resources */, 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | /* End PBXResourcesBuildPhase section */ 249 | 250 | /* Begin PBXSourcesBuildPhase section */ 251 | C783D3F92134150E000AC835 /* Sources */ = { 252 | isa = PBXSourcesBuildPhase; 253 | buildActionMask = 2147483647; 254 | files = ( 255 | C783D42921341590000AC835 /* AboutViewController.swift in Sources */, 256 | C783D4012134150E000AC835 /* AppDelegate.swift in Sources */, 257 | C783D42221341590000AC835 /* ProductsViewController.m in Sources */, 258 | C783D41321341585000AC835 /* MainViewController.swift in Sources */, 259 | C783D42721341590000AC835 /* LoginViewController.swift in Sources */, 260 | C783D42A21341590000AC835 /* BaseViewController.m in Sources */, 261 | C783D42321341590000AC835 /* DashboardViewController.m in Sources */, 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | }; 265 | /* End PBXSourcesBuildPhase section */ 266 | 267 | /* Begin PBXTargetDependency section */ 268 | C783D4372134166B000AC835 /* PBXTargetDependency */ = { 269 | isa = PBXTargetDependency; 270 | name = ControllerFactory; 271 | targetProxy = C783D4362134166B000AC835 /* PBXContainerItemProxy */; 272 | }; 273 | /* End PBXTargetDependency section */ 274 | 275 | /* Begin PBXVariantGroup section */ 276 | C783D4042134150E000AC835 /* Main.storyboard */ = { 277 | isa = PBXVariantGroup; 278 | children = ( 279 | C783D4052134150E000AC835 /* Base */, 280 | ); 281 | name = Main.storyboard; 282 | sourceTree = ""; 283 | }; 284 | C783D4092134150F000AC835 /* LaunchScreen.storyboard */ = { 285 | isa = PBXVariantGroup; 286 | children = ( 287 | C783D40A2134150F000AC835 /* Base */, 288 | ); 289 | name = LaunchScreen.storyboard; 290 | sourceTree = ""; 291 | }; 292 | /* End PBXVariantGroup section */ 293 | 294 | /* Begin XCBuildConfiguration section */ 295 | C783D40D2134150F000AC835 /* Debug */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ALWAYS_SEARCH_USER_PATHS = NO; 299 | CLANG_ANALYZER_NONNULL = YES; 300 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 301 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 302 | CLANG_CXX_LIBRARY = "libc++"; 303 | CLANG_ENABLE_MODULES = YES; 304 | CLANG_ENABLE_OBJC_ARC = YES; 305 | CLANG_ENABLE_OBJC_WEAK = YES; 306 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 307 | CLANG_WARN_BOOL_CONVERSION = YES; 308 | CLANG_WARN_COMMA = YES; 309 | CLANG_WARN_CONSTANT_CONVERSION = YES; 310 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 311 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 312 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 313 | CLANG_WARN_EMPTY_BODY = YES; 314 | CLANG_WARN_ENUM_CONVERSION = YES; 315 | CLANG_WARN_INFINITE_RECURSION = YES; 316 | CLANG_WARN_INT_CONVERSION = YES; 317 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 318 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 319 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 320 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 321 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 322 | CLANG_WARN_STRICT_PROTOTYPES = YES; 323 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 324 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 325 | CLANG_WARN_UNREACHABLE_CODE = YES; 326 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 327 | CODE_SIGN_IDENTITY = "iPhone Developer"; 328 | COPY_PHASE_STRIP = NO; 329 | DEBUG_INFORMATION_FORMAT = dwarf; 330 | ENABLE_STRICT_OBJC_MSGSEND = YES; 331 | ENABLE_TESTABILITY = YES; 332 | GCC_C_LANGUAGE_STANDARD = gnu11; 333 | GCC_DYNAMIC_NO_PIC = NO; 334 | GCC_NO_COMMON_BLOCKS = YES; 335 | GCC_OPTIMIZATION_LEVEL = 0; 336 | GCC_PREPROCESSOR_DEFINITIONS = ( 337 | "DEBUG=1", 338 | "$(inherited)", 339 | ); 340 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 341 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 342 | GCC_WARN_UNDECLARED_SELECTOR = YES; 343 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 344 | GCC_WARN_UNUSED_FUNCTION = YES; 345 | GCC_WARN_UNUSED_VARIABLE = YES; 346 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 347 | MTL_ENABLE_DEBUG_INFO = YES; 348 | ONLY_ACTIVE_ARCH = YES; 349 | SDKROOT = iphoneos; 350 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 351 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 352 | }; 353 | name = Debug; 354 | }; 355 | C783D40E2134150F000AC835 /* Release */ = { 356 | isa = XCBuildConfiguration; 357 | buildSettings = { 358 | ALWAYS_SEARCH_USER_PATHS = NO; 359 | CLANG_ANALYZER_NONNULL = YES; 360 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 361 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 362 | CLANG_CXX_LIBRARY = "libc++"; 363 | CLANG_ENABLE_MODULES = YES; 364 | CLANG_ENABLE_OBJC_ARC = YES; 365 | CLANG_ENABLE_OBJC_WEAK = YES; 366 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 367 | CLANG_WARN_BOOL_CONVERSION = YES; 368 | CLANG_WARN_COMMA = YES; 369 | CLANG_WARN_CONSTANT_CONVERSION = YES; 370 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 371 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 372 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 373 | CLANG_WARN_EMPTY_BODY = YES; 374 | CLANG_WARN_ENUM_CONVERSION = YES; 375 | CLANG_WARN_INFINITE_RECURSION = YES; 376 | CLANG_WARN_INT_CONVERSION = YES; 377 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 378 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 379 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 380 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 381 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 382 | CLANG_WARN_STRICT_PROTOTYPES = YES; 383 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 384 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 385 | CLANG_WARN_UNREACHABLE_CODE = YES; 386 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 387 | CODE_SIGN_IDENTITY = "iPhone Developer"; 388 | COPY_PHASE_STRIP = NO; 389 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 390 | ENABLE_NS_ASSERTIONS = NO; 391 | ENABLE_STRICT_OBJC_MSGSEND = YES; 392 | GCC_C_LANGUAGE_STANDARD = gnu11; 393 | GCC_NO_COMMON_BLOCKS = YES; 394 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 395 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 396 | GCC_WARN_UNDECLARED_SELECTOR = YES; 397 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 398 | GCC_WARN_UNUSED_FUNCTION = YES; 399 | GCC_WARN_UNUSED_VARIABLE = YES; 400 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 401 | MTL_ENABLE_DEBUG_INFO = NO; 402 | SDKROOT = iphoneos; 403 | SWIFT_COMPILATION_MODE = wholemodule; 404 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 405 | VALIDATE_PRODUCT = YES; 406 | }; 407 | name = Release; 408 | }; 409 | C783D4102134150F000AC835 /* Debug */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 413 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 414 | CODE_SIGN_STYLE = Manual; 415 | DEVELOPMENT_TEAM = 5GARSM38JL; 416 | INFOPLIST_FILE = ControllerFactoryDemo/Info.plist; 417 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 418 | LD_RUNPATH_SEARCH_PATHS = ( 419 | "$(inherited)", 420 | "@executable_path/Frameworks", 421 | ); 422 | PRODUCT_BUNDLE_IDENTIFIER = com.worldline.ControllerFactoryDemo; 423 | PRODUCT_NAME = "$(TARGET_NAME)"; 424 | PROVISIONING_PROFILE = "12f7fa78-2412-404d-bad9-1b66c5ea2603"; 425 | PROVISIONING_PROFILE_SPECIFIER = "Worldline Development Wildcard"; 426 | SWIFT_OBJC_BRIDGING_HEADER = "ControllerFactoryDemo/ControllerFactoryDemo-Bridging-Header.h"; 427 | SWIFT_VERSION = 4.0; 428 | TARGETED_DEVICE_FAMILY = "1,2"; 429 | }; 430 | name = Debug; 431 | }; 432 | C783D4112134150F000AC835 /* Release */ = { 433 | isa = XCBuildConfiguration; 434 | buildSettings = { 435 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 436 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 437 | CODE_SIGN_STYLE = Manual; 438 | DEVELOPMENT_TEAM = ""; 439 | INFOPLIST_FILE = ControllerFactoryDemo/Info.plist; 440 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 441 | LD_RUNPATH_SEARCH_PATHS = ( 442 | "$(inherited)", 443 | "@executable_path/Frameworks", 444 | ); 445 | PRODUCT_BUNDLE_IDENTIFIER = com.worldline.ControllerFactoryDemo; 446 | PRODUCT_NAME = "$(TARGET_NAME)"; 447 | PROVISIONING_PROFILE_SPECIFIER = ""; 448 | SWIFT_OBJC_BRIDGING_HEADER = "ControllerFactoryDemo/ControllerFactoryDemo-Bridging-Header.h"; 449 | SWIFT_VERSION = 4.0; 450 | TARGETED_DEVICE_FAMILY = "1,2"; 451 | }; 452 | name = Release; 453 | }; 454 | /* End XCBuildConfiguration section */ 455 | 456 | /* Begin XCConfigurationList section */ 457 | C783D3F82134150E000AC835 /* Build configuration list for PBXProject "ControllerFactoryDemo" */ = { 458 | isa = XCConfigurationList; 459 | buildConfigurations = ( 460 | C783D40D2134150F000AC835 /* Debug */, 461 | C783D40E2134150F000AC835 /* Release */, 462 | ); 463 | defaultConfigurationIsVisible = 0; 464 | defaultConfigurationName = Release; 465 | }; 466 | C783D40F2134150F000AC835 /* Build configuration list for PBXNativeTarget "ControllerFactoryDemo" */ = { 467 | isa = XCConfigurationList; 468 | buildConfigurations = ( 469 | C783D4102134150F000AC835 /* Debug */, 470 | C783D4112134150F000AC835 /* Release */, 471 | ); 472 | defaultConfigurationIsVisible = 0; 473 | defaultConfigurationName = Release; 474 | }; 475 | /* End XCConfigurationList section */ 476 | }; 477 | rootObject = C783D3F52134150E000AC835 /* Project object */; 478 | } 479 | -------------------------------------------------------------------------------- /ControllerFactoryDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ControllerFactoryDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "57x57", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-57x57@1x.png", 49 | "scale" : "1x" 50 | }, 51 | { 52 | "size" : "57x57", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-57x57@2x.png", 55 | "scale" : "2x" 56 | }, 57 | { 58 | "size" : "60x60", 59 | "idiom" : "iphone", 60 | "filename" : "Icon-App-60x60@2x.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "60x60", 65 | "idiom" : "iphone", 66 | "filename" : "Icon-App-60x60@3x.png", 67 | "scale" : "3x" 68 | }, 69 | { 70 | "size" : "20x20", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-20x20@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "20x20", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-20x20@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "29x29", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-29x29@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "29x29", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-29x29@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "40x40", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-40x40@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "40x40", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-40x40@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "50x50", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-Small-50x50@1x.png", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "size" : "50x50", 113 | "idiom" : "ipad", 114 | "filename" : "Icon-Small-50x50@2x.png", 115 | "scale" : "2x" 116 | }, 117 | { 118 | "size" : "72x72", 119 | "idiom" : "ipad", 120 | "filename" : "Icon-App-72x72@1x.png", 121 | "scale" : "1x" 122 | }, 123 | { 124 | "size" : "72x72", 125 | "idiom" : "ipad", 126 | "filename" : "Icon-App-72x72@2x.png", 127 | "scale" : "2x" 128 | }, 129 | { 130 | "size" : "76x76", 131 | "idiom" : "ipad", 132 | "filename" : "Icon-App-76x76@1x.png", 133 | "scale" : "1x" 134 | }, 135 | { 136 | "size" : "76x76", 137 | "idiom" : "ipad", 138 | "filename" : "Icon-App-76x76@2x.png", 139 | "scale" : "2x" 140 | }, 141 | { 142 | "size" : "83.5x83.5", 143 | "idiom" : "ipad", 144 | "filename" : "Icon-App-83.5x83.5@2x.png", 145 | "scale" : "2x" 146 | }, 147 | { 148 | "size" : "1024x1024", 149 | "idiom" : "ios-marketing", 150 | "filename" : "ItunesArtwork@2x.png", 151 | "scale" : "1x" 152 | } 153 | ], 154 | "info" : { 155 | "version" : 1, 156 | "author" : "xcode" 157 | } 158 | } -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small-50x50@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small-50x50@1x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small-50x50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/Icon-Small-50x50@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/ControllerFactoryDemo/Assets.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png -------------------------------------------------------------------------------- /ControllerFactoryDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ControllerFactoryDemo/Base.lproj/LaunchScreen.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 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Base.lproj/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 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/ControllerFactoryDemo-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "BaseViewController.h" 6 | #import "DashboardViewController.h" 7 | #import "ProductsViewController.h" 8 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/AboutViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AboutViewController.swift 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ControllerFactory 11 | 12 | class AboutViewController: BaseViewController { 13 | 14 | } 15 | 16 | extension AboutViewController: ControllerFactoryCompliant { 17 | 18 | func prepareForControllerFactory() { 19 | print("Prepared for ControllerFactory") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/AboutViewController.xib: -------------------------------------------------------------------------------- 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 | 26 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/Base/BaseViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.h 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Vincent Pradeilles on 18/05/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BaseViewController : UIViewController 12 | 13 | @property (strong, nonatomic) UILabel *titleLabel; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/Base/BaseViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.m 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Vincent Pradeilles on 18/05/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | #import "BaseViewController.h" 10 | 11 | @interface BaseViewController () 12 | 13 | @end 14 | 15 | @implementation BaseViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | self.title = [[self class] description]; 21 | 22 | self.titleLabel = [[UILabel alloc] init]; 23 | self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO; 24 | self.titleLabel.numberOfLines = 0; 25 | self.titleLabel.text = self.title; 26 | [self.view addSubview:self.titleLabel]; 27 | [self.view addConstraint:[self.titleLabel.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor]]; 28 | [self.view addConstraint:[self.titleLabel.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/DashboardViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DashboardViewController.h 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BaseViewController.h" 11 | 12 | @import ControllerFactory; 13 | 14 | @interface DashboardViewController : BaseViewController 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/DashboardViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DashboardViewController.m 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | #import "DashboardViewController.h" 10 | 11 | @interface DashboardViewController() 12 | 13 | @property (nonatomic, strong) NSString *useCase; 14 | 15 | @end 16 | 17 | @implementation DashboardViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | self.titleLabel.text = [self.titleLabel.text stringByAppendingFormat:@"\n%@", self.useCase]; 23 | } 24 | 25 | + (NSArray *)getUseCases { 26 | return @[@"Case 1", @"Case 2"]; 27 | } 28 | 29 | - (void)prepareForControllerFactoryWithUseCase:(NSString *)useCase { 30 | NSLog(@"Use case: %@", useCase); 31 | self.useCase = useCase; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/DashboardViewController.xib: -------------------------------------------------------------------------------- 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 | 26 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/LoginViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoginViewController.swift 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ControllerFactory 11 | 12 | class LoginViewController: BaseViewController { 13 | var useCase: String = "" 14 | } 15 | 16 | extension LoginViewController: ControllerFactoryUseCaseCompliant { 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | self.titleLabel.text = self.titleLabel.text.map { "\($0)\n\(useCase)" } 22 | } 23 | 24 | static func getUseCases() -> [String] { 25 | return ["Not Enrolled", "Enrolled"] 26 | } 27 | 28 | func prepareForControllerFactory(useCase: String) { 29 | print("Use case: \(useCase)") 30 | 31 | self.useCase = useCase 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/LoginViewController.xib: -------------------------------------------------------------------------------- 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 | 26 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/ProductsViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ProductsViewController.h 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BaseViewController.h" 11 | 12 | @interface ProductsViewController : BaseViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/ProductsViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ProductsViewController.m 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | #import "ProductsViewController.h" 10 | 11 | @implementation ProductsViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Controllers/ProductsViewController.xib: -------------------------------------------------------------------------------- 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 | 26 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ControllerFactoryDemo/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.swift 3 | // ControllerFactoryDemo 4 | // 5 | // Created by Benoit Caron on 16/01/2018. 6 | // Copyright © 2018 worldline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ControllerFactory 11 | 12 | class MainViewController: UIViewController { 13 | 14 | @IBAction func showControllerFactory(_ sender: Any) { 15 | 16 | ControllerFactory.printControllers() 17 | 18 | let controllerFactory = ControllerFactory.instantiate(bundle: Bundle.main, excludedViewControllers: ["BaseViewController"]) 19 | 20 | show(controllerFactory, sender: self) 21 | } 22 | } 23 | 24 | extension MainViewController: ControllerFactoryInstantiable { 25 | static func initForControllerFactory() -> UIViewController { 26 | return UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MainViewController") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Vincent Pradeilles 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS Controller Factory 2 | 3 | ![pod](https://img.shields.io/cocoapods/v/ControllerFactory.svg) 4 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 5 | 6 | ![](readme-images/icon.png) 7 | 8 | ## Purpose of the iOS `ControllerFactory` 9 | 10 | Embedding a debug view in your app is a great tool to save a lot of time, but it can also be a tedious one to build. 11 | 12 | ControllerFactory is a framework that aims at easily allowing the instantiation of *any* `UIViewController` from your app, in a way that is as fast and painless as possible. 13 | 14 | The framework will leverage the runtime environment to retrieve the complete list of all the view controllers in your app, and let you choose which one you wish to see displayed on screen. Additionally, it also embeds customization options, for instance to provide initial data. 15 | 16 | ## Requirements 17 | - iOS 8.0+ 18 | - Xcode 9.0+ 19 | - Swift 4.1+ 20 | 21 | ## Installation 22 | 23 | ### CocoaPods 24 | 25 | Add the following to your `Podfile`: 26 | 27 | `pod "ControllerFactory"` 28 | 29 | ### Carthage 30 | 31 | Add the following to your `Cartfile`: 32 | 33 | `github "worldline/ControllerFactory"` 34 | 35 | ## How `ControllerFactory` can help you save time 36 | 37 | Let's say you want to adapt your app to make the best use of the gorgeous iPhone X display. 38 | 39 | Step 1 - You adapt and test your app's homepage. Check. 40 | 41 | Step 2 - Then you adapt and test your app's settings view controller. Easy. 42 | 43 | But then, you adapt and need to test, for the eleventh time, the third controller of the enrolment process. You need to go through the whole enrolment process, again and again. Maybe you cheat a little, and, why not, create an easy access button on your homepage, which loads this controller directly. This is fine... 44 | 45 | But, are you willing to do that for the 35 controllers left? 46 | 47 | No, you are not. This is where ControllerFactory saves the day. 48 | 49 | ## How does `ControllerFactory` work? 50 | 51 | `ControllerFactory` provides you with a debug view that will automatically retrieve and list **all** your view controllers: 52 | 53 | ![](readme-images/controllerList.png) 54 | 55 | Then you just need to select the view controller you want to instantiate, and choose wether you want it pushed or presented modally. 56 | 57 | ![](readme-images/controllerFactory.png) 58 | 59 | All your view controllers can now be displayed on screen, with just two taps 👌 60 | 61 | ## Limitations 62 | 63 | For the moment, `ControllerFactory` cannot: 64 | 65 | * deal with controllers that are using Swift's Generics, as they cannot be marked `@objc`; 66 | * deal with controllers that are instantiated from a UIStoryboard, without writing some code (see [below](#custom-initializer)); 67 | * fetch controllers from multiple bundles at the same time. 68 | 69 | ## Usage 70 | 71 | * [Import](#import) 72 | * [Displaying the debug view](#displaying-the-debug-view) 73 | * [Excluding specific view controllers](#excluding-specific-view-controllers) 74 | * [Setting up initial data](#setting-up-initial-data) 75 | * [Tackling controllers with several use cases](#tackling-controllers-with-several-use-cases) 76 | * [Custom initializer](#custom-initializer) 77 | * [Custom initializer with use cases](#custom-initializer-with-use-cases) 78 | 79 | ### Import 80 | 81 | ```objc 82 | // Objective C 83 | @import ControllerFactory; 84 | ``` 85 | 86 | ```swift 87 | // Swift 88 | import ControllerFactory 89 | ``` 90 | 91 | ### Displaying the debug view 92 | 93 | To instantiate the debug view, you can use any of the following methods: 94 | 95 | ```objc 96 | // Objective C 97 | [ControllerFactory instantiate]; 98 | [ControllerFactory instantiateWithBundle:(NSBundle * _Nonnull)]; 99 | [ControllerFactory instantiateWithExcludedViewControllers:(NSArray * _Nonnull)]; 100 | [ControllerFactory instantiateWithBundle:(NSBundle * _Nonnull) excludedViewControllers:(NSArray * _Nonnull)]; 101 | ``` 102 | 103 | ```swift 104 | // Swift 105 | ControllerFactory.instantiate() 106 | ControllerFactory.instantiate(bundle: Bundle) 107 | ControllerFactory.instantiate(excludedViewControllers: [String]) 108 | ControllerFactory.instantiate(bundle: Bundle, excludedViewControllers: [String]) 109 | ``` 110 | 111 | The basic method will show you all the view controllers from your main bundle. 112 | 113 | You also have the possibility to specify a different bundle if you need to, and/or exclude some specific view controllers (for instance, abstract classes). 114 | 115 | ### Excluding specific view controllers 116 | 117 | In order to exclude some specific view controllers, first start by printing out to the console the list of all the controllers that were retrieved: 118 | 119 | ```objc 120 | // Objective C 121 | [ControllerFactory printControllers]; 122 | [ControllerFactory printControllersWithBundle:(NSBundle * _Nonnull)]; 123 | ``` 124 | 125 | ```swift 126 | // Swift 127 | ControllerFactory.printControllers() 128 | ControllerFactory.printControllers(bundle: Bundle) 129 | ``` 130 | 131 | Just as before, the first method will print all the view controllers from your main bundle, while the second one allows you to print all the view controllers from another bundle. 132 | 133 | You then need to use the values that were printed in order to populate the `excludedViewControllers` array. 134 | 135 | ### Setting up initial data 136 | 137 | Up to this point, we used the debug view to instantiate controllers using their default initializer. While this works well for simple controllers, it does not allow you to provide some initial data. 138 | 139 | To do so, you can implement the following protocol: 140 | 141 | ```swift 142 | // Swift 143 | @objc public protocol ControllerFactoryCompliant { 144 | func prepareForControllerFactory() 145 | } 146 | ``` 147 | 148 | The `prepareForControllerFactory()` method will be called after the controller has been instantiated and before the it is displayed, so this is a perfect place to set up some initial data. 149 | 150 | ### Tackling controllers with several use cases 151 | 152 | If your controller implements several use cases, or works with several sets of data, you can hand the them through the protocol `ControllerFactoryCompliant`: 153 | 154 | ```swift 155 | // Swift 156 | @objc public protocol ControllerFactoryUseCaseCompliant { 157 | static func getUseCases() -> [String] 158 | func prepareForControllerFactory(useCase: String) 159 | } 160 | ``` 161 | 162 | The `getUseCases()` method allows you to list your use cases. 163 | 164 | The `prepareForControllerFactory(useCase: String)` method will be called after initialization, so this is where you should set your data or by switch to a particular use case. 165 | 166 | The debug view will then present the different use cases, allowing you to select the one you need. 167 | 168 | ### Custom initializer 169 | 170 | If your view controller doesn't make use of the default initializer, trying to instantiate it will cause your app to crash. To resolve the issue, you will need to implement the following protocol: 171 | 172 | ```swift 173 | // Swift 174 | @objc public protocol ControllerFactoryInstantiable { 175 | static func initForControllerFactory() -> UIViewController 176 | } 177 | ``` 178 | 179 | In the `initForControllerFactory()` you can use your custom initializer, set all the required data, and then return the controller. 180 | 181 | ### Custom initializer with use cases 182 | 183 | Finally, if your view controller doesn't make use of the default initializer and depends on different use cases, or different sets of data, you will need to implement the following protocol: 184 | 185 | ```swift 186 | // Swift 187 | @objc public protocol ControllerFactoryUseCaseInstantiable { 188 | static func getUseCases() -> [String] 189 | static func initForControllerFactory(useCase: String) -> UIViewController 190 | } 191 | ``` 192 | 193 | Just as before, the `getUseCases()` method will allow you to name your different use cases. 194 | 195 | In the `initForControllerFactory(useCase: String)` you use your custom initializer to create the controller. 196 | 197 | The debug view will then present the different use cases for you to select, before instantiating your view controller. 198 | 199 | ## Credits 200 | 201 | This framework has been put together at [Worldline](https://worldline.com) by [Benoît Caron](https://www.linkedin.com/in/benoît-caron-57530634/) and [Vincent Pradeilles](https://github.com/vincent-pradeilles/). 202 | 203 | ## License 204 | 205 | This framework is provided under the MIT license. 206 | -------------------------------------------------------------------------------- /readme-images/after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/readme-images/after.png -------------------------------------------------------------------------------- /readme-images/before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/readme-images/before.png -------------------------------------------------------------------------------- /readme-images/controllerFactory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/readme-images/controllerFactory.png -------------------------------------------------------------------------------- /readme-images/controllerList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/readme-images/controllerList.png -------------------------------------------------------------------------------- /readme-images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worldline/ControllerFactory/035b3e8bd0c6665b4737bf5583d1361b9dd239f8/readme-images/icon.png --------------------------------------------------------------------------------