Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Strongly Typed access to the Info.plist for iOS, macOS and tvOS.

License

NotificationsYou must be signed in to change notification settings

nmdias/InfoKit

Repository files navigation

InfoKit

cocoapods compatiblecarthage compatiblelanguageswift

简体中文

InfoKit providesStrongly Typed access to theInfo.plist with less than 60 lines of code, while leveragingSwift 4's powerfulCodable capabilities.

Installation >>instructions <<

Usage

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

Custom .plist

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'sTarget Membership.

Specify a Bundle

InfoKit will default to theMain Bundle, however, you canspecify the bundle, if needed:

Plist<Products>("ProductIDs", in: bundle)

Build Configurations

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.

License

InfoKit is released under the MIT license. SeeLICENSE for details.

Help Wanted

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

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp