├── README.md ├── checkVersion.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── xiejiwei.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── xiejiwei.xcuserdatad │ └── xcschemes │ ├── checkVersion.xcscheme │ └── xcschememanagement.plist ├── checkVersion ├── AppDelegate.h ├── AppDelegate.m ├── AppleStoreModel.h ├── AppleStoreModel.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── checkVersionManager.h ├── checkVersionManager.m └── main.m ├── checkVersionTests ├── Info.plist └── checkVersionTests.m └── checkVersionUITests ├── Info.plist └── checkVersionUITests.m /README.md: -------------------------------------------------------------------------------- 1 | # checkAPPVersion 2 | 高度封装苹果API,提示版本更新,支持用户自定义弹窗 3 | 4 | 简书地址 http://www.jianshu.com/p/68b56062980e 5 | -------------------------------------------------------------------------------- /checkVersion.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6FB2F7B01EA90E9B00FDFF67 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FB2F7AF1EA90E9B00FDFF67 /* main.m */; }; 11 | 6FB2F7B31EA90E9B00FDFF67 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FB2F7B21EA90E9B00FDFF67 /* AppDelegate.m */; }; 12 | 6FB2F7B61EA90E9B00FDFF67 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FB2F7B51EA90E9B00FDFF67 /* ViewController.m */; }; 13 | 6FB2F7B91EA90E9B00FDFF67 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6FB2F7B71EA90E9B00FDFF67 /* Main.storyboard */; }; 14 | 6FB2F7BB1EA90E9B00FDFF67 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6FB2F7BA1EA90E9B00FDFF67 /* Assets.xcassets */; }; 15 | 6FB2F7BE1EA90E9B00FDFF67 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6FB2F7BC1EA90E9B00FDFF67 /* LaunchScreen.storyboard */; }; 16 | 6FB2F7C91EA90E9B00FDFF67 /* checkVersionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FB2F7C81EA90E9B00FDFF67 /* checkVersionTests.m */; }; 17 | 6FB2F7D41EA90E9B00FDFF67 /* checkVersionUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FB2F7D31EA90E9B00FDFF67 /* checkVersionUITests.m */; }; 18 | 6FB2F7E31EA90EB900FDFF67 /* AppleStoreModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FB2F7E21EA90EB900FDFF67 /* AppleStoreModel.m */; }; 19 | 6FB2F7E61EA90F0E00FDFF67 /* checkVersionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FB2F7E51EA90F0E00FDFF67 /* checkVersionManager.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 6FB2F7C51EA90E9B00FDFF67 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 6FB2F7A31EA90E9B00FDFF67 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 6FB2F7AA1EA90E9B00FDFF67; 28 | remoteInfo = checkVersion; 29 | }; 30 | 6FB2F7D01EA90E9B00FDFF67 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 6FB2F7A31EA90E9B00FDFF67 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 6FB2F7AA1EA90E9B00FDFF67; 35 | remoteInfo = checkVersion; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 6FB2F7AB1EA90E9B00FDFF67 /* checkVersion.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = checkVersion.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 6FB2F7AF1EA90E9B00FDFF67 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 42 | 6FB2F7B11EA90E9B00FDFF67 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 43 | 6FB2F7B21EA90E9B00FDFF67 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 44 | 6FB2F7B41EA90E9B00FDFF67 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 45 | 6FB2F7B51EA90E9B00FDFF67 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 46 | 6FB2F7B81EA90E9B00FDFF67 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 47 | 6FB2F7BA1EA90E9B00FDFF67 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 48 | 6FB2F7BD1EA90E9B00FDFF67 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 49 | 6FB2F7BF1EA90E9B00FDFF67 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | 6FB2F7C41EA90E9B00FDFF67 /* checkVersionTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = checkVersionTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 6FB2F7C81EA90E9B00FDFF67 /* checkVersionTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = checkVersionTests.m; sourceTree = ""; }; 52 | 6FB2F7CA1EA90E9B00FDFF67 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | 6FB2F7CF1EA90E9B00FDFF67 /* checkVersionUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = checkVersionUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 6FB2F7D31EA90E9B00FDFF67 /* checkVersionUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = checkVersionUITests.m; sourceTree = ""; }; 55 | 6FB2F7D51EA90E9B00FDFF67 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 6FB2F7E11EA90EB900FDFF67 /* AppleStoreModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleStoreModel.h; sourceTree = ""; }; 57 | 6FB2F7E21EA90EB900FDFF67 /* AppleStoreModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppleStoreModel.m; sourceTree = ""; }; 58 | 6FB2F7E41EA90F0E00FDFF67 /* checkVersionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = checkVersionManager.h; sourceTree = ""; }; 59 | 6FB2F7E51EA90F0E00FDFF67 /* checkVersionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = checkVersionManager.m; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 6FB2F7A81EA90E9B00FDFF67 /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | 6FB2F7C11EA90E9B00FDFF67 /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | 6FB2F7CC1EA90E9B00FDFF67 /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | /* End PBXFrameworksBuildPhase section */ 85 | 86 | /* Begin PBXGroup section */ 87 | 6FB2F7A21EA90E9B00FDFF67 = { 88 | isa = PBXGroup; 89 | children = ( 90 | 6FB2F7AD1EA90E9B00FDFF67 /* checkVersion */, 91 | 6FB2F7C71EA90E9B00FDFF67 /* checkVersionTests */, 92 | 6FB2F7D21EA90E9B00FDFF67 /* checkVersionUITests */, 93 | 6FB2F7AC1EA90E9B00FDFF67 /* Products */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | 6FB2F7AC1EA90E9B00FDFF67 /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 6FB2F7AB1EA90E9B00FDFF67 /* checkVersion.app */, 101 | 6FB2F7C41EA90E9B00FDFF67 /* checkVersionTests.xctest */, 102 | 6FB2F7CF1EA90E9B00FDFF67 /* checkVersionUITests.xctest */, 103 | ); 104 | name = Products; 105 | sourceTree = ""; 106 | }; 107 | 6FB2F7AD1EA90E9B00FDFF67 /* checkVersion */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 6FB2F7B11EA90E9B00FDFF67 /* AppDelegate.h */, 111 | 6FB2F7B21EA90E9B00FDFF67 /* AppDelegate.m */, 112 | 6FB2F7B41EA90E9B00FDFF67 /* ViewController.h */, 113 | 6FB2F7B51EA90E9B00FDFF67 /* ViewController.m */, 114 | 6FB2F7E11EA90EB900FDFF67 /* AppleStoreModel.h */, 115 | 6FB2F7E21EA90EB900FDFF67 /* AppleStoreModel.m */, 116 | 6FB2F7E41EA90F0E00FDFF67 /* checkVersionManager.h */, 117 | 6FB2F7E51EA90F0E00FDFF67 /* checkVersionManager.m */, 118 | 6FB2F7B71EA90E9B00FDFF67 /* Main.storyboard */, 119 | 6FB2F7BA1EA90E9B00FDFF67 /* Assets.xcassets */, 120 | 6FB2F7BC1EA90E9B00FDFF67 /* LaunchScreen.storyboard */, 121 | 6FB2F7BF1EA90E9B00FDFF67 /* Info.plist */, 122 | 6FB2F7AE1EA90E9B00FDFF67 /* Supporting Files */, 123 | ); 124 | path = checkVersion; 125 | sourceTree = ""; 126 | }; 127 | 6FB2F7AE1EA90E9B00FDFF67 /* Supporting Files */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 6FB2F7AF1EA90E9B00FDFF67 /* main.m */, 131 | ); 132 | name = "Supporting Files"; 133 | sourceTree = ""; 134 | }; 135 | 6FB2F7C71EA90E9B00FDFF67 /* checkVersionTests */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | 6FB2F7C81EA90E9B00FDFF67 /* checkVersionTests.m */, 139 | 6FB2F7CA1EA90E9B00FDFF67 /* Info.plist */, 140 | ); 141 | path = checkVersionTests; 142 | sourceTree = ""; 143 | }; 144 | 6FB2F7D21EA90E9B00FDFF67 /* checkVersionUITests */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | 6FB2F7D31EA90E9B00FDFF67 /* checkVersionUITests.m */, 148 | 6FB2F7D51EA90E9B00FDFF67 /* Info.plist */, 149 | ); 150 | path = checkVersionUITests; 151 | sourceTree = ""; 152 | }; 153 | /* End PBXGroup section */ 154 | 155 | /* Begin PBXNativeTarget section */ 156 | 6FB2F7AA1EA90E9B00FDFF67 /* checkVersion */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = 6FB2F7D81EA90E9B00FDFF67 /* Build configuration list for PBXNativeTarget "checkVersion" */; 159 | buildPhases = ( 160 | 6FB2F7A71EA90E9B00FDFF67 /* Sources */, 161 | 6FB2F7A81EA90E9B00FDFF67 /* Frameworks */, 162 | 6FB2F7A91EA90E9B00FDFF67 /* Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | ); 168 | name = checkVersion; 169 | productName = checkVersion; 170 | productReference = 6FB2F7AB1EA90E9B00FDFF67 /* checkVersion.app */; 171 | productType = "com.apple.product-type.application"; 172 | }; 173 | 6FB2F7C31EA90E9B00FDFF67 /* checkVersionTests */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = 6FB2F7DB1EA90E9B00FDFF67 /* Build configuration list for PBXNativeTarget "checkVersionTests" */; 176 | buildPhases = ( 177 | 6FB2F7C01EA90E9B00FDFF67 /* Sources */, 178 | 6FB2F7C11EA90E9B00FDFF67 /* Frameworks */, 179 | 6FB2F7C21EA90E9B00FDFF67 /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | 6FB2F7C61EA90E9B00FDFF67 /* PBXTargetDependency */, 185 | ); 186 | name = checkVersionTests; 187 | productName = checkVersionTests; 188 | productReference = 6FB2F7C41EA90E9B00FDFF67 /* checkVersionTests.xctest */; 189 | productType = "com.apple.product-type.bundle.unit-test"; 190 | }; 191 | 6FB2F7CE1EA90E9B00FDFF67 /* checkVersionUITests */ = { 192 | isa = PBXNativeTarget; 193 | buildConfigurationList = 6FB2F7DE1EA90E9B00FDFF67 /* Build configuration list for PBXNativeTarget "checkVersionUITests" */; 194 | buildPhases = ( 195 | 6FB2F7CB1EA90E9B00FDFF67 /* Sources */, 196 | 6FB2F7CC1EA90E9B00FDFF67 /* Frameworks */, 197 | 6FB2F7CD1EA90E9B00FDFF67 /* Resources */, 198 | ); 199 | buildRules = ( 200 | ); 201 | dependencies = ( 202 | 6FB2F7D11EA90E9B00FDFF67 /* PBXTargetDependency */, 203 | ); 204 | name = checkVersionUITests; 205 | productName = checkVersionUITests; 206 | productReference = 6FB2F7CF1EA90E9B00FDFF67 /* checkVersionUITests.xctest */; 207 | productType = "com.apple.product-type.bundle.ui-testing"; 208 | }; 209 | /* End PBXNativeTarget section */ 210 | 211 | /* Begin PBXProject section */ 212 | 6FB2F7A31EA90E9B00FDFF67 /* Project object */ = { 213 | isa = PBXProject; 214 | attributes = { 215 | LastUpgradeCheck = 0800; 216 | ORGANIZATIONNAME = cn.com.rockmobile; 217 | TargetAttributes = { 218 | 6FB2F7AA1EA90E9B00FDFF67 = { 219 | CreatedOnToolsVersion = 8.0; 220 | DevelopmentTeam = 593SK39KEK; 221 | ProvisioningStyle = Automatic; 222 | }; 223 | 6FB2F7C31EA90E9B00FDFF67 = { 224 | CreatedOnToolsVersion = 8.0; 225 | DevelopmentTeam = 593SK39KEK; 226 | ProvisioningStyle = Automatic; 227 | TestTargetID = 6FB2F7AA1EA90E9B00FDFF67; 228 | }; 229 | 6FB2F7CE1EA90E9B00FDFF67 = { 230 | CreatedOnToolsVersion = 8.0; 231 | DevelopmentTeam = 593SK39KEK; 232 | ProvisioningStyle = Automatic; 233 | TestTargetID = 6FB2F7AA1EA90E9B00FDFF67; 234 | }; 235 | }; 236 | }; 237 | buildConfigurationList = 6FB2F7A61EA90E9B00FDFF67 /* Build configuration list for PBXProject "checkVersion" */; 238 | compatibilityVersion = "Xcode 3.2"; 239 | developmentRegion = English; 240 | hasScannedForEncodings = 0; 241 | knownRegions = ( 242 | en, 243 | Base, 244 | ); 245 | mainGroup = 6FB2F7A21EA90E9B00FDFF67; 246 | productRefGroup = 6FB2F7AC1EA90E9B00FDFF67 /* Products */; 247 | projectDirPath = ""; 248 | projectRoot = ""; 249 | targets = ( 250 | 6FB2F7AA1EA90E9B00FDFF67 /* checkVersion */, 251 | 6FB2F7C31EA90E9B00FDFF67 /* checkVersionTests */, 252 | 6FB2F7CE1EA90E9B00FDFF67 /* checkVersionUITests */, 253 | ); 254 | }; 255 | /* End PBXProject section */ 256 | 257 | /* Begin PBXResourcesBuildPhase section */ 258 | 6FB2F7A91EA90E9B00FDFF67 /* Resources */ = { 259 | isa = PBXResourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | 6FB2F7BE1EA90E9B00FDFF67 /* LaunchScreen.storyboard in Resources */, 263 | 6FB2F7BB1EA90E9B00FDFF67 /* Assets.xcassets in Resources */, 264 | 6FB2F7B91EA90E9B00FDFF67 /* Main.storyboard in Resources */, 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | 6FB2F7C21EA90E9B00FDFF67 /* Resources */ = { 269 | isa = PBXResourcesBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | 6FB2F7CD1EA90E9B00FDFF67 /* Resources */ = { 276 | isa = PBXResourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | }; 282 | /* End PBXResourcesBuildPhase section */ 283 | 284 | /* Begin PBXSourcesBuildPhase section */ 285 | 6FB2F7A71EA90E9B00FDFF67 /* Sources */ = { 286 | isa = PBXSourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | 6FB2F7E31EA90EB900FDFF67 /* AppleStoreModel.m in Sources */, 290 | 6FB2F7E61EA90F0E00FDFF67 /* checkVersionManager.m in Sources */, 291 | 6FB2F7B61EA90E9B00FDFF67 /* ViewController.m in Sources */, 292 | 6FB2F7B31EA90E9B00FDFF67 /* AppDelegate.m in Sources */, 293 | 6FB2F7B01EA90E9B00FDFF67 /* main.m in Sources */, 294 | ); 295 | runOnlyForDeploymentPostprocessing = 0; 296 | }; 297 | 6FB2F7C01EA90E9B00FDFF67 /* Sources */ = { 298 | isa = PBXSourcesBuildPhase; 299 | buildActionMask = 2147483647; 300 | files = ( 301 | 6FB2F7C91EA90E9B00FDFF67 /* checkVersionTests.m in Sources */, 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | 6FB2F7CB1EA90E9B00FDFF67 /* Sources */ = { 306 | isa = PBXSourcesBuildPhase; 307 | buildActionMask = 2147483647; 308 | files = ( 309 | 6FB2F7D41EA90E9B00FDFF67 /* checkVersionUITests.m in Sources */, 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | }; 313 | /* End PBXSourcesBuildPhase section */ 314 | 315 | /* Begin PBXTargetDependency section */ 316 | 6FB2F7C61EA90E9B00FDFF67 /* PBXTargetDependency */ = { 317 | isa = PBXTargetDependency; 318 | target = 6FB2F7AA1EA90E9B00FDFF67 /* checkVersion */; 319 | targetProxy = 6FB2F7C51EA90E9B00FDFF67 /* PBXContainerItemProxy */; 320 | }; 321 | 6FB2F7D11EA90E9B00FDFF67 /* PBXTargetDependency */ = { 322 | isa = PBXTargetDependency; 323 | target = 6FB2F7AA1EA90E9B00FDFF67 /* checkVersion */; 324 | targetProxy = 6FB2F7D01EA90E9B00FDFF67 /* PBXContainerItemProxy */; 325 | }; 326 | /* End PBXTargetDependency section */ 327 | 328 | /* Begin PBXVariantGroup section */ 329 | 6FB2F7B71EA90E9B00FDFF67 /* Main.storyboard */ = { 330 | isa = PBXVariantGroup; 331 | children = ( 332 | 6FB2F7B81EA90E9B00FDFF67 /* Base */, 333 | ); 334 | name = Main.storyboard; 335 | sourceTree = ""; 336 | }; 337 | 6FB2F7BC1EA90E9B00FDFF67 /* LaunchScreen.storyboard */ = { 338 | isa = PBXVariantGroup; 339 | children = ( 340 | 6FB2F7BD1EA90E9B00FDFF67 /* Base */, 341 | ); 342 | name = LaunchScreen.storyboard; 343 | sourceTree = ""; 344 | }; 345 | /* End PBXVariantGroup section */ 346 | 347 | /* Begin XCBuildConfiguration section */ 348 | 6FB2F7D61EA90E9B00FDFF67 /* Debug */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CLANG_ANALYZER_NONNULL = YES; 353 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 354 | CLANG_CXX_LIBRARY = "libc++"; 355 | CLANG_ENABLE_MODULES = YES; 356 | CLANG_ENABLE_OBJC_ARC = YES; 357 | CLANG_WARN_BOOL_CONVERSION = YES; 358 | CLANG_WARN_CONSTANT_CONVERSION = YES; 359 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 360 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 361 | CLANG_WARN_EMPTY_BODY = YES; 362 | CLANG_WARN_ENUM_CONVERSION = YES; 363 | CLANG_WARN_INFINITE_RECURSION = YES; 364 | CLANG_WARN_INT_CONVERSION = YES; 365 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 366 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 367 | CLANG_WARN_UNREACHABLE_CODE = YES; 368 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 369 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 370 | COPY_PHASE_STRIP = NO; 371 | DEBUG_INFORMATION_FORMAT = dwarf; 372 | ENABLE_STRICT_OBJC_MSGSEND = YES; 373 | ENABLE_TESTABILITY = YES; 374 | GCC_C_LANGUAGE_STANDARD = gnu99; 375 | GCC_DYNAMIC_NO_PIC = NO; 376 | GCC_NO_COMMON_BLOCKS = YES; 377 | GCC_OPTIMIZATION_LEVEL = 0; 378 | GCC_PREPROCESSOR_DEFINITIONS = ( 379 | "DEBUG=1", 380 | "$(inherited)", 381 | ); 382 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 383 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 384 | GCC_WARN_UNDECLARED_SELECTOR = YES; 385 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 386 | GCC_WARN_UNUSED_FUNCTION = YES; 387 | GCC_WARN_UNUSED_VARIABLE = YES; 388 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 389 | MTL_ENABLE_DEBUG_INFO = YES; 390 | ONLY_ACTIVE_ARCH = YES; 391 | SDKROOT = iphoneos; 392 | }; 393 | name = Debug; 394 | }; 395 | 6FB2F7D71EA90E9B00FDFF67 /* Release */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | ALWAYS_SEARCH_USER_PATHS = NO; 399 | CLANG_ANALYZER_NONNULL = YES; 400 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 401 | CLANG_CXX_LIBRARY = "libc++"; 402 | CLANG_ENABLE_MODULES = YES; 403 | CLANG_ENABLE_OBJC_ARC = YES; 404 | CLANG_WARN_BOOL_CONVERSION = YES; 405 | CLANG_WARN_CONSTANT_CONVERSION = YES; 406 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 407 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 408 | CLANG_WARN_EMPTY_BODY = YES; 409 | CLANG_WARN_ENUM_CONVERSION = YES; 410 | CLANG_WARN_INFINITE_RECURSION = YES; 411 | CLANG_WARN_INT_CONVERSION = YES; 412 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 413 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 414 | CLANG_WARN_UNREACHABLE_CODE = YES; 415 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 416 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 417 | COPY_PHASE_STRIP = NO; 418 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 419 | ENABLE_NS_ASSERTIONS = NO; 420 | ENABLE_STRICT_OBJC_MSGSEND = YES; 421 | GCC_C_LANGUAGE_STANDARD = gnu99; 422 | GCC_NO_COMMON_BLOCKS = YES; 423 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 424 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 425 | GCC_WARN_UNDECLARED_SELECTOR = YES; 426 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 427 | GCC_WARN_UNUSED_FUNCTION = YES; 428 | GCC_WARN_UNUSED_VARIABLE = YES; 429 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 430 | MTL_ENABLE_DEBUG_INFO = NO; 431 | SDKROOT = iphoneos; 432 | VALIDATE_PRODUCT = YES; 433 | }; 434 | name = Release; 435 | }; 436 | 6FB2F7D91EA90E9B00FDFF67 /* Debug */ = { 437 | isa = XCBuildConfiguration; 438 | buildSettings = { 439 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 440 | DEVELOPMENT_TEAM = 593SK39KEK; 441 | INFOPLIST_FILE = checkVersion/Info.plist; 442 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 443 | PRODUCT_BUNDLE_IDENTIFIER = cn.com.rockmobile.xie.checkVersion; 444 | PRODUCT_NAME = "$(TARGET_NAME)"; 445 | }; 446 | name = Debug; 447 | }; 448 | 6FB2F7DA1EA90E9B00FDFF67 /* Release */ = { 449 | isa = XCBuildConfiguration; 450 | buildSettings = { 451 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 452 | DEVELOPMENT_TEAM = 593SK39KEK; 453 | INFOPLIST_FILE = checkVersion/Info.plist; 454 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 455 | PRODUCT_BUNDLE_IDENTIFIER = cn.com.rockmobile.xie.checkVersion; 456 | PRODUCT_NAME = "$(TARGET_NAME)"; 457 | }; 458 | name = Release; 459 | }; 460 | 6FB2F7DC1EA90E9B00FDFF67 /* Debug */ = { 461 | isa = XCBuildConfiguration; 462 | buildSettings = { 463 | BUNDLE_LOADER = "$(TEST_HOST)"; 464 | DEVELOPMENT_TEAM = 593SK39KEK; 465 | INFOPLIST_FILE = checkVersionTests/Info.plist; 466 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 467 | PRODUCT_BUNDLE_IDENTIFIER = cn.com.rockmobile.xie.checkVersionTests; 468 | PRODUCT_NAME = "$(TARGET_NAME)"; 469 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/checkVersion.app/checkVersion"; 470 | }; 471 | name = Debug; 472 | }; 473 | 6FB2F7DD1EA90E9B00FDFF67 /* Release */ = { 474 | isa = XCBuildConfiguration; 475 | buildSettings = { 476 | BUNDLE_LOADER = "$(TEST_HOST)"; 477 | DEVELOPMENT_TEAM = 593SK39KEK; 478 | INFOPLIST_FILE = checkVersionTests/Info.plist; 479 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 480 | PRODUCT_BUNDLE_IDENTIFIER = cn.com.rockmobile.xie.checkVersionTests; 481 | PRODUCT_NAME = "$(TARGET_NAME)"; 482 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/checkVersion.app/checkVersion"; 483 | }; 484 | name = Release; 485 | }; 486 | 6FB2F7DF1EA90E9B00FDFF67 /* Debug */ = { 487 | isa = XCBuildConfiguration; 488 | buildSettings = { 489 | DEVELOPMENT_TEAM = 593SK39KEK; 490 | INFOPLIST_FILE = checkVersionUITests/Info.plist; 491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 492 | PRODUCT_BUNDLE_IDENTIFIER = cn.com.rockmobile.xie.checkVersionUITests; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | TEST_TARGET_NAME = checkVersion; 495 | }; 496 | name = Debug; 497 | }; 498 | 6FB2F7E01EA90E9B00FDFF67 /* Release */ = { 499 | isa = XCBuildConfiguration; 500 | buildSettings = { 501 | DEVELOPMENT_TEAM = 593SK39KEK; 502 | INFOPLIST_FILE = checkVersionUITests/Info.plist; 503 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 504 | PRODUCT_BUNDLE_IDENTIFIER = cn.com.rockmobile.xie.checkVersionUITests; 505 | PRODUCT_NAME = "$(TARGET_NAME)"; 506 | TEST_TARGET_NAME = checkVersion; 507 | }; 508 | name = Release; 509 | }; 510 | /* End XCBuildConfiguration section */ 511 | 512 | /* Begin XCConfigurationList section */ 513 | 6FB2F7A61EA90E9B00FDFF67 /* Build configuration list for PBXProject "checkVersion" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | 6FB2F7D61EA90E9B00FDFF67 /* Debug */, 517 | 6FB2F7D71EA90E9B00FDFF67 /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | 6FB2F7D81EA90E9B00FDFF67 /* Build configuration list for PBXNativeTarget "checkVersion" */ = { 523 | isa = XCConfigurationList; 524 | buildConfigurations = ( 525 | 6FB2F7D91EA90E9B00FDFF67 /* Debug */, 526 | 6FB2F7DA1EA90E9B00FDFF67 /* Release */, 527 | ); 528 | defaultConfigurationIsVisible = 0; 529 | }; 530 | 6FB2F7DB1EA90E9B00FDFF67 /* Build configuration list for PBXNativeTarget "checkVersionTests" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | 6FB2F7DC1EA90E9B00FDFF67 /* Debug */, 534 | 6FB2F7DD1EA90E9B00FDFF67 /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | }; 538 | 6FB2F7DE1EA90E9B00FDFF67 /* Build configuration list for PBXNativeTarget "checkVersionUITests" */ = { 539 | isa = XCConfigurationList; 540 | buildConfigurations = ( 541 | 6FB2F7DF1EA90E9B00FDFF67 /* Debug */, 542 | 6FB2F7E01EA90E9B00FDFF67 /* Release */, 543 | ); 544 | defaultConfigurationIsVisible = 0; 545 | }; 546 | /* End XCConfigurationList section */ 547 | }; 548 | rootObject = 6FB2F7A31EA90E9B00FDFF67 /* Project object */; 549 | } 550 | -------------------------------------------------------------------------------- /checkVersion.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /checkVersion.xcodeproj/project.xcworkspace/xcuserdata/xiejiwei.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/china-xie/checkAPPVersion/43b49de0ae66e8d603caf7ce35bf713cb9a72e27/checkVersion.xcodeproj/project.xcworkspace/xcuserdata/xiejiwei.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /checkVersion.xcodeproj/xcuserdata/xiejiwei.xcuserdatad/xcschemes/checkVersion.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /checkVersion.xcodeproj/xcuserdata/xiejiwei.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | checkVersion.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6FB2F7AA1EA90E9B00FDFF67 16 | 17 | primary 18 | 19 | 20 | 6FB2F7C31EA90E9B00FDFF67 21 | 22 | primary 23 | 24 | 25 | 6FB2F7CE1EA90E9B00FDFF67 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /checkVersion/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // checkVersion 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /checkVersion/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // checkVersion 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // 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. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // 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. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /checkVersion/AppleStoreModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppleStoreModel.h 3 | // checkVersion 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppleStoreModel : NSObject 12 | /** 13 | * 版本号 14 | */ 15 | @property(nonatomic,copy) NSString * version; 16 | 17 | /** 18 | * 更新日志 19 | */ 20 | @property(nonatomic,copy)NSString *releaseNotes; 21 | 22 | /** 23 | * 更新时间 24 | */ 25 | @property(nonatomic,copy)NSString *currentVersionReleaseDate; 26 | 27 | 28 | /** 29 | * AppStore地址 30 | */ 31 | @property(nonatomic,copy)NSString *trackViewUrl; 32 | @end 33 | -------------------------------------------------------------------------------- /checkVersion/AppleStoreModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppleStoreModel.m 3 | // checkVersion 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import "AppleStoreModel.h" 10 | 11 | @implementation AppleStoreModel 12 | -(void)setValue:(id)value forUndefinedKey:(NSString *)key{ 13 | 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /checkVersion/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 | } -------------------------------------------------------------------------------- /checkVersion/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 | -------------------------------------------------------------------------------- /checkVersion/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 | -------------------------------------------------------------------------------- /checkVersion/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 | -------------------------------------------------------------------------------- /checkVersion/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // checkVersion 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /checkVersion/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // checkVersion 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "checkVersionManager.h" 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | [checkVersionManager checkNewEditionWithAppID:@"1177904945" ctrl:self]; 21 | 22 | [checkVersionManager checkNewEditionWithAppID:@"1177904945" CustomAlert:^(AppleStoreModel *appInfo) { 23 | 24 | }];//2种用法,自定义Alert 25 | // Do any additional setup after loading the view, typically from a nib. 26 | } 27 | 28 | 29 | - (void)didReceiveMemoryWarning { 30 | [super didReceiveMemoryWarning]; 31 | // Dispose of any resources that can be recreated. 32 | } 33 | 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /checkVersion/checkVersionManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // checkVersionManager.h 3 | // checkVersion 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @class AppleStoreModel; 12 | typedef void(^checkVersionBlock)(AppleStoreModel * appModel); 13 | @interface checkVersionManager : NSObject 14 | 15 | + (instancetype)shareManager; 16 | /** 17 | * 检测新版本(使用系统默认提示框) 18 | * 19 | * appID:应用在Store里面的ID (应用的AppStore地址里面可获取) 20 | * containCtrl: 提示框显示在哪个控制器上 21 | */ 22 | +(void)checkNewEditionWithAppID:(NSString *)appID ctrl:(UIViewController *)containCtrl; 23 | 24 | /** 25 | * 检测新版本(使用自定义提示框) 26 | * 27 | * @param appID应用在Store里面的ID (应用的AppStore地址里面可获取) 28 | * @param checkVersionBlock AppStore上版本信息回调block 29 | */ 30 | +(void)checkNewEditionWithAppID:(NSString *)appID CustomAlert:(checkVersionBlock)checkVersionBlock; 31 | @end 32 | -------------------------------------------------------------------------------- /checkVersion/checkVersionManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // checkVersionManager.m 3 | // checkVersion 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import "checkVersionManager.h" 10 | #import "AppleStoreModel.h" 11 | @interface checkVersionManager() 12 | //本地info文件 13 | @property (strong,nonatomic)NSDictionary *infoDict; 14 | 15 | @end 16 | @implementation checkVersionManager 17 | #pragma mark - 懒加载 18 | - (NSDictionary *)infoDict { 19 | if (!_infoDict) { 20 | _infoDict = [NSBundle mainBundle].infoDictionary; 21 | } 22 | return _infoDict; 23 | } 24 | 25 | #pragma mark - 单例 26 | + (instancetype)shareManager { 27 | static checkVersionManager *instance; 28 | static dispatch_once_t onceToken; 29 | dispatch_once(&onceToken, ^{ 30 | instance = [[self alloc] init]; 31 | }); 32 | return instance; 33 | } 34 | 35 | #pragma mark - API 36 | + (void)checkNewEditionWithAppID:(NSString *)appID ctrl:(UIViewController *)containCtrl { 37 | 38 | [[self shareManager] checkNewVersion:appID ctrl:containCtrl]; 39 | 40 | } 41 | 42 | +(void)checkNewEditionWithAppID:(NSString *)appID CustomAlert:(checkVersionBlock)checkVersionBlock { 43 | [[self shareManager] getAppStoreVersion:appID sucess:^(AppleStoreModel *model) { 44 | if(checkVersionBlock)checkVersionBlock(model); 45 | }]; 46 | } 47 | 48 | - (void)checkNewVersion:(NSString *)appID ctrl:(UIViewController *)containCtrl { 49 | [self getAppStoreVersion:appID sucess:^(AppleStoreModel *model) { 50 | 51 | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"有新的版本(%@)",model.version] message:model.releaseNotes preferredStyle:UIAlertControllerStyleAlert]; 52 | 53 | UIAlertAction *updateAction = [UIAlertAction actionWithTitle:@"立即升级" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 54 | [self updateRightNow:model]; 55 | }]; 56 | UIAlertAction *delayAction = [UIAlertAction actionWithTitle:@"稍后再说" style:UIAlertActionStyleDefault handler:nil]; 57 | UIAlertAction *ignoreAction = [UIAlertAction actionWithTitle:@"忽略" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 58 | [self ignoreNewVersion:model.version]; 59 | }]; 60 | 61 | [alertController addAction:updateAction]; 62 | [alertController addAction:delayAction]; 63 | [alertController addAction:ignoreAction]; 64 | [containCtrl presentViewController:alertController animated:YES completion:nil]; 65 | }]; 66 | } 67 | 68 | #pragma mark - 立即升级 69 | - (void)updateRightNow:(AppleStoreModel *)model { 70 | if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:model.trackViewUrl]]) { 71 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:model.trackViewUrl] options:@{} completionHandler:nil]; 72 | } 73 | 74 | } 75 | 76 | #pragma mark - 忽略新版本 77 | - (void)ignoreNewVersion:(NSString *)version { 78 | //保存忽略的版本号 79 | [[NSUserDefaults standardUserDefaults] setObject:version forKey:@"ingoreVersion"]; 80 | [[NSUserDefaults standardUserDefaults] synchronize]; 81 | } 82 | 83 | #pragma mark - 获取AppStore上的版本信息 84 | - (void)getAppStoreVersion:(NSString *)appID sucess:(void(^)(AppleStoreModel *))update { 85 | 86 | [self getAppStoreInfo:appID success:^(NSDictionary *respDict) { 87 | NSInteger resultCount = [respDict[@"resultCount"] integerValue]; 88 | if (resultCount == 1) { 89 | NSArray *results = respDict[@"results"]; 90 | NSDictionary *appStoreInfo = [results firstObject]; 91 | 92 | //字典转模型 93 | AppleStoreModel *model = [[AppleStoreModel alloc] init]; 94 | [model setValuesForKeysWithDictionary:appStoreInfo]; 95 | //是否提示更新 96 | BOOL result = [self isEqualEdition:model.version]; 97 | if (result) { 98 | if(update)update(model); 99 | } 100 | } else { 101 | #ifdef DEBUG 102 | NSLog(@"AppStore上面没有找到对应id的App"); 103 | #endif 104 | } 105 | }]; 106 | 107 | } 108 | 109 | #pragma mark - 返回是否提示更新 110 | -(BOOL)isEqualEdition:(NSString *)newEdition { 111 | NSString *ignoreVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"ingoreVersion"]; 112 | if([self.infoDict[@"CFBundleShortVersionString"] compare:newEdition] == NSOrderedDescending || [self.infoDict[@"CFBundleShortVersionString"] compare:newEdition] == NSOrderedSame || 113 | [ignoreVersion isEqualToString:newEdition]) { 114 | return NO; 115 | } else { 116 | return YES; 117 | } 118 | } 119 | 120 | #pragma mark - 获取AppStore的info信息 121 | - (void)getAppStoreInfo:(NSString *)appID success:(void(^)(NSDictionary *))success { 122 | 123 | NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/CN/lookup?id=%@",appID]]; 124 | [[[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { 125 | dispatch_async(dispatch_get_main_queue(), ^{ 126 | if (error == nil && data != nil && data.length > 0) { 127 | NSDictionary *respDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; 128 | if (success) { 129 | success(respDict); 130 | } 131 | } 132 | }); 133 | }] resume]; 134 | 135 | } 136 | 137 | @end 138 | -------------------------------------------------------------------------------- /checkVersion/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // checkVersion 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. 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 | -------------------------------------------------------------------------------- /checkVersionTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /checkVersionTests/checkVersionTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // checkVersionTests.m 3 | // checkVersionTests 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface checkVersionTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation checkVersionTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /checkVersionUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /checkVersionUITests/checkVersionUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // checkVersionUITests.m 3 | // checkVersionUITests 4 | // 5 | // Created by 谢纪伟 on 17/4/20. 6 | // Copyright © 2017年 cn.com.rockmobile. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface checkVersionUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation checkVersionUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------