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.2
Property wrapper that allows you to access build settings values through the `infoDictionary` property of Foundation’s `Bundle` API.
⭐️ 2
🕓 46 weeks ago
.package(url: "https://github.com/AnasAlhasani/XcodeConfig.git", from: "1.0.2")

@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.

Installation

CocoaPods

To integrate XcodeConfig into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'XcodeConfig', :git => 'https://github.com/AnasAlhasani/XcodeConfig'

Then, run the following command:

$ pod install

Swift Package Manager

To integrate XcodeConfig into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:

dependencies: [ 
    .package(url: "https://github.com/AnasAlhasani/XcodeConfig.git", from: "1.0.1")
]

Author

Anas Alhasani

GitHub

link
Stars: 2
Last commit: 46 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Version 1.0.1
1 year ago

Added BundleProvider abstraction.

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