{"id":19252229,"url":"https://github.com/bellapplab/defines","last_synced_at":"2025-07-13T17:39:46.009Z","repository":{"id":56908370,"uuid":"40299431","full_name":"BellAppLab/Defines","owner":"BellAppLab","description":"A collection of runtime checks written in Swift.","archived":false,"fork":false,"pushed_at":"2018-11-05T19:56:55.000Z","size":105,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-12-14T23:51:39.543Z","etag":null,"topics":["cocoapods","define","defines","ios","macos","osx","swift","tvos","watchos"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/BellAppLab.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":"2015-08-06T10:37:56.000Z","updated_at":"2023-04-03T19:37:19.000Z","dependencies_parsed_at":"2022-08-21T01:50:58.105Z","dependency_job_id":null,"html_url":"https://github.com/BellAppLab/Defines","commit_stats":null,"previous_names":[],"tags_count":12,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FDefines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FDefines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FDefines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FDefines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BellAppLab","download_url":"https://codeload.github.com/BellAppLab/Defines/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240347928,"owners_count":19787236,"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","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":["cocoapods","define","defines","ios","macos","osx","swift","tvos","watchos"],"created_at":"2024-11-09T18:26:04.619Z","updated_at":"2025-02-23T16:50:30.569Z","avatar_url":"https://github.com/BellAppLab.png","language":"Swift","readme":"# Defines [![Version](https://img.shields.io/badge/Version-1.0.2-black.svg?style=flat)](#installation) [![License](https://img.shields.io/cocoapods/l/Defines.svg?style=flat)](#license)\n\n[![Platforms](https://img.shields.io/badge/Platforms-iOS|watchOS|tvOS|macOS-brightgreen.svg?style=flat)](#installation)\n[![Swift support](https://img.shields.io/badge/Swift-3.3%20%7C%204.1%20%7C%204.2-red.svg?style=flat)](#swift-versions-support)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Defines.svg?style=flat\u0026label=CocoaPods)](https://cocoapods.org/pods/Defines)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-orange.svg?style=flat)](https://github.com/apple/swift-package-manager)\n[![Twitter](https://img.shields.io/badge/Twitter-@BellAppLab-blue.svg?style=flat)](http://twitter.com/BellAppLab)\n\n![Defines](./Images/defines.png)\n\nA collection of runtime checks written in Swift.\n\nIn other words, simply do this:\n\n```swift\nif Defines.Device.isSimulator {\n    //Don't ask permission to send push notifications\n}\n```\n\nWe all know the Apple Way of Doing Things ™, right? Instead of checking for a device, you check for a capability. For instance, instead of checking if a device is an iPod touch and therefore doesn't have a GPS, you check if `CoreLocation` is available. Or instead of checking for a device's screen size all the time, we should rely on Auto Layout's size classes and all that. \n\nI get it. \n\nBut sometimes you just have to have that flag somewhere. `Compact` and `Regular` do not capture how preposterous the iPad Pro 12.9\" screen's real estate is. So maybe you want to present a little bit more content there. Or maybe you just don't want to ask permissions for push notifications on the Simulator. We've all been there.\n\nSo just `import Defines` and get on with your life. \n\n## Note\n\nPlease note that `Defines` does **not** provide compile-time safety checks. It is merely a collection of static booleans for runtime checks. \n\nIn other words, doing this:\n\n```swift\nlet iOS9 = Defines.Version(versionString: \"9.0\")\nif Defines.OS.isiOS \u0026\u0026 Defines.OS.version = iOS9 {\n    //execute code only available on iOS9\n}\n```\n\n... will **not** silence any compiler warnings. \n\nFor that, take a look at [Checking API Availability](https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID523) and  [Conditional Compilation Block](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID539).\n\n## Usage\n\nJust so you get the gist of it.\n\n- `Defines`: main point of interaction with this module.\n    - `Device`\n        - `currentModel` : the device model running your code.\n        - `isSimulator`\n        - `Model`: enumeration of model identifiers for all the relevant Apple products since 2008.\n        - `isAppleTV`\n        - `isAppleWatch`\n        - `isiPad`\n        - `isiPhone`\n        - `isiPod`\n        - `isMac`\n        - much more\n    - `Screen`: information about the current screen available to your app.\n        - `bounds`: the screen's current bound rect.\n        - `currentWidth`\n        - `currentHeight`\n        - `maxLength`: the greater between width and height.\n        - `minLength`: the lesser between width and height.\n        - much more\n    - `OS`: information about the OS running your app.\n        - `version`: describes the version of the OS running your app and makes it easy to compare them.\n    - `App`: your app, mainly reading from Info.plist.\n        - `name(forClass:)`:  find your app's name.\n        - `version(forClass:)`: find your app's version.\n    - `Version`: defines a software version in the format **major.minor.patch (build)**.\n- `Bundle`:\n    - `id(forClass:)`: find your app's bundle id.\n\n## Specs\n\n* iOS 9+\n* watchOS 3+\n* tvOS 9+\n* macOS 10.11+\n* Swift 3.3+\n\n## Installation\n\n### Cocoapods\n\n```ruby\npod 'Defines', '~\u003e 1.0'\n```\n\nThen `import Defines` where needed.\n\n### Carthage\n\n```swift\ngithub \"BellAppLab/Defines\" ~\u003e 1.0\n```\n\nThen `import Defines` where needed.\n\n### Swift Package Manager\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/BellAppLab/Defines\", from: \"1.0\")\n]\n```\n\nThen `import Defines` where needed.\n\n### Git Submodules\n\n```shell\ncd toYourProjectsFolder\ngit submodule add -b submodule --name Defines https://github.com/BellAppLab/Defines.git\n```\n\nThen drag the `Definess` folder into your Xcode project.\n\n## Author\n\nBell App Lab, apps@bellapplab.com\n\n### Credits\n\n[Logo image](https://thenounproject.com/search/?q=define\u0026i=659840#) by [Sumana Chamrunworakiat](https://thenounproject.com/windy.windysky) from [The Noun Project](https://thenounproject.com/)\n\n## License\n\nDefines is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbellapplab%2Fdefines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbellapplab%2Fdefines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbellapplab%2Fdefines/lists"}