├── .gitignore ├── AppDelegateExtensions ├── AppDelegateExtensionsDemo.xcodeproj │ └── project.pbxproj └── AppDelegateExtensionsDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── AppDelegateExtensions.h │ ├── AppDelegateExtensions.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── AppdelegateExtension.podspec └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 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 | *.xcuserstate 14 | *.xccheckout 15 | *.moved-aside 16 | DerivedData 17 | *.hmap 18 | *.ipa 19 | *.orig 20 | *.xcscmblueprint 21 | npm-debug.log 22 | # CocoaPods 23 | # 24 | # We recommend against adding the Pods directory to your .gitignore. However 25 | # you should judge for yourself, the pros and cons are mentioned at: 26 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control? 27 | # 28 | Pods/ 29 | bin/ 30 | 31 | 32 | ### AppCode ### 33 | ## Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm 34 | # 35 | ### Directory-based project format 36 | .idea/ 37 | ## if you remove the above rule, at least ignore user-specific stuff: 38 | # .idea/workspace.xml 39 | ## .idea/tasks.xml 40 | ## and these sensitive or high-churn files: 41 | ## .idea/dataSources.ids 42 | ## .idea/dataSources.xml 43 | ## .idea/sqlDataSources.xml 44 | ## .idea/dynamic.xml 45 | # 46 | ### File-based project format 47 | *.ipr 48 | *.iml 49 | *.iws 50 | # 51 | ### Additional for IntelliJ 52 | out/ 53 | # 54 | ## generated by mpeltonen/sbt-idea plugin 55 | .idea_modules/ 56 | # 57 | ## generated by JIRA plugin 58 | atlassian-ide-plugin.xml 59 | # 60 | ## generated by Crashlytics plugin (for Android Studio and Intellij) 61 | com_crashlytics_export_strings.xml 62 | # 63 | # 64 | ReactComponent/ 65 | # 66 | ## React Native JS file 67 | # 68 | # 69 | cleanUUID.log 70 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8E612B8D1F4C368800543E53 /* AppDelegateExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E612B8C1F4C368800543E53 /* AppDelegateExtensions.m */; }; 11 | 8E8DE1CD1F4A820B00B1F926 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E8DE1CC1F4A820B00B1F926 /* main.m */; }; 12 | 8E8DE1D01F4A820B00B1F926 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E8DE1CF1F4A820B00B1F926 /* AppDelegate.m */; }; 13 | 8E8DE1D31F4A820B00B1F926 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E8DE1D21F4A820B00B1F926 /* ViewController.m */; }; 14 | 8E8DE1D61F4A820B00B1F926 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8E8DE1D41F4A820B00B1F926 /* Main.storyboard */; }; 15 | 8E8DE1D81F4A820B00B1F926 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8E8DE1D71F4A820B00B1F926 /* Assets.xcassets */; }; 16 | 8E8DE1DB1F4A820B00B1F926 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8E8DE1D91F4A820B00B1F926 /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | 8E8DE1F31F4A832F00B1F926 /* Embed Frameworks */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = ""; 24 | dstSubfolderSpec = 10; 25 | files = ( 26 | ); 27 | name = "Embed Frameworks"; 28 | runOnlyForDeploymentPostprocessing = 0; 29 | }; 30 | /* End PBXCopyFilesBuildPhase section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 8E612B8B1F4C368800543E53 /* AppDelegateExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegateExtensions.h; sourceTree = ""; }; 34 | 8E612B8C1F4C368800543E53 /* AppDelegateExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegateExtensions.m; sourceTree = ""; }; 35 | 8E8DE1C81F4A820B00B1F926 /* AppDelegateExtensionsDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppDelegateExtensionsDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | 8E8DE1CC1F4A820B00B1F926 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 37 | 8E8DE1CE1F4A820B00B1F926 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 38 | 8E8DE1CF1F4A820B00B1F926 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 39 | 8E8DE1D11F4A820B00B1F926 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 40 | 8E8DE1D21F4A820B00B1F926 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 41 | 8E8DE1D51F4A820B00B1F926 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 8E8DE1D71F4A820B00B1F926 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 8E8DE1DA1F4A820B00B1F926 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 8E8DE1DC1F4A820B00B1F926 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 8E8DE1C51F4A820B00B1F926 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 8E8DE1BF1F4A820B00B1F926 = { 59 | isa = PBXGroup; 60 | children = ( 61 | 8E8DE1CA1F4A820B00B1F926 /* AppDelegateExtensionsDemo */, 62 | 8E8DE1C91F4A820B00B1F926 /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | 8E8DE1C91F4A820B00B1F926 /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 8E8DE1C81F4A820B00B1F926 /* AppDelegateExtensionsDemo.app */, 70 | ); 71 | name = Products; 72 | sourceTree = ""; 73 | }; 74 | 8E8DE1CA1F4A820B00B1F926 /* AppDelegateExtensionsDemo */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 8E612B8B1F4C368800543E53 /* AppDelegateExtensions.h */, 78 | 8E612B8C1F4C368800543E53 /* AppDelegateExtensions.m */, 79 | 8E8DE1CE1F4A820B00B1F926 /* AppDelegate.h */, 80 | 8E8DE1CF1F4A820B00B1F926 /* AppDelegate.m */, 81 | 8E8DE1D11F4A820B00B1F926 /* ViewController.h */, 82 | 8E8DE1D21F4A820B00B1F926 /* ViewController.m */, 83 | 8E8DE1D41F4A820B00B1F926 /* Main.storyboard */, 84 | 8E8DE1D71F4A820B00B1F926 /* Assets.xcassets */, 85 | 8E8DE1D91F4A820B00B1F926 /* LaunchScreen.storyboard */, 86 | 8E8DE1DC1F4A820B00B1F926 /* Info.plist */, 87 | 8E8DE1CB1F4A820B00B1F926 /* Supporting Files */, 88 | ); 89 | path = AppDelegateExtensionsDemo; 90 | sourceTree = ""; 91 | }; 92 | 8E8DE1CB1F4A820B00B1F926 /* Supporting Files */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 8E8DE1CC1F4A820B00B1F926 /* main.m */, 96 | ); 97 | name = "Supporting Files"; 98 | sourceTree = ""; 99 | }; 100 | /* End PBXGroup section */ 101 | 102 | /* Begin PBXNativeTarget section */ 103 | 8E8DE1C71F4A820B00B1F926 /* AppDelegateExtensionsDemo */ = { 104 | isa = PBXNativeTarget; 105 | buildConfigurationList = 8E8DE1DF1F4A820B00B1F926 /* Build configuration list for PBXNativeTarget "AppDelegateExtensionsDemo" */; 106 | buildPhases = ( 107 | 8E8DE1C41F4A820B00B1F926 /* Sources */, 108 | 8E8DE1C51F4A820B00B1F926 /* Frameworks */, 109 | 8E8DE1C61F4A820B00B1F926 /* Resources */, 110 | 8E8DE1F31F4A832F00B1F926 /* Embed Frameworks */, 111 | ); 112 | buildRules = ( 113 | ); 114 | dependencies = ( 115 | ); 116 | name = AppDelegateExtensionsDemo; 117 | productName = AppDelegateExtensionsDemo; 118 | productReference = 8E8DE1C81F4A820B00B1F926 /* AppDelegateExtensionsDemo.app */; 119 | productType = "com.apple.product-type.application"; 120 | }; 121 | /* End PBXNativeTarget section */ 122 | 123 | /* Begin PBXProject section */ 124 | 8E8DE1C01F4A820B00B1F926 /* Project object */ = { 125 | isa = PBXProject; 126 | attributes = { 127 | LastUpgradeCheck = 0830; 128 | ORGANIZATIONNAME = Mobike; 129 | TargetAttributes = { 130 | 8E8DE1C71F4A820B00B1F926 = { 131 | CreatedOnToolsVersion = 8.3.3; 132 | DevelopmentTeam = 5HGEPVJ8JL; 133 | ProvisioningStyle = Automatic; 134 | }; 135 | }; 136 | }; 137 | buildConfigurationList = 8E8DE1C31F4A820B00B1F926 /* Build configuration list for PBXProject "AppDelegateExtensionsDemo" */; 138 | compatibilityVersion = "Xcode 3.2"; 139 | developmentRegion = English; 140 | hasScannedForEncodings = 0; 141 | knownRegions = ( 142 | en, 143 | Base, 144 | ); 145 | mainGroup = 8E8DE1BF1F4A820B00B1F926; 146 | productRefGroup = 8E8DE1C91F4A820B00B1F926 /* Products */; 147 | projectDirPath = ""; 148 | projectRoot = ""; 149 | targets = ( 150 | 8E8DE1C71F4A820B00B1F926 /* AppDelegateExtensionsDemo */, 151 | ); 152 | }; 153 | /* End PBXProject section */ 154 | 155 | /* Begin PBXResourcesBuildPhase section */ 156 | 8E8DE1C61F4A820B00B1F926 /* Resources */ = { 157 | isa = PBXResourcesBuildPhase; 158 | buildActionMask = 2147483647; 159 | files = ( 160 | 8E8DE1DB1F4A820B00B1F926 /* LaunchScreen.storyboard in Resources */, 161 | 8E8DE1D81F4A820B00B1F926 /* Assets.xcassets in Resources */, 162 | 8E8DE1D61F4A820B00B1F926 /* Main.storyboard in Resources */, 163 | ); 164 | runOnlyForDeploymentPostprocessing = 0; 165 | }; 166 | /* End PBXResourcesBuildPhase section */ 167 | 168 | /* Begin PBXSourcesBuildPhase section */ 169 | 8E8DE1C41F4A820B00B1F926 /* Sources */ = { 170 | isa = PBXSourcesBuildPhase; 171 | buildActionMask = 2147483647; 172 | files = ( 173 | 8E8DE1D31F4A820B00B1F926 /* ViewController.m in Sources */, 174 | 8E8DE1D01F4A820B00B1F926 /* AppDelegate.m in Sources */, 175 | 8E612B8D1F4C368800543E53 /* AppDelegateExtensions.m in Sources */, 176 | 8E8DE1CD1F4A820B00B1F926 /* main.m in Sources */, 177 | ); 178 | runOnlyForDeploymentPostprocessing = 0; 179 | }; 180 | /* End PBXSourcesBuildPhase section */ 181 | 182 | /* Begin PBXVariantGroup section */ 183 | 8E8DE1D41F4A820B00B1F926 /* Main.storyboard */ = { 184 | isa = PBXVariantGroup; 185 | children = ( 186 | 8E8DE1D51F4A820B00B1F926 /* Base */, 187 | ); 188 | name = Main.storyboard; 189 | sourceTree = ""; 190 | }; 191 | 8E8DE1D91F4A820B00B1F926 /* LaunchScreen.storyboard */ = { 192 | isa = PBXVariantGroup; 193 | children = ( 194 | 8E8DE1DA1F4A820B00B1F926 /* Base */, 195 | ); 196 | name = LaunchScreen.storyboard; 197 | sourceTree = ""; 198 | }; 199 | /* End PBXVariantGroup section */ 200 | 201 | /* Begin XCBuildConfiguration section */ 202 | 8E8DE1DD1F4A820B00B1F926 /* Debug */ = { 203 | isa = XCBuildConfiguration; 204 | buildSettings = { 205 | ALWAYS_SEARCH_USER_PATHS = NO; 206 | CLANG_ANALYZER_NONNULL = YES; 207 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 208 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 209 | CLANG_CXX_LIBRARY = "libc++"; 210 | CLANG_ENABLE_MODULES = YES; 211 | CLANG_ENABLE_OBJC_ARC = YES; 212 | CLANG_WARN_BOOL_CONVERSION = YES; 213 | CLANG_WARN_CONSTANT_CONVERSION = YES; 214 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 215 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 216 | CLANG_WARN_EMPTY_BODY = YES; 217 | CLANG_WARN_ENUM_CONVERSION = YES; 218 | CLANG_WARN_INFINITE_RECURSION = YES; 219 | CLANG_WARN_INT_CONVERSION = YES; 220 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 221 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 222 | CLANG_WARN_UNREACHABLE_CODE = YES; 223 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 224 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 225 | COPY_PHASE_STRIP = NO; 226 | DEBUG_INFORMATION_FORMAT = dwarf; 227 | ENABLE_STRICT_OBJC_MSGSEND = YES; 228 | ENABLE_TESTABILITY = YES; 229 | GCC_C_LANGUAGE_STANDARD = gnu99; 230 | GCC_DYNAMIC_NO_PIC = NO; 231 | GCC_NO_COMMON_BLOCKS = YES; 232 | GCC_OPTIMIZATION_LEVEL = 0; 233 | GCC_PREPROCESSOR_DEFINITIONS = ( 234 | "DEBUG=1", 235 | "$(inherited)", 236 | ); 237 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 238 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 239 | GCC_WARN_UNDECLARED_SELECTOR = YES; 240 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 241 | GCC_WARN_UNUSED_FUNCTION = YES; 242 | GCC_WARN_UNUSED_VARIABLE = YES; 243 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 244 | MTL_ENABLE_DEBUG_INFO = YES; 245 | ONLY_ACTIVE_ARCH = YES; 246 | SDKROOT = iphoneos; 247 | }; 248 | name = Debug; 249 | }; 250 | 8E8DE1DE1F4A820B00B1F926 /* Release */ = { 251 | isa = XCBuildConfiguration; 252 | buildSettings = { 253 | ALWAYS_SEARCH_USER_PATHS = NO; 254 | CLANG_ANALYZER_NONNULL = YES; 255 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 256 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 257 | CLANG_CXX_LIBRARY = "libc++"; 258 | CLANG_ENABLE_MODULES = YES; 259 | CLANG_ENABLE_OBJC_ARC = YES; 260 | CLANG_WARN_BOOL_CONVERSION = YES; 261 | CLANG_WARN_CONSTANT_CONVERSION = YES; 262 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 263 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 264 | CLANG_WARN_EMPTY_BODY = YES; 265 | CLANG_WARN_ENUM_CONVERSION = YES; 266 | CLANG_WARN_INFINITE_RECURSION = YES; 267 | CLANG_WARN_INT_CONVERSION = YES; 268 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 269 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 270 | CLANG_WARN_UNREACHABLE_CODE = YES; 271 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 272 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 273 | COPY_PHASE_STRIP = NO; 274 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 275 | ENABLE_NS_ASSERTIONS = NO; 276 | ENABLE_STRICT_OBJC_MSGSEND = YES; 277 | GCC_C_LANGUAGE_STANDARD = gnu99; 278 | GCC_NO_COMMON_BLOCKS = YES; 279 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 280 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 281 | GCC_WARN_UNDECLARED_SELECTOR = YES; 282 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 283 | GCC_WARN_UNUSED_FUNCTION = YES; 284 | GCC_WARN_UNUSED_VARIABLE = YES; 285 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 286 | MTL_ENABLE_DEBUG_INFO = NO; 287 | SDKROOT = iphoneos; 288 | VALIDATE_PRODUCT = YES; 289 | }; 290 | name = Release; 291 | }; 292 | 8E8DE1E01F4A820B00B1F926 /* Debug */ = { 293 | isa = XCBuildConfiguration; 294 | buildSettings = { 295 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 296 | DEVELOPMENT_TEAM = 5HGEPVJ8JL; 297 | FRAMEWORK_SEARCH_PATHS = ( 298 | "$(inherited)", 299 | "$(PROJECT_DIR)/AppDelegateExtensionsDemo", 300 | ); 301 | INFOPLIST_FILE = AppDelegateExtensionsDemo/Info.plist; 302 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 303 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 304 | PRODUCT_BUNDLE_IDENTIFIER = Mobike.AppDelegateExtensionsDemo; 305 | PRODUCT_NAME = "$(TARGET_NAME)"; 306 | }; 307 | name = Debug; 308 | }; 309 | 8E8DE1E11F4A820B00B1F926 /* Release */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 313 | DEVELOPMENT_TEAM = 5HGEPVJ8JL; 314 | FRAMEWORK_SEARCH_PATHS = ( 315 | "$(inherited)", 316 | "$(PROJECT_DIR)/AppDelegateExtensionsDemo", 317 | ); 318 | INFOPLIST_FILE = AppDelegateExtensionsDemo/Info.plist; 319 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 320 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 321 | PRODUCT_BUNDLE_IDENTIFIER = Mobike.AppDelegateExtensionsDemo; 322 | PRODUCT_NAME = "$(TARGET_NAME)"; 323 | }; 324 | name = Release; 325 | }; 326 | /* End XCBuildConfiguration section */ 327 | 328 | /* Begin XCConfigurationList section */ 329 | 8E8DE1C31F4A820B00B1F926 /* Build configuration list for PBXProject "AppDelegateExtensionsDemo" */ = { 330 | isa = XCConfigurationList; 331 | buildConfigurations = ( 332 | 8E8DE1DD1F4A820B00B1F926 /* Debug */, 333 | 8E8DE1DE1F4A820B00B1F926 /* Release */, 334 | ); 335 | defaultConfigurationIsVisible = 0; 336 | defaultConfigurationName = Release; 337 | }; 338 | 8E8DE1DF1F4A820B00B1F926 /* Build configuration list for PBXNativeTarget "AppDelegateExtensionsDemo" */ = { 339 | isa = XCConfigurationList; 340 | buildConfigurations = ( 341 | 8E8DE1E01F4A820B00B1F926 /* Debug */, 342 | 8E8DE1E11F4A820B00B1F926 /* Release */, 343 | ); 344 | defaultConfigurationIsVisible = 0; 345 | defaultConfigurationName = Release; 346 | }; 347 | /* End XCConfigurationList section */ 348 | }; 349 | rootObject = 8E8DE1C01F4A820B00B1F926 /* Project object */; 350 | } 351 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AppDelegateExtensionsDemo 4 | // 5 | // Created by 苏合 on 2017/8/21. 6 | // Copyright © 2017年 Mobike. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | 13 | @interface AppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | 18 | @end 19 | 20 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AppDelegateExtensionsDemo 4 | // 5 | // Created by 苏合 on 2017/8/21. 6 | // Copyright © 2017年 Mobike. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "AppDelegateExtensions.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | + (void)load 20 | { 21 | installAppDelegateExtensionsWithClass(self); 22 | } 23 | 24 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 25 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 26 | id aa = application; 27 | [self application:application openURL:aa sourceApplication:aa annotation:aa]; 28 | }); 29 | return YES; 30 | } 31 | 32 | 33 | - (void)applicationWillResignActive:(UIApplication *)application { 34 | // 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. 35 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 36 | } 37 | 38 | 39 | - (void)applicationDidEnterBackground:(UIApplication *)application { 40 | // 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. 41 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 42 | } 43 | 44 | 45 | - (void)applicationWillEnterForeground:(UIApplication *)application { 46 | // 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. 47 | } 48 | 49 | 50 | - (void)applicationDidBecomeActive:(UIApplication *)application { 51 | // 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. 52 | } 53 | 54 | 55 | - (void)applicationWillTerminate:(UIApplication *)application { 56 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 57 | } 58 | 59 | 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/AppDelegateExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegateExtensions.m 3 | // AppDelegateExtensionsDemo 4 | // 5 | // Created by 苏合 on 2017/8/21. 6 | // Copyright © 2017年 AppDelegateExtensions. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | 29 | 30 | UIKIT_EXTERN NSNotificationName const UIApplicationWillFinishLaunchingNotification; 31 | UIKIT_EXTERN NSNotificationName const UIApplicationDidRegisterUserNotificationSettingsNotification; 32 | UIKIT_EXTERN NSNotificationName const UIApplicationDidRegisterForRemoteNotificationsNotification; 33 | UIKIT_EXTERN NSNotificationName const UIApplicationDidFailToRegisterForRemoteNotificationsNotification; 34 | UIKIT_EXTERN NSNotificationName const UIApplicationDidReceiveRemoteNotification NS_DEPRECATED_IOS(3_0, 10_0, "Use UserNotifications Framework's -[UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:] or -[UNUserNotificationCenterDelegate didReceiveNotificationResponse:withCompletionHandler:] for user visible notifications and -[UIApplicationDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] for silent remote notifications"); 35 | UIKIT_EXTERN NSNotificationName const UIApplicationDidReceiveRemoteWithFetchCompletionHandlerNotification; 36 | UIKIT_EXTERN NSNotificationName const UIApplicationDidReceiveLocalNotification NS_DEPRECATED_IOS(4_0, 10_0, "Use UserNotifications Framework's -[UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:] or -[UNUserNotificationCenterDelegate didReceiveNotificationResponse:withCompletionHandler:]"); 37 | UIKIT_EXTERN NSNotificationName const UIApplicationHandleOpenURLNotification NS_DEPRECATED_IOS(2_0, 9_0, "Please use application:openURL:options:"); 38 | UIKIT_EXTERN NSNotificationName const UIApplicationOpenURLWithSourceApplicationNotification NS_DEPRECATED_IOS(2_0, 9_0, "Please use application:openURL:options:"); 39 | UIKIT_EXTERN NSNotificationName const UIApplicationOpenURLWithOptionsNotification; 40 | UIKIT_EXTERN NSNotificationName const UIApplicationContinueUserActivityNotification; 41 | UIKIT_EXTERN NSNotificationName const UIApplicationPerformActionForShortcutItemNotification; 42 | UIKIT_EXTERN NSNotificationName const UIApplicationHandleWatchKitExtensionRequestNotification; 43 | 44 | UIKIT_EXTERN NSString *const UIApplicationUserNotificationSettingsKey; 45 | UIKIT_EXTERN NSString *const UIApplicationDeviceTokenKey; 46 | UIKIT_EXTERN NSString *const UIApplicationErrorKey; 47 | UIKIT_EXTERN NSString *const UIApplicationLocalNotificationKey; 48 | UIKIT_EXTERN NSString *const UIApplicationURLOptionsKey; 49 | UIKIT_EXTERN UIApplicationOpenURLOptionsKey const UIApplicationOpenURLOptionsURLKey; 50 | UIKIT_EXTERN NSString *const UIApplicationContinueUserActivityKey; 51 | UIKIT_EXTERN NSString *const UIApplicationRestorationHandlerKey; 52 | UIKIT_EXTERN NSString *const UIApplicationShortcutItemKey; 53 | UIKIT_EXTERN NSString *const UIApplicationCompletionHandlerKey; 54 | UIKIT_EXTERN NSString *const UIApplicationWatchKitExtensionRequestUserInfoKey; 55 | UIKIT_EXTERN NSString *const UIApplicationWatchKitExtensionReplyKey; 56 | UIKIT_EXTERN NSString *const UIApplicationRemoteNoficationUserInfoKey; 57 | UIKIT_EXTERN NSString *const UIApplicationFetchCompletionHandlerKey; 58 | 59 | #if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0 60 | UIApplicationOpenURLOptionsKey const UIApplicationOpenURLOptionsSourceApplicationKey; 61 | UIApplicationOpenURLOptionsKey const UIApplicationOpenURLOptionsAnnotationKey; 62 | #endif 63 | 64 | void installAppDelegateExtensionsWithClass(Class clazz); 65 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/AppDelegateExtensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegateExtensions.m 3 | // AppDelegateExtensionsDemo 4 | // 5 | // Created by 苏合 on 2017/8/21. 6 | // Copyright © 2017年 AppDelegateExtensions. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import "AppDelegateExtensions.h" 27 | #import 28 | #import 29 | 30 | NSNotificationName const UIApplicationWillFinishLaunchingNotification = @"UIApplicationWillFinishLaunchingNotification"; 31 | NSNotificationName const UIApplicationDidRegisterUserNotificationSettingsNotification = @"UIApplicationDidRegisterUserNotificationSettingsNotification"; 32 | NSNotificationName const UIApplicationDidRegisterForRemoteNotificationsNotification = @"UIApplicationDidRegisterForRemoteNotificationsNotification"; 33 | NSNotificationName const UIApplicationDidFailToRegisterForRemoteNotificationsNotification = @"UIApplicationDidFailToRegisterForRemoteNotificationsNotification"; 34 | NSNotificationName const UIApplicationDidReceiveRemoteNotification = @"UIApplicationDidReceiveRemoteNotification"; 35 | NSNotificationName const UIApplicationDidReceiveRemoteWithFetchCompletionHandlerNotification = @"UIApplicationDidReceiveRemoteWithFetchCompletionHandlerNotification"; 36 | NSNotificationName const UIApplicationDidReceiveLocalNotification = @"UIApplicationDidReceiveLocalNotification"; 37 | NSNotificationName const UIApplicationHandleOpenURLNotification = @"UIApplicationHandleOpenURLNotification"; 38 | NSNotificationName const UIApplicationOpenURLWithSourceApplicationNotification = @"UIApplicationOpenURLWithSourceApplicationNotification"; 39 | NSNotificationName const UIApplicationOpenURLWithOptionsNotification = @"UIApplicationOpenURLWithOptionsNotification"; 40 | NSNotificationName const UIApplicationContinueUserActivityNotification = @"UIApplicationContinueUserActivityNotification"; 41 | NSNotificationName const UIApplicationPerformActionForShortcutItemNotification = @"UIApplicationPerformActionForShortcutItemNotification"; 42 | NSNotificationName const UIApplicationHandleWatchKitExtensionRequestNotification = @"UIApplicationHandleWatchKitExtensionRequestNotification"; 43 | 44 | NSString *const UIApplicationUserNotificationSettingsKey = @"UIApplicationUserNotificationSettingsKey"; 45 | NSString *const UIApplicationDeviceTokenKey = @"UIApplicationDeviceTokenKey"; 46 | NSString *const UIApplicationErrorKey = @"UIApplicationErrorKey"; 47 | NSString *const UIApplicationLocalNotificationKey = @"UIApplicationLocalNotificationKey"; 48 | NSString *const UIApplicationURLOptionsKey = @"UIApplicationURLOptionsKey"; 49 | UIApplicationOpenURLOptionsKey const UIApplicationOpenURLOptionsURLKey = @"UIApplicationOpenURLOptionsURLKey"; 50 | NSString *const UIApplicationContinueUserActivityKey = @"UIApplicationContinueUserActivityKey"; 51 | NSString *const UIApplicationRestorationHandlerKey = @"UIApplicationRestorationHandlerKey"; 52 | NSString *const UIApplicationShortcutItemKey = @"UIApplicationShortcutItemKey"; 53 | NSString *const UIApplicationCompletionHandlerKey = @"UIApplicationCompletionHandlerKey"; 54 | NSString *const UIApplicationWatchKitExtensionRequestUserInfoKey = @"UIApplicationWatchKitExtensionRequestUserInfoKey"; 55 | NSString *const UIApplicationWatchKitExtensionReplyKey = @"UIApplicationWatchKitExtensionReplyKey"; 56 | NSString *const UIApplicationRemoteNoficationUserInfoKey = @"UIApplicationRemoteNoficationUserInfoKey"; 57 | NSString *const UIApplicationFetchCompletionHandlerKey = @"UIApplicationFetchCompletionHandlerKey"; 58 | UIApplicationOpenURLOptionsKey const UIApplicationOpenURLOptionsSourceApplicationKey = @"UIApplicationOpenURLOptionsAnnotationKey"; 59 | UIApplicationOpenURLOptionsKey const UIApplicationOpenURLOptionsAnnotationKey = @"UIApplicationOpenURLOptionsAnnotationKey"; 60 | 61 | static inline BOOL isValidIMP(IMP impl) 62 | { 63 | #if defined(__arm64__) 64 | if (impl == NULL || impl == _objc_msgForward) return NO; 65 | #else 66 | if (impl == NULL || impl == _objc_msgForward || impl == (IMP)_objc_msgForward_stret) return NO; 67 | #endif 68 | return YES; 69 | } 70 | 71 | static BOOL addMethodWithIMP(Class cls, SEL oldSel, SEL newSel, IMP newIMP, const char *types, BOOL aggressive) 72 | { 73 | if (!class_addMethod(cls, oldSel, newIMP, types)) 74 | { 75 | return NO; 76 | } 77 | 78 | IMP parentIMP = NULL; 79 | Class superclass = class_getSuperclass(cls); 80 | while (superclass && !isValidIMP(parentIMP)) 81 | { 82 | parentIMP = class_getMethodImplementation(superclass, oldSel); 83 | if (isValidIMP(parentIMP)) 84 | { 85 | break; 86 | } 87 | else 88 | { 89 | parentIMP = NULL; 90 | } 91 | 92 | superclass = class_getSuperclass(superclass); 93 | } 94 | 95 | if (parentIMP) 96 | { 97 | if (aggressive) 98 | { 99 | return class_addMethod(cls, newSel, parentIMP, types); 100 | } 101 | 102 | class_replaceMethod(cls, newSel, newIMP, types); 103 | class_replaceMethod(cls, oldSel, parentIMP, types); 104 | } 105 | 106 | return YES; 107 | } 108 | 109 | static BOOL swizzleWithIMP(Class cls, SEL oldSel, SEL newSel, IMP newIMP, const char *types, BOOL aggressive) 110 | { 111 | Method origMethod = class_getInstanceMethod(cls, oldSel); 112 | 113 | BOOL ret = class_addMethod(cls, newSel, newIMP, types); 114 | Method newMethod = class_getInstanceMethod(cls, newSel); 115 | method_exchangeImplementations(origMethod, newMethod); 116 | return ret; 117 | } 118 | 119 | static SEL selectorWithPattern(const char *prefix, const char *key, const char *suffix) 120 | { 121 | size_t prefixLength = prefix ? strlen(prefix) : 0; 122 | size_t suffixLength = suffix ? strlen(suffix) : 0; 123 | 124 | char initial = key[0]; 125 | if (prefixLength) initial = (char)toupper(initial); 126 | size_t initialLength = 1; 127 | 128 | const char *rest = key + initialLength; 129 | size_t restLength = strlen(rest); 130 | 131 | char selector[prefixLength + initialLength + restLength + suffixLength + 1]; 132 | memcpy(selector, prefix, prefixLength); 133 | selector[prefixLength] = initial; 134 | memcpy(selector + prefixLength + initialLength, rest, restLength); 135 | memcpy(selector + prefixLength + initialLength + restLength, suffix, suffixLength); 136 | selector[prefixLength + initialLength + restLength + suffixLength] = '\0'; 137 | 138 | return sel_registerName(selector); 139 | } 140 | 141 | static inline SEL prefixedSelector(SEL original) { 142 | return selectorWithPattern("adext_", sel_getName(original), NULL); 143 | } 144 | 145 | #pragma clang diagnostic push 146 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" 147 | #pragma clang diagnostic ignored "-Wint-conversion" 148 | 149 | @implementation NSDictionary (AppDelegateExtensions) 150 | 151 | + (NSDictionary *)adext_selectors 152 | { 153 | NSDictionary *selectors = 154 | @{ 155 | UIApplicationWillFinishLaunchingNotification : NSStringFromSelector(@selector(application:willFinishLaunchingWithOptions:)), 156 | UIApplicationDidRegisterUserNotificationSettingsNotification : NSStringFromSelector(@selector(application:didRegisterUserNotificationSettings:)), 157 | UIApplicationDidRegisterForRemoteNotificationsNotification : NSStringFromSelector(@selector(application:didRegisterForRemoteNotificationsWithDeviceToken:)), 158 | UIApplicationDidFailToRegisterForRemoteNotificationsNotification : NSStringFromSelector(@selector(application:didFailToRegisterForRemoteNotificationsWithError:)), 159 | UIApplicationDidReceiveRemoteNotification : NSStringFromSelector(@selector(application:didReceiveRemoteNotification:)), 160 | UIApplicationDidReceiveRemoteWithFetchCompletionHandlerNotification : NSStringFromSelector(@selector(application:didReceiveRemoteNotification:fetchCompletionHandler:)), 161 | UIApplicationDidReceiveLocalNotification : NSStringFromSelector(@selector(application:didReceiveLocalNotification:)), 162 | UIApplicationHandleOpenURLNotification : NSStringFromSelector(@selector(application:handleOpenURL:)), 163 | UIApplicationOpenURLWithSourceApplicationNotification : NSStringFromSelector(@selector(application:openURL:sourceApplication:annotation:)), 164 | UIApplicationOpenURLWithOptionsNotification : NSStringFromSelector(@selector(application:openURL:options:)), 165 | UIApplicationContinueUserActivityNotification : NSStringFromSelector(@selector(application:continueUserActivity:restorationHandler:)), 166 | UIApplicationPerformActionForShortcutItemNotification : NSStringFromSelector(@selector(application:performActionForShortcutItem:completionHandler:)), 167 | UIApplicationHandleWatchKitExtensionRequestNotification : NSStringFromSelector(@selector(application:handleWatchKitExtensionRequest:reply:)), 168 | }; 169 | return selectors; 170 | } 171 | 172 | @end 173 | 174 | 175 | @implementation NSInvocation (AppDelegateExtensions) 176 | 177 | + (NSInvocation *)adext_invocationWithNotificationName:(NSNotificationName)notificationName clazz:(Class)clazz target:(id)target 178 | { 179 | SEL originalSelector = NSSelectorFromString([NSDictionary adext_selectors][notificationName]); 180 | SEL swizzledSelector = prefixedSelector(originalSelector); 181 | NSMethodSignature *signature = [clazz instanceMethodSignatureForSelector:originalSelector]; 182 | NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 183 | invocation.target = target; 184 | invocation.selector = swizzledSelector; 185 | return invocation; 186 | } 187 | 188 | - (id)adext_returnValueWithAddResult:(BOOL)addResult 189 | { 190 | id returnValue; 191 | const char *returnType = self.methodSignature.methodReturnType; 192 | if (!addResult) 193 | { 194 | [self invoke]; 195 | if( !strcmp(returnType, @encode(void))) 196 | { 197 | returnValue = nil; 198 | } 199 | else if( !strcmp(returnType, @encode(id))) 200 | { 201 | [self getReturnValue:&returnValue]; 202 | } 203 | else 204 | { 205 | NSUInteger length = [self.methodSignature methodReturnLength]; 206 | void *buffer = (void *)malloc(length); 207 | [self getReturnValue:buffer]; 208 | returnValue = [NSValue valueWithBytes:buffer objCType:returnType]; 209 | } 210 | } 211 | else 212 | { 213 | if( !strcmp(returnType, @encode(BOOL)) ) 214 | { 215 | returnValue = [NSValue valueWithBytes:"\1" objCType:returnType]; 216 | } 217 | else 218 | { 219 | returnValue = nil; 220 | } 221 | } 222 | return returnValue; 223 | } 224 | 225 | @end 226 | 227 | typedef void (^ADEXTPostNotificationBlock)(NSObject *self, va_list arguments); 228 | 229 | @interface AppDelegateExtension : NSObject 230 | 231 | @property (nonatomic, assign) BOOL addSucceeded; 232 | 233 | @end 234 | 235 | @implementation AppDelegateExtension 236 | 237 | + (NSMutableDictionary *)extensions 238 | { 239 | static dispatch_once_t onceToken; 240 | static NSMutableDictionary *extensions; 241 | dispatch_once(&onceToken, ^{ 242 | extensions = [NSMutableDictionary dictionary]; 243 | }); 244 | return extensions; 245 | } 246 | 247 | + (AppDelegateExtension *)installWithNotificationName:(NSNotificationName)notificationName clazz:(Class)clazz block:(id)block 248 | { 249 | AppDelegateExtension *extension = [AppDelegateExtension new]; 250 | SEL originalSelector = NSSelectorFromString([NSDictionary adext_selectors][notificationName]); 251 | SEL swizzledSelector = prefixedSelector(originalSelector); 252 | 253 | IMP swizzledImplementation = imp_implementationWithBlock(block); 254 | extension.addSucceeded = addMethodWithIMP(clazz, originalSelector, swizzledSelector, swizzledImplementation, "v@:@", YES); 255 | if (!extension.addSucceeded) 256 | { 257 | swizzleWithIMP(clazz, originalSelector, swizzledSelector, swizzledImplementation, "v@:@", YES); 258 | } 259 | [[self.class extensions] setObject:extension forKey:notificationName]; 260 | return extension; 261 | } 262 | 263 | @end 264 | 265 | 266 | 267 | void installAppDelegateExtensionsWithClass(Class clazz) 268 | { 269 | static dispatch_once_t onceToken; 270 | dispatch_once(&onceToken, ^{ 271 | [AppDelegateExtension installWithNotificationName:UIApplicationWillFinishLaunchingNotification clazz:clazz block:^BOOL(NSObject *self, id application, id options) { 272 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationWillFinishLaunchingNotification clazz:clazz target:self]; 273 | [invocation setArgument:&application atIndex:2]; 274 | [invocation setArgument:&options atIndex:3]; 275 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationWillFinishLaunchingNotification].addSucceeded; 276 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 277 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillFinishLaunchingNotification object:application userInfo:options]; 278 | return returnValue; 279 | }]; 280 | 281 | [AppDelegateExtension installWithNotificationName:UIApplicationDidRegisterUserNotificationSettingsNotification clazz:clazz block:^BOOL(NSObject *self, id application, id settings) { 282 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationDidRegisterUserNotificationSettingsNotification clazz:clazz target:self]; 283 | [invocation setArgument:&application atIndex:2]; 284 | [invocation setArgument:&settings atIndex:3]; 285 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationDidRegisterUserNotificationSettingsNotification].addSucceeded; 286 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 287 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidRegisterUserNotificationSettingsNotification object:application userInfo:settings ? @{UIApplicationUserNotificationSettingsKey : settings} : nil]; 288 | return returnValue; 289 | }]; 290 | 291 | [AppDelegateExtension installWithNotificationName:UIApplicationDidRegisterForRemoteNotificationsNotification clazz:clazz block:^BOOL(NSObject *self, id application, id deviceToken) { 292 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationDidRegisterForRemoteNotificationsNotification clazz:clazz target:self]; 293 | [invocation setArgument:&application atIndex:2]; 294 | [invocation setArgument:&deviceToken atIndex:3]; 295 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationDidRegisterForRemoteNotificationsNotification].addSucceeded; 296 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 297 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidRegisterForRemoteNotificationsNotification object:application userInfo:deviceToken ? @{UIApplicationDeviceTokenKey : deviceToken} : nil]; 298 | return returnValue; 299 | }]; 300 | 301 | [AppDelegateExtension installWithNotificationName:UIApplicationDidFailToRegisterForRemoteNotificationsNotification clazz:clazz block:^BOOL(NSObject *self, id application, id error) { 302 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationDidFailToRegisterForRemoteNotificationsNotification clazz:clazz target:self]; 303 | [invocation setArgument:&application atIndex:2]; 304 | [invocation setArgument:&error atIndex:3]; 305 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationDidFailToRegisterForRemoteNotificationsNotification].addSucceeded; 306 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 307 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidFailToRegisterForRemoteNotificationsNotification object:application userInfo:error ? @{UIApplicationErrorKey : error} : nil]; 308 | return returnValue; 309 | }]; 310 | 311 | [AppDelegateExtension installWithNotificationName:UIApplicationDidReceiveRemoteNotification clazz:clazz block:^BOOL(NSObject *self, id application, id remoteNotificationUserInfo) { 312 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationDidReceiveRemoteNotification clazz:clazz target:self]; 313 | [invocation setArgument:&application atIndex:2]; 314 | [invocation setArgument:&remoteNotificationUserInfo atIndex:3]; 315 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationDidReceiveRemoteNotification].addSucceeded; 316 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 317 | NSMutableDictionary *userinfo = [NSMutableDictionary dictionary]; 318 | if (remoteNotificationUserInfo) 319 | { 320 | [userinfo setObject:remoteNotificationUserInfo forKey:UIApplicationRemoteNoficationUserInfoKey]; 321 | } 322 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveRemoteNotification object:application userInfo:userinfo.count ? [userinfo copy] : nil]; 323 | return returnValue; 324 | }]; 325 | 326 | [AppDelegateExtension installWithNotificationName:UIApplicationDidReceiveRemoteWithFetchCompletionHandlerNotification clazz:clazz block:^BOOL(NSObject *self, id application, id remoteNotificationUserInfo, id fetchCompletionHandler) { 327 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationDidReceiveRemoteWithFetchCompletionHandlerNotification clazz:clazz target:self]; 328 | [invocation setArgument:&application atIndex:2]; 329 | [invocation setArgument:&remoteNotificationUserInfo atIndex:3]; 330 | [invocation setArgument:&fetchCompletionHandler atIndex:4]; 331 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationDidReceiveRemoteWithFetchCompletionHandlerNotification].addSucceeded; 332 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 333 | NSMutableDictionary *userinfo = [NSMutableDictionary dictionary]; 334 | if (remoteNotificationUserInfo) 335 | { 336 | [userinfo setObject:remoteNotificationUserInfo forKey:UIApplicationRemoteNoficationUserInfoKey]; 337 | } 338 | if (fetchCompletionHandler) 339 | { 340 | [userinfo setObject:[fetchCompletionHandler copy] forKey:UIApplicationFetchCompletionHandlerKey]; 341 | } 342 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveRemoteWithFetchCompletionHandlerNotification object:application userInfo:userinfo.count ? [userinfo copy] : nil]; 343 | return returnValue; 344 | }]; 345 | 346 | [AppDelegateExtension installWithNotificationName:UIApplicationDidReceiveLocalNotification clazz:clazz block:^BOOL(NSObject *self, id application, id localNotification) { 347 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationDidReceiveLocalNotification clazz:clazz target:self]; 348 | [invocation setArgument:&application atIndex:2]; 349 | [invocation setArgument:&localNotification atIndex:3]; 350 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationDidReceiveLocalNotification].addSucceeded; 351 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 352 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationDidReceiveLocalNotification object:application userInfo:localNotification ? @{UIApplicationLocalNotificationKey : localNotification} : nil]; 353 | return returnValue; 354 | }]; 355 | if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0) 356 | { 357 | [AppDelegateExtension installWithNotificationName:UIApplicationPerformActionForShortcutItemNotification clazz:clazz block:^BOOL(NSObject *self, id application, id item, id handler) { 358 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationPerformActionForShortcutItemNotification clazz:clazz target:self]; 359 | [invocation setArgument:&application atIndex:2]; 360 | [invocation setArgument:&item atIndex:3]; 361 | [invocation setArgument:&handler atIndex:4]; 362 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationPerformActionForShortcutItemNotification].addSucceeded; 363 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 364 | NSMutableDictionary *userinfo = [NSMutableDictionary dictionary]; 365 | if (item) 366 | { 367 | [userinfo setObject:item forKey:UIApplicationShortcutItemKey]; 368 | } 369 | if (handler) 370 | { 371 | [userinfo setObject:[handler copy] forKey:UIApplicationCompletionHandlerKey]; 372 | } 373 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationPerformActionForShortcutItemNotification object:application userInfo:[userinfo copy]]; 374 | return returnValue; 375 | }]; 376 | 377 | [AppDelegateExtension installWithNotificationName:UIApplicationOpenURLWithOptionsNotification clazz:clazz block:^BOOL(NSObject *self, id application, id url, id options) { 378 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationOpenURLWithOptionsNotification clazz:clazz target:self]; 379 | [invocation setArgument:&application atIndex:2]; 380 | [invocation setArgument:&url atIndex:3]; 381 | [invocation setArgument:&options atIndex:4]; 382 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationOpenURLWithOptionsNotification].addSucceeded; 383 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 384 | NSMutableDictionary *userinfo = [NSMutableDictionary dictionary]; 385 | if (url) 386 | { 387 | [userinfo setObject:url forKey:UIApplicationOpenURLOptionsURLKey]; 388 | } 389 | if (options) 390 | { 391 | [userinfo setObject:options forKey:UIApplicationURLOptionsKey]; 392 | } 393 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationOpenURLWithOptionsNotification object:application userInfo:[userinfo copy]]; 394 | return returnValue; 395 | }]; 396 | } 397 | else 398 | { 399 | [AppDelegateExtension installWithNotificationName:UIApplicationHandleOpenURLNotification clazz:clazz block:^BOOL(NSObject *self, id application, id url) { 400 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationHandleOpenURLNotification clazz:clazz target:self]; 401 | [invocation setArgument:&application atIndex:2]; 402 | [invocation setArgument:&url atIndex:3]; 403 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationHandleOpenURLNotification].addSucceeded; 404 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 405 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationHandleOpenURLNotification object:application userInfo:url ? @{UIApplicationOpenURLOptionsURLKey : url} : nil]; 406 | return returnValue; 407 | }]; 408 | 409 | [AppDelegateExtension installWithNotificationName:UIApplicationOpenURLWithSourceApplicationNotification clazz:clazz block:^BOOL(NSObject *self, id application, id url, id sourceApplication, id annotation) { 410 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationOpenURLWithSourceApplicationNotification clazz:clazz target:self]; 411 | [invocation setArgument:&application atIndex:2]; 412 | [invocation setArgument:&url atIndex:3]; 413 | [invocation setArgument:&sourceApplication atIndex:4]; 414 | [invocation setArgument:&annotation atIndex:5]; 415 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationOpenURLWithSourceApplicationNotification].addSucceeded; 416 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 417 | NSMutableDictionary *userinfo = [NSMutableDictionary dictionary]; 418 | if (url) 419 | { 420 | [userinfo setObject:url forKey:UIApplicationOpenURLOptionsURLKey]; 421 | } 422 | if (sourceApplication) 423 | { 424 | [userinfo setObject:sourceApplication forKey:UIApplicationOpenURLOptionsSourceApplicationKey]; 425 | } 426 | if (annotation) 427 | { 428 | [userinfo setObject:annotation forKey:UIApplicationOpenURLOptionsAnnotationKey]; 429 | } 430 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationOpenURLWithSourceApplicationNotification object:application userInfo:userinfo.count ? [userinfo copy] : nil]; 431 | return returnValue; 432 | }]; 433 | } 434 | 435 | [AppDelegateExtension installWithNotificationName:UIApplicationContinueUserActivityNotification clazz:clazz block:^BOOL(NSObject *self, id application, id userActivity, id restorationHandler) { 436 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationContinueUserActivityNotification clazz:clazz target:self]; 437 | [invocation setArgument:&application atIndex:2]; 438 | [invocation setArgument:&userActivity atIndex:3]; 439 | [invocation setArgument:&restorationHandler atIndex:4]; 440 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationContinueUserActivityNotification].addSucceeded; 441 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 442 | NSMutableDictionary *userinfo = [NSMutableDictionary dictionary]; 443 | if (userActivity) 444 | { 445 | [userinfo setObject:userActivity forKey:UIApplicationContinueUserActivityKey]; 446 | } 447 | if (restorationHandler) 448 | { 449 | [userinfo setObject:[restorationHandler copy] forKey:UIApplicationRestorationHandlerKey]; 450 | } 451 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationContinueUserActivityNotification object:application userInfo:[userinfo copy]]; 452 | return returnValue; 453 | }]; 454 | if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.2) 455 | { 456 | [AppDelegateExtension installWithNotificationName:UIApplicationHandleWatchKitExtensionRequestNotification clazz:clazz block:^BOOL(NSObject *self, id application, id userInfo, id reply) { 457 | NSInvocation *invocation = [NSInvocation adext_invocationWithNotificationName:UIApplicationHandleWatchKitExtensionRequestNotification clazz:clazz target:self]; 458 | [invocation setArgument:&application atIndex:2]; 459 | [invocation setArgument:&userInfo atIndex:3]; 460 | [invocation setArgument:&reply atIndex:4]; 461 | BOOL addSucceeded = [AppDelegateExtension extensions][UIApplicationHandleWatchKitExtensionRequestNotification].addSucceeded; 462 | id returnValue = [invocation adext_returnValueWithAddResult:addSucceeded]; 463 | NSMutableDictionary *userinfo = [NSMutableDictionary dictionary]; 464 | if (userInfo) 465 | { 466 | [userinfo setObject:userInfo forKey:UIApplicationWatchKitExtensionRequestUserInfoKey]; 467 | } 468 | if (reply) 469 | { 470 | [userinfo setObject:reply forKey:UIApplicationWatchKitExtensionReplyKey]; 471 | } 472 | [[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationHandleWatchKitExtensionRequestNotification object:application userInfo:[userinfo copy]]; 473 | return returnValue; 474 | }]; 475 | } 476 | }); 477 | } 478 | 479 | #pragma clang diagnostic pop 480 | 481 | 482 | 483 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/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 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/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 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | 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 | 38 | 39 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AppDelegateExtensionsDemo 4 | // 5 | // Created by 苏合 on 2017/8/21. 6 | // Copyright © 2017年 Mobike. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // AppDelegateExtensionsDemo 4 | // 5 | // Created by 苏合 on 2017/8/21. 6 | // Copyright © 2017年 Mobike. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "AppDelegateExtensions.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | 22 | // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle:) name:UIApplicationDidFinishLaunchingNotification object:nil]; 23 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle:) name:UIApplicationOpenURLWithSourceApplicationNotification object:nil]; 24 | } 25 | 26 | 27 | - (void)didReceiveMemoryWarning { 28 | [super didReceiveMemoryWarning]; 29 | // Dispose of any resources that can be recreated. 30 | } 31 | 32 | - (void)handle:(NSNotification *)noti 33 | { 34 | 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /AppDelegateExtensions/AppDelegateExtensionsDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AppDelegateExtensionsDemo 4 | // 5 | // Created by 苏合 on 2017/8/21. 6 | // Copyright © 2017年 Mobike. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AppdelegateExtension.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint AppdelegateExtension.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "AppdelegateExtension" 19 | s.version = "0.1.0" 20 | s.summary = "使用通知和runtime-AOP的为AppDelegate瘦身方案." 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = "使用通知和runtime-AOP的为AppDelegate瘦身方案." 28 | 29 | s.homepage = "https://github.com/jiaopen/AppDelegateExtensions" 30 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 31 | 32 | 33 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 34 | # 35 | # Licensing your code is important. See http://choosealicense.com for more info. 36 | # CocoaPods will detect a license file if there is a named LICENSE* 37 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 38 | # 39 | 40 | s.license = "MIT" 41 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 42 | 43 | 44 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 45 | # 46 | # Specify the authors of the library, with email addresses. Email addresses 47 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 48 | # accepts just a name if you'd rather not provide an email address. 49 | # 50 | # Specify a social_media_url where others can refer to, for example a twitter 51 | # profile URL. 52 | # 53 | 54 | s.author = { "Zip Lee" => "54459708@qq.com" } 55 | # Or just: s.author = "Zip Lee" 56 | # s.authors = { "Zip Lee" => "54459708@qq.com" } 57 | # s.social_media_url = "http://twitter.com/Zip Lee" 58 | 59 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 60 | # 61 | # If this Pod runs only on iOS or OS X, then specify the platform and 62 | # the deployment target. You can optionally include the target after the platform. 63 | # 64 | 65 | # s.platform = :ios 66 | s.platform = :ios, "8.0" 67 | 68 | # When using multiple platforms 69 | # s.ios.deployment_target = "5.0" 70 | # s.osx.deployment_target = "10.7" 71 | # s.watchos.deployment_target = "2.0" 72 | # s.tvos.deployment_target = "9.0" 73 | 74 | 75 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 76 | # 77 | # Specify the location from where the source should be retrieved. 78 | # Supports git, hg, bzr, svn and HTTP. 79 | # 80 | 81 | s.source = { :git => "https://github.com/jiaopen/AppDelegateExtensions.git", :tag => "#{s.version}" } 82 | 83 | 84 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 85 | # 86 | # CocoaPods is smart about how it includes source code. For source files 87 | # giving a folder will include any swift, h, m, mm, c & cpp files. 88 | # For header files it will include any header in the folder. 89 | # Not including the public_header_files will make all headers public. 90 | # 91 | 92 | s.source_files = "AppDelegateExtensions/AppDelegateExtensionsDemo/AppDelegateExtensions.{h,m}" 93 | # s.public_header_files = "Classes/**/*.h" 94 | 95 | 96 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 97 | # 98 | # A list of resources included with the Pod. These are copied into the 99 | # target bundle with a build phase script. Anything else will be cleaned. 100 | # You can preserve files from being cleaned, please don't preserve 101 | # non-essential files like tests, examples and documentation. 102 | # 103 | 104 | # s.resource = "icon.png" 105 | # s.resources = "Resources/*.png" 106 | 107 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 108 | 109 | 110 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 111 | # 112 | # Link your library with frameworks, or libraries. Libraries do not include 113 | # the lib prefix of their name. 114 | # 115 | 116 | # s.framework = "SomeFramework" 117 | # s.frameworks = "SomeFramework", "AnotherFramework" 118 | 119 | # s.library = "iconv" 120 | # s.libraries = "iconv", "xml2" 121 | 122 | 123 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 124 | # 125 | # If your library depends on compiler flags you can set them in the xcconfig hash 126 | # where they will only apply to your library. If you depend on other Podspecs 127 | # you can include multiple dependencies to ensure it works. 128 | 129 | # s.requires_arc = true 130 | 131 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 132 | # s.dependency "JSONKit", "~> 1.4" 133 | 134 | end 135 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AppDelegateExtension 2 | 使用通知和runtime-AOP的为AppDelegate瘦身方案 3 | 4 | ### 使用姿势 5 | objective-C的工程 6 | 7 | main.m: 8 | 9 | ```objc 10 | int main(int argc, char * argv[]) { 11 | @autoreleasepool { 12 | installAppDelegateExtensionsWithClass([AppDelegate class]); 13 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 14 | } 15 | } 16 | ``` 17 | 18 | swift的工程 19 | 20 | 1.删除AppDelegate.swift中的@UIApplicationMain 21 | 22 | 2.添加main.swift到工程里并添加: 23 | 24 | ```swift 25 | installAppDelegateExtensionsWithClass(AppDelegate.self) 26 | 27 | UIApplicationMain( 28 | CommandLine.argc, 29 | UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to: UnsafeMutablePointer.self, capacity: Int(CommandLine.argc)), 30 | nil, 31 | NSStringFromClass(AppDelegate.self) 32 | ) 33 | ``` 34 | 35 | 添加了以下这些Notification key 36 | 37 | ```objc 38 | UIKIT_EXTERN NSNotificationName const UIApplicationDidRegisterUserNotificationSettingsNotification; 39 | UIKIT_EXTERN NSNotificationName const UIApplicationDidRegisterForRemoteNotificationsNotification; 40 | UIKIT_EXTERN NSNotificationName const UIApplicationDidFailToRegisterForRemoteNotificationsNotification; 41 | UIKIT_EXTERN NSNotificationName const UIApplicationDidReceiveRemoteNotification NS_DEPRECATED_IOS(3_0, 10_0, "Use UserNotifications Framework's -[UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:] or -[UNUserNotificationCenterDelegate didReceiveNotificationResponse:withCompletionHandler:] for user visible notifications and -[UIApplicationDelegate application:didReceiveRemoteNotification:fetchCompletionHandler:] for silent remote notifications"); 42 | UIKIT_EXTERN NSNotificationName const UIApplicationDidReceiveLocalNotification NS_DEPRECATED_IOS(4_0, 10_0, "Use UserNotifications Framework's -[UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:] or -[UNUserNotificationCenterDelegate didReceiveNotificationResponse:withCompletionHandler:]"); 43 | UIKIT_EXTERN NSNotificationName const UIApplicationHandleOpenURLNotification NS_DEPRECATED_IOS(2_0, 9_0, "Please use application:openURL:options:"); 44 | UIKIT_EXTERN NSNotificationName const UIApplicationOpenURLWithSourceApplicationNotification NS_DEPRECATED_IOS(2_0, 9_0, "Please use application:openURL:options:"); 45 | UIKIT_EXTERN NSNotificationName const UIApplicationOpenURLWithOptionsNotification; 46 | UIKIT_EXTERN NSNotificationName const UIApplicationContinueUserActivityNotification; 47 | UIKIT_EXTERN NSNotificationName const UIApplicationPerformActionForShortcutItemNotification; 48 | UIKIT_EXTERN NSNotificationName const UIApplicationHandleWatchKitExtensionRequestNotification; 49 | ``` 50 | 51 | ### Features: 52 | - AOP没有使用category来实现methodswizzle,因为不是所有工程的`AppDelegate`起名相同,因此需要在`load`中显式调用一行注册代码。 53 | - 增加了常用的`UIApplicationDelegate`方法对应的通知,可以根据自已业务的情况补充。 54 | 55 | 56 | 具体细节:http://www.jianshu.com/p/a926fd605b7a 57 | 58 | 代码中参考了BlocksKit和libextobjc的实现,感谢两位大神的精彩code 59 | 60 | #### Podfile 61 | 62 | 可以使用cocoapods集成 63 | 64 | ```ruby 65 | pod 'AppDelegateExtension', '~> 0.1.0' 66 | 67 | ``` 68 | --------------------------------------------------------------------------------