Contents

BellAppLab/Defines

A collection of runtime checks written in Swift.

Note

Please note that Defines does not provide compile-time safety checks. It is merely a collection of static booleans for runtime checks.

In other words, doing this:

let iOS9 = Defines.Version(versionString: "9.0")
if Defines.OS.isiOS && Defines.OS.version = iOS9 {
    //execute code only available on iOS9
}

... will not silence any compiler warnings.

For that, take a look at Checking API Availability and Conditional Compilation Block.

Usage

Just so you get the gist of it.

  • Defines: main point of interaction with this module.

- Device - currentModel : the device model running your code. - isSimulator - Model: enumeration of model identifiers for all the relevant Apple products since 2008. - isAppleTV - isAppleWatch - isiPad - isiPhone - isiPod - isMac - much more - Screen: information about the current screen available to your app. - bounds: the screen's current bound rect. - currentWidth - currentHeight - maxLength: the greater between width and height. - minLength: the lesser between width and height. - much more - OS: information about the OS running your app. - version: describes the version of the OS running your app and makes it easy to compare them. - App: your app, mainly reading from Info.plist. - name(forClass:): find your app's name. - version(forClass:): find your app's version. - Version: defines a software version in the format major.minor.patch (build).

  • Bundle:

- id(forClass:): find your app's bundle id.

Specs

  • iOS 9+
  • watchOS 3+
  • tvOS 9+
  • macOS 10.11+
  • Swift 3.3+

Installation

Cocoapods

pod 'Defines', '~> 1.0'

Then import Defines where needed.

Carthage

github "BellAppLab/Defines" ~> 1.0

Then import Defines where needed.

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/BellAppLab/Defines", from: "1.0")
]

Then import Defines where needed.

Git Submodules

cd toYourProjectsFolder
git submodule add -b submodule --name Defines https://github.com/BellAppLab/Defines.git

Then drag the Definess folder into your Xcode project.

Author

Bell App Lab, apps@bellapplab.com

Credits

Logo image by Sumana Chamrunworakiat from The Noun Project

License

Defines is available under the MIT license. See the LICENSE file for more info.

Package Metadata

Repository: BellAppLab/Defines

Stars: 2

Forks: 0

Open issues: 0

Default branch: master

Primary language: swift

License: MIT

Topics: cocoapods, define, defines, ios, macos, osx, swift, tvos, watchos

README: README.md