Skip to content

Latest commit

 

History

History
66 lines (49 loc) · 1.62 KB

README.md

File metadata and controls

66 lines (49 loc) · 1.62 KB

@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