{"id":1259,"url":"https://github.com/sebyddd/SDVersion","last_synced_at":"2025-07-30T20:32:56.823Z","repository":{"id":20569839,"uuid":"23850144","full_name":"sebyddd/SDVersion","owner":"sebyddd","description":":iphone: Lightweight Cocoa library for detecting the running device's model and screen size.","archived":false,"fork":false,"pushed_at":"2022-09-29T08:15:20.000Z","size":406,"stargazers_count":1309,"open_issues_count":19,"forks_count":213,"subscribers_count":55,"default_branch":"master","last_synced_at":"2025-07-24T02:28:06.442Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebyddd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-09T21:03:17.000Z","updated_at":"2025-07-22T05:37:52.000Z","dependencies_parsed_at":"2022-08-31T17:22:05.296Z","dependency_job_id":null,"html_url":"https://github.com/sebyddd/SDVersion","commit_stats":null,"previous_names":["sebyddd/sdiphoneversion"],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/sebyddd/SDVersion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyddd%2FSDVersion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyddd%2FSDVersion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyddd%2FSDVersion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyddd%2FSDVersion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebyddd","download_url":"https://codeload.github.com/sebyddd/SDVersion/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebyddd%2FSDVersion/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267792737,"owners_count":24144931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:42.403Z","updated_at":"2025-07-30T20:32:56.307Z","avatar_url":"https://github.com/sebyddd.png","language":"Objective-C","readme":"\u003cp align=\"center\"\u003e\n \u003cimg src=\"https://dl.dropboxusercontent.com/s/bmfjwfe2ngnivwn/sdversion.png?dl=0\" alt=\"SDVersion\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://gitter.im/sebyddd/SDiPhoneVersion?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/gitter-join%20chat-1dce73.svg\"\n             alt=\"Gitter\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://sebastiandobrincu.com\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/platform-iOS%20%7C%20watchOS%20%7C%20tvOS%20%7C%20macOS-D0547F.svg\"\n             alt=\"Platform\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://sebastiandobrincu.com\"\u003e\n        \u003cimg src=\"http://img.shields.io/cocoapods/v/SDVersion.svg\"\n             alt=\"Cocoapods Version\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nLightweight Cocoa library for detecting the running device's model and screen size.\n\nWith the newer  devices, developers have more work to do. This library simplifies their job by allowing them to get information about the running device and easily target the ones they want.\n\nSDVersion supports iOS, watchOS, tvOS, and macOS. Browse through the implementation of each platform using the links below.\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"#ios\"\u003e\n        \t\u003cimg src=\"https://dl.dropboxusercontent.com/s/ck42lqeda643v02/sdversion-ios.png?dl=0\" alt=\"iOS\"\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"#mac-os\"\u003e\n\t\t\u003cimg src=\"https://dl.dropboxusercontent.com/s/2yhgx57v4alnzld/sdversion-mac.png?dl=0\" alt=\"Mac\"\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\n## How it works\n\n```objective-c\n      // Check for device model\n      if ([SDVersion deviceVersion] == iPhone7)\n           NSLog(@\"You got the iPhone 7. Sweet 🍭!\");\n      else if ([SDVersion deviceVersion] == iPhone6SPlus)\n           NSLog(@\"iPhone 6S Plus? Bigger is better!\");\n      else if ([SDVersion deviceVersion] == iPadAir2)\n      \t   NSLog(@\"You own an iPad Air 2 🌀!\");\n\n      // Check for device screen size\n      if ([SDVersion deviceSize] == Screen4Dot7inch)\n           NSLog(@\"Your screen is 4.7 inches\");\n\n      // Check if screen is in zoom mode\n      if ([SDVersion isZoomed])\n      \t   NSLog(@\"Your device is in Zoom Mode 🔎\");\n\n      // Get device name\n      NSLog(@\"%@\", [SDVersion deviceNameString]);\n      /* e.g: Outputs 'iPhone 7 Plus' */\n\n      // Check for iOS Version\n      if ([SDVersion versionGreaterThanOrEqualTo:@\"10\"])\n           NSLog(@\"You are running iOS 10 or above!\");\n```\n\n\u003cp align=\"center\"\u003e\n \u003ca href=\"#how-it-works\"\u003e\n        \t\u003cimg src=\"https://static1.squarespace.com/static/52428a0ae4b0c4a5c2a2cede/t/5479ce82e4b028a16123006d/1417268866072/Apple_Swift_Logo.png\" alt=\"SDVersion Swift\" width=\"40\" height=\"40\"/\u003e\u003cbr\u003e\n\t\u003c/a\u003e\nSwift Version:\n\u003c/p\u003e\n  \n\n```swift\n      // Check for device model\n      if SDiOSVersion.deviceVersion() == .iPhone7 {\n            print(\"You got the iPhone 7. Sweet 🍭!\")\n      }\n\n      // Check for device screen size\n      if SDiOSVersion.deviceSize() == .Screen3Dot5inch {\n            print(\"Still on 3.5 inches!? 😮\")\n      }\n\n      // Get device name\n      print(SDiOSVersion.deviceNameString())\n      /* e.g: Outputs 'iPhone 7 Plus' */\n\n      // Check for iOS Version\n      if SDiOSVersion.versionGreaterThan(\"10\") {\n            print(\"You are running iOS 10 or above!\")\n      }\n```\n\n## Add to your project\n\nThere are 2 ways you can add SDVersion to your project:\n\n### Manual installation\n\n\n Simply import the 'SDVersion' into your project then import the following in the class you want to use it:\n ```objective-c\n       #import \"SDVersion.h\"\n ```\n In Swift, you need to import in the bridging header the specific library version, not the library wrapper:\n  ```objective-c\n       #import \"SDiOSVersion.h\" // Or SDMacVersion.h\n ```\n\n### Installation with CocoaPods\n\nCocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like SDVersion in your projects. See the \"[Getting Started](http://guides.cocoapods.org/syntax/podfile.html)\" guide for more information.\n\n### Podfile\n```ruby\n        pod 'SDVersion'\n```\n\n\n## iOS\n\n### Available methods\n```objective-c\n\t+ (DeviceVersion)deviceVersion;\n\t+ (NSString *)deviceNameForVersion:(DeviceVersion)deviceVersion;\n\t+ (DeviceSize)resolutionSize;\n\t+ (DeviceSize)deviceSize;\n\t+ (NSString *)deviceSizeName:(DeviceSize)deviceSize;\n\t+ (NSString *)deviceNameString;\n\t+ (BOOL)isZoomed;\n```\n### Targetable models\n\tiPhone4\n    iPhone4S\n    iPhone5\n    iPhone5C\n    iPhone5S\n    iPhone6\n    iPhone6Plus\n    iPhone6S\n    iPhone6SPlus\n    iPhoneSE\n    iPhone7\n    iPhone7Plus\n\n    iPad1\n    iPad2\n    iPadMini\n    iPad3\n    iPad4\n    iPadAir\n    iPadMini2\n    iPadAir2\n    iPadMini3\n    iPadMini4\n    iPadPro9Dot7Inch\n    iPadPro12Dot9Inch\n    iPad5\n\n\tiPodTouch1Gen\n    iPodTouch2Gen\n    iPodTouch3Gen\n    iPodTouch4Gen\n    iPodTouch5Gen\n    iPodTouch6Gen\n\n    Simulator\n### Targetable screen sizes\n    Screen3Dot5inch\n    Screen4inch\n    Screen4Dot7inch\n    Screen5Dot5inch\n### Available iOS Version Finder methods\n  ```objective-c\n      + (BOOL)versionEqualTo:(NSString *)version;\n      + (BOOL)versionGreaterThan:(NSString *)version;\n      + (BOOL)versionGreaterThanOrEqualTo:(NSString *)version;\n      + (BOOL)versionLessThan:(NSString *)version;\n      + (BOOL)versionLessThanOrEqualTo:(NSString *)version;\n  ```       \n\n### Helpers\n```objective-c\n\t  NSLog(@\"%@\", [SDVersion deviceVersionName:[SDVersion deviceVersion]]);\n      /* e.g: Outputs 'iPad Air 2' */\n\n      NSLog(@\"%@\", [SDVersion deviceSizeName:[SDVersion deviceSize]]);\n      /* e.g: Outputs '4.7 inch' */\n```\nOr in Swift: \n```swift\n      let deviceVersionName = SDiOSVersion.deviceVersionName(SDiOSVersion.deviceVersion())\n      let deviceSizeName = SDiOSVersion.deviceSizeName(SDiOSVersion.deviceSize())    \n```\n\n## watchOS\n\n### Available methods\n```objective-c\n    + (DeviceVersion)deviceVersion;\n\t+ (DeviceSize)deviceSize;\n\t+ (NSString *)deviceName;\n```\n### Targetable models\n\tApple Watch 38mm\n    Apple Watch 42mm\n    Apple Watch 38mm Series 1\n    Apple Watch 42mm Series 1\n    Apple Watch 38mm Series 2\n    Apple Watch 42mm Series 2\n\n    Simulator\n\n### Targetable screen sizes\n    Screen38mm\n    Screen42mm\n\n### Available watchOS Version Finder methods\n```objective-c\n    + (BOOL)versionEqualTo:(NSString *)version;\n    + (BOOL)versionGreaterThan:(NSString *)version;\n    + (BOOL)versionGreaterThanOrEqualTo:(NSString *)version;\n    + (BOOL)versionLessThan:(NSString *)version;\n    + (BOOL)versionLessThanOrEqualTo:(NSString *)version;\n```      \n\n### Helpers\n```objective-c\n\t  NSLog(@\"%@\", [SDVersion deviceVersionName:[SDVersion deviceVersion]]);\n      /* e.g: Outputs 'Apple Watch 42mm' */\n\n      NSLog(@\"%@\", [SDVersion deviceSizeName:[SDVersion deviceSize]]);\n      /* e.g: Outputs '42mm' */\n```\n\n## tvOS\n\n### Available methods\n```objective-c\n    + (DeviceVersion)deviceVersion;\n\t+ (NSString *)deviceName;\n```\n### Targetable models\n\tApple TV (4th Generation)\n\n    Simulator\n\n### Available tvOS Version Finder methods\n```objective-c\n    + (BOOL)versionEqualTo:(NSString *)version;\n    + (BOOL)versionGreaterThan:(NSString *)version;\n    + (BOOL)versionGreaterThanOrEqualTo:(NSString *)version;\n    + (BOOL)versionLessThan:(NSString *)version;\n    + (BOOL)versionLessThanOrEqualTo:(NSString *)version;\n```       \n\n### Helpers\n```objective-c\n\t  NSLog(@\"%@\", [SDVersion deviceVersionName:[SDVersion deviceVersion]]);\n      /* e.g: Outputs 'Apple TV (4th Generation)' */\n```\n\n## Mac OS\n```objective-c\n      // Check for device model\n      if ([SDVersion deviceVersion] == DeviceVersionIMac)\n          NSLog(@\"So you have a iMac? 💻\");\n      else if ([SDVersion deviceVersion] == DeviceVersionMacBookPro)\n          NSLog(@\"You're using a MacBook Pro.\");\n\n      // Check for screen size\n      if ([SDVersion deviceSize] == Mac27Inch)\n          NSLog(@\"Whoah! You got a big ass 27 inch screen.\");\n      else if ([SDVersion deviceSize] == Mac21Dot5Inch)\n          NSLog(@\"You have a 21.5 inch screen.\");\n\n      // Check for screen resolution\n      if ([SDVersion deviceScreenResolution] == DeviceScreenRetina)\n          NSLog(@\"Nice retina screen!\");\n\n      // Get screen resolution in pixels\n      NSLog(@\"%@\", [SDVersion deviceScreenResolutionName:[SDVersion deviceScreenResolution]]);\n      /* e.g: Outputs '{2880, 1800}' */\n\n      // Check OSX Version (pass the minor version)\n      if([SDVersion versionGreaterThanOrEqualTo:@\"11\"])\n           NSLog(@\"Looks like you are running OSX 10.11 El Capitan or 🆙.\");\n```\n\n### Available methods\n```objective-c\n    + (DeviceVersion)deviceVersion;\n    + (NSString *)deviceVersionString;\n    + (DeviceSize)deviceSize;\n    + (NSSize)deviceScreenResolutionPixelSize;\n    + (DeviceScreenResolution)deviceScreenResolution;\n```\n### Targetable models\n\tDeviceVersionIMac\n\tDeviceVersionMacMini\n\tDeviceVersionMacPro\n\tDeviceVersionMacBook\n\tDeviceVersionMacBookAir\n\tDeviceVersionMacBookPro\n\tDeviceVersionXserve\n\n### Targetable screen sizes\n    Mac27Inch\n\tMac24Inch\n\tMac21Dot5Inch\n\tMac20Inch\n\tMac17Inch\n\tMac15Inch\n\tMac13Inch\n\tMac12Inch\n\tMac11Inch\n\n### Targetable screen resolutions\n    DeviceScreenRetina,\n\tDeviceScreenNoRetina\n\n### Available OSX Version Finder methods\n```objective-c\n    + (BOOL)versionEqualTo:(NSString *)version;\n    + (BOOL)versionGreaterThan:(NSString *)version;\n    + (BOOL)versionGreaterThanOrEqualTo:(NSString *)version;\n    + (BOOL)versionLessThan:(NSString *)version;\n    + (BOOL)versionLessThanOrEqualTo:(NSString *)version;\n    /* 'v' must be the minor OS Version. e.g: OSX 10.9 - 'v' is 9 */\n```\n### Helpers\n```objective-c\n      NSLog(@\"%@\", [SDVersion deviceSizeName:[SDVersion deviceSize]]);\n      /* e.g: Outputs '15 inch' */\n\n      NSLog(@\"%@\",[SDVersion deviceScreenResolutionName:[SDVersion deviceScreenResolution]])\n      /* e.g: Outputs '{2880, 1800}' */\n```\n\n## Used by\n\n\u003cp align=\"center\"\u003e\n       \u003cimg src=\"https://dl.dropboxusercontent.com/s/yp3kwu2lobe9pvg/who-uses-sdversion.png?dl=0\" alt=\"Who uses SDVersion\"\u003e\n\u003c/p\u003e\n\n## License\nUsage is provided under the [MIT License](http://opensource.org/licenses/mit-license.php). See LICENSE for the full details.\n","funding_links":[],"categories":["Hardware","Objective-C  Stars 1000以内排名整理","Project Logo","HarmonyOS","etc","Examples"],"sub_categories":["Other Hardware","Other free courses","Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebyddd%2FSDVersion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebyddd%2FSDVersion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebyddd%2FSDVersion/lists"}