Swiftpack.co - AnasAlhasani/XcodeConfig as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by AnasAlhasani.
AnasAlhasani/XcodeConfig 1.0.0
Property wrapper that allows you to access build settings values through the `infoDictionary` property of Foundation’s `Bundle` API.
⭐️ 0
🕓 32 weeks ago
.package(url: "https://github.com/AnasAlhasani/XcodeConfig.git", from: "1.0.0")

@XcodeConfig

Property wrapper that allows you to access build settings values through the infoDictionary property of Foundation’s Bundle API.

Create a build configuration file i.e Development.xcconfig:

HOST = localhost
TIMEOUT = 15.0

In your Info.plist you can reference build settings values using the following syntax $(BUILD_SETTING_NAME):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>HOST</key>
        <string>$(HOST)</string>
        <key>TIMEOUT</key>
        <string>$(TIMEOUT)</string>
    </dict>
</plist>

For example, adding @XcodeConfig like this:

enum API {
    @XcodeConfig(key: "HOST")
    static var host: String

    @XcodeConfig(key: "TIMEOUT")
    static var timeout: TimeInterval
}

will access build settings values: "localhost" and 15.0 which are defined in Development.xcconfig.

GitHub

link
Stars: 0
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Version 1.0.0
32 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics