From 5835e994567054a609bc22cf2acbc9cb50d12a6d Mon Sep 17 00:00:00 2001 From: ZY Date: Tue, 26 Nov 2013 23:35:49 +0800 Subject: [PATCH 1/4] Add cocoapods support and add string name for hardware --- README.md | 8 +++ UIDevice+HardwareModel.h | 9 +++- UIDevice+HardwareModel.m | 106 +++++++++++++++++++++++++++++++++++++++ pod.podspec | 17 +++++++ 4 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 pod.podspec diff --git a/README.md b/README.md index b24e65d..a4ac69b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +###### Add string name for hardware. +###### Add cocoapods support. + +--- +zzymoon@gmail.com + +--- + Determines exact hardware of current iOS device. mail@boxedfolder.com diff --git a/UIDevice+HardwareModel.h b/UIDevice+HardwareModel.h index 31993f6..f2241eb 100644 --- a/UIDevice+HardwareModel.h +++ b/UIDevice+HardwareModel.h @@ -7,7 +7,7 @@ #import -enum UIHardwareModel +typedef enum __UIHardwareModel { UIHardwareModelSimulator = 1, @@ -51,10 +51,15 @@ enum UIHardwareModel UIHardwareModeliPhone5s = 30, UIHardwareModeliPhone5sGlobal = 31 -}; typedef NSUInteger UIHardwareModel; +} UIHardwareModel; @interface UIDevice (HardwareModel) +/** + * Returns hardware name of device instance + */ +- (NSString *)hardwareName + /** * Returns hardware id of device instance */ diff --git a/UIDevice+HardwareModel.m b/UIDevice+HardwareModel.m index 076c45a..b613910 100644 --- a/UIDevice+HardwareModel.m +++ b/UIDevice+HardwareModel.m @@ -10,6 +10,112 @@ @implementation UIDevice (HardwareModel) +- (NSString *)hardwareName +{ + NSString *name = @"Unknown"; + + switch ([self hardwareModel]) { + case UIHardwareModeliPad: + name = @"iPad 1G"; + break; + case UIHardwareModeliPad2CDMA: + name = @"iPad 2 CDMA"; + break; + case UIHardwareModeliPad2GSM: + name = @"iPad 2 GSM"; + break; + case UIHardwareModeliPad2Wifi: + name = @"iPad 2 Wifi"; + break; + case UIHardwareModeliPad3CDMA: + name = @"iPad 3 CDMA"; + break; + case UIHardwareModeliPad3GSM: + name = @"iPad 3 GSM"; + break; + case UIHardwareModeliPad3Wifi: + name = @"iPad 3 Wifi"; + break; + case UIHardwareModeliPad4CDMA: + name = @"iPad 4 CDMA"; + break; + case UIHardwareModeliPad4GSM: + name = @"iPad 4 GSM"; + break; + case UIHardwareModeliPad4Wifi: + name = @"iPad 4 Wifi"; + break; + case UIHardwareModeliPadMiniCDMA: + name = @"iPad mini CDMA"; + break; + case UIHardwareModeliPadMiniGSM: + name = @"iPad mini GSM"; + break; + case UIHardwareModeliPadMiniWifi: + name = @"iPad mini Wifi"; + break; + case UIHardwareModeliPhone1G: + name = @"iPhone 1G"; + break; + case UIHardwareModeliPhone3G: + name = @"iPhone 3G"; + break; + case UIHardwareModeliPhone3GS: + name = @"iPhone 3Gs"; + break; + case UIHardwareModeliPhone4: + name = @"iPhone 4"; + break; + case UIHardwareModeliPhone4S: + name = @"iPhone 4s"; + break; + case UIHardwareModeliPhone4Verizon: + name = @"iPhone 4 Verizon"; + break; + case UIHardwareModeliPhone5: + name = @"iPhone 5"; + break; + case UIHardwareModeliPhone5c: + name = @"iPhone 5c"; + break; + case UIHardwareModeliPhone5cGlobal: + name = @"iPhone 5c Global"; + break; + case UIHardwareModeliPhone5Global: + name = @"iPhone 5 Global"; + break; + case UIHardwareModeliPhone5s: + name = @"iPhone 5s"; + break; + case UIHardwareModeliPhone5sGlobal: + name = @"iPhone 5s Global"; + break; + case UIHardwareModeliPodTouch1G: + name = @"iPod 1G"; + break; + case UIHardwareModeliPodTouch2G: + name = @"iPod 2G"; + break; + case UIHardwareModeliPodTouch3G: + name = @"iPod 3G"; + break; + case UIHardwareModeliPodTouch4G: + name = @"iPod 4G"; + break; + case UIHardwareModeliPodTouch5G: + name = @"iPod 5G"; + break; + case UIHardwareModelSimulator: + name = @"Simulator"; + break; + default: + name = @"Unknown"; + break; + } + + return name; +} + -(UIHardwareModel)hardwareModel { static UIHardwareModel _hardwareModel; diff --git a/pod.podspec b/pod.podspec new file mode 100644 index 0000000..5d73e68 --- /dev/null +++ b/pod.podspec @@ -0,0 +1,17 @@ +Pod::Spec.new do |s| + s.name = 'UIDevice-HardwareModel' + s.version = '1.1' + s.license = :type => 'MIT' + s.homepage = 'http://605studio.info' + s.authors = 'ZY' => 'zzymoon@gmail.com' + s.summary = 'Determines exact hardware of current iOS device. Forked from https://github.com/bfolder/UIDevice-HardwareModel' + +# Source Info + s.platform = :ios, '3.0' + s.source = :git => 'https://github.com/tecentmoon/UIDevice-HardwareModel.git', :tag => '1.1' + s.source_files = '' + s.framework = '' + + s.requires_arc = false + +end \ No newline at end of file From 8c8adee6ea5c1dd7372245e354361dc82fe6eecc Mon Sep 17 00:00:00 2001 From: ZY Date: Tue, 26 Nov 2013 23:53:31 +0800 Subject: [PATCH 2/4] update pod --- pod.podspec | 138 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 122 insertions(+), 16 deletions(-) diff --git a/pod.podspec b/pod.podspec index 5d73e68..0c9bc54 100644 --- a/pod.podspec +++ b/pod.podspec @@ -1,17 +1,123 @@ +# +# Be sure to run `pod spec lint pod.podspec' to ensure this is a +# valid spec and to remove all comments including this before submitting the spec. +# +# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html +# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ +# + Pod::Spec.new do |s| - s.name = 'UIDevice-HardwareModel' - s.version = '1.1' - s.license = :type => 'MIT' - s.homepage = 'http://605studio.info' - s.authors = 'ZY' => 'zzymoon@gmail.com' - s.summary = 'Determines exact hardware of current iOS device. Forked from https://github.com/bfolder/UIDevice-HardwareModel' - -# Source Info - s.platform = :ios, '3.0' - s.source = :git => 'https://github.com/tecentmoon/UIDevice-HardwareModel.git', :tag => '1.1' - s.source_files = '' - s.framework = '' - - s.requires_arc = false - -end \ No newline at end of file + + # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # These will help people to find your library, and whilst it + # can feel like a chore to fill in it's definitely to your advantage. The + # summary should be tweet-length, and the description more in depth. + # + + s.name = "UIDevice-HardwareModel" + s.version = "0.0.1" + s.summary = "A short description of pod." + + s.homepage = "https://github.com/tecentmoon/UIDevice-HardwareModel.git" + + + # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Licensing your code is important. See http://choosealicense.com for more info. + # CocoaPods will detect a license file if there is a named LICENSE* + # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. + # + + s.license = 'MIT' + # s.license = { :type => 'MIT', :file => 'FILE_LICENSE' } + + + # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the authors of the library, with email addresses. Email addresses + # of the authors by using the SCM log. E.g. $ git log. If no email can be + # found CocoaPods accept just the names. + # + + s.author = { "ZY" => "zzymoon@gmail.com" , "bfolder" => "mail@boxedfolder.com"} + # s.authors = { "ZY" => "zzymoon@gmail.com", "other author" => "email@address.com" } + # s.author = 'ZY', 'other author' + + + # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If this Pod runs only on iOS or OS X, then specify the platform and + # the deployment target. You can optionally include the target after the platform. + # + + s.platform = :ios + # s.platform = :ios, '5.0' + + # When using multiple platforms + # s.ios.deployment_target = '5.0' + # s.osx.deployment_target = '10.7' + + + # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the location from where the source should be retrieved. + # Supports git, hg, svn and HTTP. + # + + s.source = { :git => "https://github.com/tecentmoon/UIDevice-HardwareModel.git", :tag => "1.1" } + + + # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # CocoaPods is smart about how it includes source code. For source files + # giving a folder will include any h, m, mm, c & cpp files. For header + # files it will include any header in the folder. + # Not including the public_header_files will make all headers public. + # + + s.source_files = 'Classes', 'Classes/**/*.{h,m}' + s.exclude_files = 'Classes/Exclude' + + # s.public_header_files = 'Classes/**/*.h' + + + # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # A list of resources included with the Pod. These are copied into the + # target bundle with a build phase script. Anything else will be cleaned. + # You can preserve files from being cleaned, please don't preserve + # non-essential files like tests, examples and documentation. + # + + # s.resource = "icon.png" + # s.resources = "Resources/*.png" + + # s.preserve_paths = "FilesToSave", "MoreFilesToSave" + + + # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Link your library with frameworks, or libraries. Libraries do not include + # the lib prefix of their name. + # + + # s.framework = 'SomeFramework' + # s.frameworks = 'SomeFramework', 'AnotherFramework' + + # s.library = 'iconv' + # s.libraries = 'iconv', 'xml2' + + + # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If your library depends on compiler flags you can set them in the xcconfig hash + # where they will only apply to your library. If you depend on other Podspecs + # you can include multiple dependencies to ensure it works. + + # s.requires_arc = true + + # s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' } + # s.dependency 'JSONKit', '~> 1.4' + +end From eb9d7f072a1c34d00565c45758c684db3977aa9b Mon Sep 17 00:00:00 2001 From: ZY Date: Wed, 27 Nov 2013 00:16:41 +0800 Subject: [PATCH 3/4] add files --- LICENSE | 30 ++++++++ UIDevice+HardwareModel.h | 2 +- UIDevice+HardwareModel.podspec | 13 ++++ pod.podspec | 123 --------------------------------- 4 files changed, 44 insertions(+), 124 deletions(-) create mode 100644 LICENSE create mode 100644 UIDevice+HardwareModel.podspec delete mode 100644 pod.podspec diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4c42ab5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +The MIT License (MIT) + +Copyright (c) 2013 ZY + +Permission is hereby granted, free of charge, to any person obtaining a +copy +of this software and associated documentation files (the "Software"), to +deal +in the Software without restriction, including without limitation the +rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN +THE SOFTWARE. diff --git a/UIDevice+HardwareModel.h b/UIDevice+HardwareModel.h index f2241eb..93a756d 100644 --- a/UIDevice+HardwareModel.h +++ b/UIDevice+HardwareModel.h @@ -58,7 +58,7 @@ typedef enum __UIHardwareModel /** * Returns hardware name of device instance */ -- (NSString *)hardwareName +- (NSString *)hardwareName; /** * Returns hardware id of device instance diff --git a/UIDevice+HardwareModel.podspec b/UIDevice+HardwareModel.podspec new file mode 100644 index 0000000..39f73cc --- /dev/null +++ b/UIDevice+HardwareModel.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + + s.name = "UIDevice+HardwareModel" + s.version = "1.1" + s.summary = "Check iOS hardware model" + s.homepage = "https://github.com/tecentmoon/UIDevice-HardwareModel.git" + s.license = { :type => 'MIT', :file => 'LICENSE' } + s.author = { "ZY" => "zzymoon@gmail.com" , "bfolder" => "mail@boxedfolder.com"} + s.platform = :ios + s.source = { :git => "https://github.com/tecentmoon/UIDevice-HardwareModel.git", :tag => "1.1" } + s.source_files = '*.{h,m}' + +end diff --git a/pod.podspec b/pod.podspec deleted file mode 100644 index 0c9bc54..0000000 --- a/pod.podspec +++ /dev/null @@ -1,123 +0,0 @@ -# -# Be sure to run `pod spec lint pod.podspec' to ensure this is a -# valid spec and to remove all comments including this before submitting the spec. -# -# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html -# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ -# - -Pod::Spec.new do |s| - - # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # These will help people to find your library, and whilst it - # can feel like a chore to fill in it's definitely to your advantage. The - # summary should be tweet-length, and the description more in depth. - # - - s.name = "UIDevice-HardwareModel" - s.version = "0.0.1" - s.summary = "A short description of pod." - - s.homepage = "https://github.com/tecentmoon/UIDevice-HardwareModel.git" - - - # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # Licensing your code is important. See http://choosealicense.com for more info. - # CocoaPods will detect a license file if there is a named LICENSE* - # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. - # - - s.license = 'MIT' - # s.license = { :type => 'MIT', :file => 'FILE_LICENSE' } - - - # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # Specify the authors of the library, with email addresses. Email addresses - # of the authors by using the SCM log. E.g. $ git log. If no email can be - # found CocoaPods accept just the names. - # - - s.author = { "ZY" => "zzymoon@gmail.com" , "bfolder" => "mail@boxedfolder.com"} - # s.authors = { "ZY" => "zzymoon@gmail.com", "other author" => "email@address.com" } - # s.author = 'ZY', 'other author' - - - # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # If this Pod runs only on iOS or OS X, then specify the platform and - # the deployment target. You can optionally include the target after the platform. - # - - s.platform = :ios - # s.platform = :ios, '5.0' - - # When using multiple platforms - # s.ios.deployment_target = '5.0' - # s.osx.deployment_target = '10.7' - - - # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # Specify the location from where the source should be retrieved. - # Supports git, hg, svn and HTTP. - # - - s.source = { :git => "https://github.com/tecentmoon/UIDevice-HardwareModel.git", :tag => "1.1" } - - - # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # CocoaPods is smart about how it includes source code. For source files - # giving a folder will include any h, m, mm, c & cpp files. For header - # files it will include any header in the folder. - # Not including the public_header_files will make all headers public. - # - - s.source_files = 'Classes', 'Classes/**/*.{h,m}' - s.exclude_files = 'Classes/Exclude' - - # s.public_header_files = 'Classes/**/*.h' - - - # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # A list of resources included with the Pod. These are copied into the - # target bundle with a build phase script. Anything else will be cleaned. - # You can preserve files from being cleaned, please don't preserve - # non-essential files like tests, examples and documentation. - # - - # s.resource = "icon.png" - # s.resources = "Resources/*.png" - - # s.preserve_paths = "FilesToSave", "MoreFilesToSave" - - - # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # Link your library with frameworks, or libraries. Libraries do not include - # the lib prefix of their name. - # - - # s.framework = 'SomeFramework' - # s.frameworks = 'SomeFramework', 'AnotherFramework' - - # s.library = 'iconv' - # s.libraries = 'iconv', 'xml2' - - - # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # - # - # If your library depends on compiler flags you can set them in the xcconfig hash - # where they will only apply to your library. If you depend on other Podspecs - # you can include multiple dependencies to ensure it works. - - # s.requires_arc = true - - # s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' } - # s.dependency 'JSONKit', '~> 1.4' - -end From e0f17e2bf516c4a3e5b5d9f8cd3d1b06e3c17e0d Mon Sep 17 00:00:00 2001 From: ZY Date: Wed, 27 Nov 2013 00:49:33 +0800 Subject: [PATCH 4/4] update --- UIDevice+HardwareModel.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UIDevice+HardwareModel.podspec b/UIDevice+HardwareModel.podspec index 39f73cc..7e45cc3 100644 --- a/UIDevice+HardwareModel.podspec +++ b/UIDevice+HardwareModel.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "UIDevice+HardwareModel" - s.version = "1.1" + s.version = "1.2" s.summary = "Check iOS hardware model" s.homepage = "https://github.com/tecentmoon/UIDevice-HardwareModel.git" s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { "ZY" => "zzymoon@gmail.com" , "bfolder" => "mail@boxedfolder.com"} s.platform = :ios - s.source = { :git => "https://github.com/tecentmoon/UIDevice-HardwareModel.git", :tag => "1.1" } + s.source = { :git => "https://github.com/tecentmoon/UIDevice-HardwareModel.git", :tag => "1.2" } s.source_files = '*.{h,m}' end