Is it possible to add environment variables on Podfile
s without having to create a custom shell script to replace strings inside my Podfile
?
Example:
platform :ios, '10.0'
source 'https://github.com/CocoaPods/Specs.git'
source 'https://<USERNAME>@bitbucket.org/awesometeamname/ios-private-specs.git'
use_modular_headers!
target 'a-generic-app-name' do
use_frameworks!
pod 'MaybeFirebase'
pod 'AnotherSDK'
pod 'AlamofireOfCourse'
pod 'WhoUsesRxSwiftAnyway'
end
The reasoning behind this is that we're using a private pod spec repository that we connect to via ssh, and a developer will have to always Push or manually ignore Pushing the username, is it possible to set this via command line?
My current solution right now is that I have a script that I call instead of calling pod install
this script does the ff:
<USERNAME>
stringpod install
Environment variables help programs know what directory to install files in, where to store temporary files, and where to find user profile settings. They help shape the environment that the programs on your computer use to run.
Yes, it's possible. Remember that you can still use ruby syntax in your Podfile
. Let's assume you keep the username in env var named REPO_USERNAME
. Then your file would look like:
platform :ios, '10.0'
source 'https://github.com/CocoaPods/Specs.git'
source 'https://' + ENV['REPO_USERNAME'] + '@bitbucket.org/awesometeamname/ios-private-specs.git'
use_modular_headers!
target 'a-generic-app-name' do
use_frameworks!
pod 'MaybeFirebase'
pod 'AnotherSDK'
pod 'AlamofireOfCourse'
pod 'WhoUsesRxSwiftAnyway'
end
Usage
REPO_USERNAME=Zonily pod install
Bonus
IMO cleaner solution for your problem would be to use SSH access instead of HTTPS. Then, you can create shared SSH key for your team, or add teammates SSH public keys to the repository, so all of them will have the access. In such case, you'll use the following lines for sources:
source '[email protected]/CocoaPods/Specs.git'
source '[email protected]/awesometeamname/ios-private-specs.git'
If you believe this could work for you, just browse Bitbucket's docs to see how to use SSH keys with your repository.
Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With