- Notifications
You must be signed in to change notification settings - Fork6
Strongly Typed access to the Info.plist for iOS, macOS and tvOS.
License
nmdias/InfoKit
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
InfoKit providesStrongly Typed access to theInfo.plist with less than 60 lines of code, while leveragingSwift 4's powerfulCodable capabilities.
Installation >>instructions <<
Define aCodable with the properties you wish to access from the project's bundleInfo.plist file.
structInfo:Codable{letbaseUrl:StringletstaticUrl:String}
And read the Info.plist into theInfo struct:
// Define a Plistletplist=Plist<Info>()// Decode itletinfo= plist.decode()// Then access it's propertiesinfo?.baseUrl // http://debug.InfoKit.localinfo?.staticUrl // http://debug.static.InfoKit.local
For convenience,InfoKit will also provide access to custom .plist files. Let's say you included aProductIDs.plist file. Start by defining the struct with it's respective properties.
structProducts:Codable{letfoo:Stringletbar:String}
Define aPlist, and this time,specify the resource name. e.g.ProductIDs
letplist=Plist<Products>("ProductIDs") // Reads `ProductIDs.plist`letproducts= plist.decode()products?.foo // com.InfoKit.fooproducts?.bar // com.InfoKit.bar
Remember, user provided property lists must be copied into the bundle, so make sure to set it's
Target Membership.
InfoKit will default to theMain Bundle, however, you canspecify the bundle, if needed:
Plist<Products>("ProductIDs", in: bundle)
Ifno resource or bundle is specified in the initializer of thePlist class, like so:
Plist<Info>()
...then,InfoKit will default to the Main Bundle's Info.plist file defined in the Project's Build Settings.
Because of this, you can providemultiple Info.plist files fordifferent configurations and still get the desired results.See the iOS Example project in action by choosing between thedebug,staging andrelease configurations.
InfoKit is released under the MIT license. SeeLICENSE for details.
Review/TranslateREADME.zh-CN.md to Chinese
Chinese is the #1 spoken language in the world and I'd love to have InfoKit be more inclusive, unfortunately I don't speak Chinese. If you know chinese, and would like to help out, please seeissue #1
Thank you 🙏
About
Strongly Typed access to the Info.plist for iOS, macOS and tvOS.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors2
Uh oh!
There was an error while loading.Please reload this page.
