Giter Club home page Giter Club logo

infokit's Introduction

InfoKit

cocoapods compatible carthage compatible language swift

简体中文

InfoKit provides Strongly Typed access to the Info.plist with less than 60 lines of code, while leveraging Swift 4's powerful Codable capabilities.

Installation >> instructions <<

Usage

Define a Codable with the properties you wish to access from the project's bundle Info.plist file.

struct Info: Codable {
    let baseUrl: String
    let staticUrl: String
}

And read the Info.plist into the Info struct:

// Define a Plist
let plist = Plist<Info>()

// Decode it
let info = plist.decode()

// Then access it's properties
info?.baseUrl    // http://debug.InfoKit.local
info?.staticUrl  // http://debug.static.InfoKit.local

Custom .plist

For convenience, InfoKit will also provide access to custom .plist files. Let's say you included a ProductIDs.plist file. Start by defining the struct with it's respective properties.

struct Products: Codable {
    let foo: String
    let bar: String
}

Define a Plist, and this time, specify the resource name. e.g. ProductIDs

let plist = Plist<Products>("ProductIDs") // Reads `ProductIDs.plist`
let products = plist.decode()

products?.foo // com.InfoKit.foo
products?.bar // com.InfoKit.bar

Remember, user provided property lists must be copied into the bundle, so make sure to set it's Target Membership.

Specify a Bundle

InfoKit will default to the Main Bundle, however, you can specify the bundle, if needed:

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

Build Configurations

If no resource or bundle is specified in the initializer of the Plist 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 provide multiple Info.plist files for different configurations and still get the desired results. See the iOS Example project in action by choosing between the debug, staging and release configurations.

License

InfoKit is released under the MIT license. See LICENSE for details.

Help Wanted

Review/Translate README.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 see issue #1

Thank you 🙏

infokit's People

Contributors

nmdias avatar shaobaili3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

infokit's Issues

Translate README 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, I'd be eternally grateful.

Pull Requests to the README.zh-CN.md are super welcome

Thank you 🙏

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.