Get information about your app in Swifty way
Do you remember yourself doing this? Can remember all the keys? How many times have you searched for the right names?
let text = NSBundle.mainBundle().infoDictionary?["CFBundleVersion"]
// Keys
"CFBundleDisplayName", "CFBundleVersion", "UIRequiredDeviceCapabilities", "UIMainStoryboardFile", ...
Wouldn't it be awesome to have Xcode to show them all? And be staticly typed!?
Enter AppInfo.
AppInfo provides an static typed API for working with infoDictionary
.
let name = AppInfo.CFBundleName
let build = AppInfo.CFBundleVersion
let version = AppInfo.CFBundleShortVersionString
let devices = AppInfo.UIDeviceFamily
/*
Results:
Name - "DemeApp", String
build - 2, Int
version - "1.0", String
devices - ["armv7"], Array
/*
The simplest way - copy AppInfo/Classes/AppInfo.swift
to your project. That's it!
use_frameworks!
pod 'AppInfo'
Then import it to your project:
import AppInfo
Note: This requires CocoaPods 0.36 as well as iOS 8
Please open an issue with bugs and missing features, functionality or ideas for improvements.
Also you can contribute by following this guidelines:
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Kostiantyn Koval, @KostiaKoval
AppInfo is available under the MIT license. See the LICENSE file for more info.