{"id":17360204,"url":"https://github.com/dimaru/buildenvironment","last_synced_at":"2026-01-21T08:12:43.272Z","repository":{"id":257821313,"uuid":"861176305","full_name":"DimaRU/BuildEnvironment","owner":"DimaRU","description":"Use dotenv files and environment variables in Xcode and Swift Package Manager projects.","archived":false,"fork":false,"pushed_at":"2024-10-10T16:19:42.000Z","size":652,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T00:43:09.328Z","etag":null,"topics":["ios","linux","macos","obfuscation","plugin","spm","spm-plugin","swift","swiftpm","xcode","xcode-plugin"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DimaRU.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-22T07:51:45.000Z","updated_at":"2024-10-12T17:02:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"9b7a9fd2-f2f4-4df4-95c0-e40137c48fc9","html_url":"https://github.com/DimaRU/BuildEnvironment","commit_stats":null,"previous_names":["dimaru/buildenvironment"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimaRU%2FBuildEnvironment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimaRU%2FBuildEnvironment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimaRU%2FBuildEnvironment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimaRU%2FBuildEnvironment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DimaRU","download_url":"https://codeload.github.com/DimaRU/BuildEnvironment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986271,"owners_count":21194024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","linux","macos","obfuscation","plugin","spm","spm-plugin","swift","swiftpm","xcode","xcode-plugin"],"created_at":"2024-10-15T19:16:28.599Z","updated_at":"2026-01-21T08:12:43.258Z","avatar_url":"https://github.com/DimaRU.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BuildEvironment\n\n![swift-version](https://img.shields.io/badge/swift-5.8-brightgreen.svg?style=for-the-badge) ![Mac OS](https://img.shields.io/badge/-platform-gray?style=for-the-badge)![Mac OS](https://img.shields.io/badge/mac%20os-000000?style=for-the-badge\u0026logo=Apple\u0026logoColor=F0F0F0)![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge\u0026logo=linux\u0026logoColor=black)![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge\u0026logo=windows\u0026logoColor=white) ![GitHub License](https://img.shields.io/github/license/DimaRU/PackageBuildInfo?style=for-the-badge)\n\n\u003cdiv align=\"center\"\u003e\n  \u003cp\u003e\u003cstrong\u003eStore your keys and secrets away from your source code. Designed for both SPM and Xcode projects.\u003c/strong\u003e\u003c/p\u003e\n  \u003ca href=\"https://github.com/DimaRU/BuildEnvironment/releases\"\u003e\n    \u003cimg alt=\"Latest Release\" src=\"https://img.shields.io/github/v/release/DimaRU/BuildEnvironment?sort=semver\u0026style=for-the-badge\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\n## Description\n\nThe BuildEvironment project lets you store your keys and secrets away from your repository. Secrets can be stored in the `.env` file or in environment variables. Simple lightweight and functional solution, platform agnostic.\n\n\n## Usage\n\n### With Swift package :\n\n- Add the package dependency: \n```swift\n.package(url: \"https://github.com/DimaRU/BuildEnvironment.git\", from: \"1.0.0\"),\n```\n- Add plugin to the target:\n```swift\nplugins: [ .plugin(name: \"BuildEnvPlugin\", package: \"BuildEnvironment\") ]\n```\n- You may have add platform requirements:\n```swift\nplatforms: [.macOS(.v11), .iOS(.v14), .watchOS(.v7), .tvOS(.v14)],\n```\n\n### With Xcode project:\n\n- Add package dependency:  \nDon't add BuildEnv as a dependency to any target.\n![Add package dependency](screenshots/Screenshot-1.png)\n- Add plugin to the Target:\n![Add plugin to the Target](screenshots/Screenshot-2.png)\n\n#### Add  the`.env`  and/or `buildenv.config` files to the root directory of your project. \n\nOne of the files must be added. \n\n##### If only `.env` exist, code with default settings will be generated:\n- enum name: `BuildEnvironment`\n- enum access level: `public`\n- encode: no\n- variables will be taken from the `.env` file.\n\n\u003e [!caution] \n\u003e The `.env` file shouldn't be committed to git as it contains your secrets. \n\n##### If your project contain `buildenv.config`:\n- you can customize code generation options.\n- environment variables can be added.\n\n`buildenv.config` contains no secrets and can be added to the repository.\n\n## Examples\n\n###  Single `.env` file\n```bash\n# Sample api key\napiKey = \"123456\"\n```\nGenerated code:\n\n```swift\n// Code generated from .env file \n// Don't edit! All changes will be lost.\n\npublic enum BuildEnvironment {\n    public static let apiKey: String = \"123456\"\n}\n```\n\n### Both  `.env` and `buildenv.config`\n```\n# Sample BuildEnvPlugin config file\n\n# Generated enum name. Default: BuildEnvironment\nname: BuildEnvironment\n# Generated enum access level.\n# Must be one of: public, package, internal. Default: public\naccess: internal\n# Obfuscate data by encode: yes/no. Default: no\nencode: yes\n\n# Environment variable list.\n# Format: swift_variable_name=$environment_variable_name\n# Environment varibles ended in ? are optional, no code or warnings are generated. \nuserName= $USER\nhomeDir= $HOME\noptional= $OPTIONAL?\n```\nGenerated code:\n\n```swift\n// Code generated from .env file \n// Don't edit! All changes will be lost.\n\nenum BuildEnvironment {\n    static let userName: String = {\n        let encrypted: [UInt8] = [191, 121, 218, 23, 127, 221, 219, 20, 179, 99, 13, 164]\n        let count = encrypted.count / 2\n        return String(unsafeUninitializedCapacity: count) { ptr in\n            (0..\u003ccount).forEach { ptr[$0] = encrypted[$0] ^ encrypted[$0 + count] }\n            return count\n        }\n    }()\n    static let homeDir: String = {\n        let encrypted: [UInt8] = [245, 33, 241, 173, 4, 190, 7, 163, 71, 155, 203, 189, 211, 218, 116, 130, 200, 118, 205, 40, 199, 42, 242, 191, 207, 170]\n        let count = encrypted.count / 2\n        return String(unsafeUninitializedCapacity: count) { ptr in\n            (0..\u003ccount).forEach { ptr[$0] = encrypted[$0] ^ encrypted[$0 + count] }\n            return count\n        }\n    }()\n    static let apiKey: String = {\n        let encrypted: [UInt8] = [41, 83, 240, 172, 236, 228, 24, 97, 195, 152, 217, 210]\n        let count = encrypted.count / 2\n        return String(unsafeUninitializedCapacity: count) { ptr in\n            (0..\u003ccount).forEach { ptr[$0] = encrypted[$0] ^ encrypted[$0 + count] }\n            return count\n        }\n    }()\n}\n```\n\n## Sample project:\n\n- Clone the current repository\n- Enter the `BuildEnvironment` directory\n- Execute: `swift run BuildEnvExample`\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimaru%2Fbuildenvironment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimaru%2Fbuildenvironment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimaru%2Fbuildenvironment/lists"}