Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Give access to .env
environment variables file within your iOS projects.
dotenv-ios
is a simple CLI tool you can run on each XCode build to inject environment variables into your iOS app. This tool was inspired by the twelve-factor app to make environmental changes in your app simple.
Note: At this time, only Swift is supported.
gem install dotenv-ios
In the root of your iOS project, create a .env
file and store all of the environment variables you wish inside. (Make sure to add this file to your .gitignore
to avoid checking it into source control!)
In your iOS app's source code, reference environment variables that you want to use:
let apiHost: String = Env.apiHost
At first, XCode will complain that Env.apiHost
cannot be found. Don't worry. We will be fixing that. dotenv-ios
CLI crawls your source code looking for Env.X
requests and generating a Env.swift
file for you! Anytime you want to use environmental variables, you just need to add it to your source. Super easy.
First, create a bash script in your project (for example purposes here, we created a script named, dot_env_ios.rb
in the root of the project. It's important to put it there so dotenv-ios can find the .env
file in the root):
#!/usr/bin/env ruby
require 'dotenv'
Dotenv.load('.env')
`bundle exec dotenv-ios --source #{ENV["SOURCE_CODE_DIRECTORY"]}`
You will notice above that I am also using the dotenv
ruby gem to make life even easier storing a variable SOURCE_CODE_DIRECTORY
in .env
I can use in this script.
Now, back to XCode build scripts. Leave the shell as the default, /bin/sh
and have the script in XCode simply execute your bash script you just made:
./dot_env_ios.rb
Done!
Note: It's highly recommended you checkout this quick doc on how to run ruby scripts within XCode as you may encounter issues along the way.
Run a build in XCode (Cmd + B) to run the dotenv-ios
CLI tool.
Add the newly generated PathToYourSourceCode/Env.swift
file to your XCode project.
Done!
$> bundle install
You're ready to start developing!
This gem is setup automatically to deploy to RubyGems on a git tag deployment.
RUBYGEMS_KEY
secret to Travis-CI's settings.dotenv-ios is open for pull requests. Check out the list of issues for tasks I am planning on working on. Check them out if you wish to contribute in that way.
Want to add features? Before you decide to take a bunch of time and add functionality to the library, please, [create an issue] (https://github.com/levibostian/dotenv-ios/issues/new) stating what you wish to add. This might save you some time in case your purpose does not fit well in the use cases of this project.
FAQs
Unknown package
We found that dotenv-ios demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.