Skip to content

Installation

Swift

Download and install Swift 5.3 or higher.

Swift Package Manager

New Package

This creates a new executable package named MyPackage.

mkdir MyPackage
cd MyPackage
swift package init --type executable

Package Manifest

Add the DotEnv package as a dependency by specifying its name, url, and version.

dependencies: [
    .package(name: "chaqmoq-dotenv", url: "https://github.com/chaqmoq/dotenv.git", from: "1.0.0")
]

Add the DotEnv target to your desired target as a dependency by specifying its name and package where you want to import and use it. In this case, we are adding it to the default target named MyPackage generated using the swift package init command we executed earlier.

targets: [
    .target(name: "MyPackage", dependencies: [
        .product(name: "DotEnv", package: "chaqmoq-dotenv")
    ])
]

Build

This builds the MyPackage and installs the DotEnv package with the Debug configuration needed for development.

swift build

Once you are ready to deploy, you can run the command below that builds the MyPackage and installs the DotEnv package with the Release configuration optimized for production.

swift build -c release

Xcode Project

  1. Open your Xcode project.
  2. Go to File -> Swift Packages -> Add Package Dependency.
  3. Enter the DotEnv package URL: https://github.com/chaqmoq/dotenv.git.
  4. Choose the version you want to install. We suggest installing the latest stable version by using the Up to Next Major strategy.
  5. Add the DotEnv package to your desired target of the MyPackage where you want to import and use it.