How to use environment variable in project.pbxproj file? - ios

I have a react native application built and distributed through microsoft appcenter. for the iOS side, I have a release variant which is the live production variant. and i have a staging variant. the git flow im trying to achieve is something like this:
create feature branch from either master or staging (for the sake of
this argument) -->
push OTA update to staging variant -->
merge staging variant into master (this is the key part)
I want to be able to merge staging into master without having to manually set the defaultConfigurationName each time i pull staging into master, or push the master-branched-feature-branch to staging. I want a dynamic value: master's value to always be 'release' and staging to always be 'staging'.
Problem:
When merging staging branch into master branch (production), the defaultConfigurationName in project.pbxproj changes the variant that will be built by microsoft appcenter from the release variant (production) to the staging variant
lets say i have an env variable called "ENVIRONMENT", with values of 'release' and 'staging', corresponding to 'master' and 'staging branches. i want to automate management of the ios build configuration when merging staging into master, and not have to manually reset defaultConfigurationName back to 'release' each time i merge staging into master. how can i set the env variable's value to the value of "defaultConfigurationName" in project.pbxproj file?
Note: i dont need help setting up environments or environment variables. i also dont want to create an additional target.

I came across this issue and found that you can update the info.plist file found in ios/app/app/info.plist to include your environment variables.
Eg
<key>CFBundleVersion</key>
<string>$(CAPACITOR_BUILD_NUMBER)</string>

Please have a look at this blog post, it shows how to set up multiple environments for android and iOS.

Related

Add new environment to an existing release-build

I have release build that has been kicked off already, this build was kicked-off it went through QA and staging environment successfully, the users were happy with the app on both these environments. I then added the last environment that is production. Now my question is, is there a way of getting the current build to see that there is an extra environment added, at the moment it looks like the production deployment does not exist yet I know its there, here is the screenshot of the prod environment that was added
The below screen illustrate that the app deployed succcessfully to the other environments but the prod environment does not appear, the area highlighted in red is where I am expecting my prod environment to appear
I understand queuing or kicking off a new build would make the prod environment appear but I wonder if is there a way to let the current release that there is new environment added.
No. The pipeline is locked in when the release is created. You can create a new release using the same build that you'd previously deployed to lower environments. That will pick up the production environment that you added to the release definition.
I don't think already running releases will have PROD environment aded

Keep same project source for development and production

I have an general query about maintaining our project. Our project has some code changes between development source and production source. That is production source has live database configuration in web config, and payment checkout mode set to production in some class files. But in development source these are set to testing environment. Other than those both the development and production has same codes. Because of having difference between development and production source, we have to keep these source separately and work on two sources to publish any changes. We are frequently doing any features and bug fixes and publish the changes immediately. So we couldn’t follow Gitflow model (development and master). But Github model will suit for our case because of having immediate publish after feature or bug fixes done.
The problem is Github model says to maintain master source alone. But in our case master source connected to production database, so taking branch from master also connect to production. We need our development should be done with testing configuration. How can we maintain production and testing configuration in master branch itself and switching some configuration leads to connect to testing or production. What is the best way to do this?
Thanks,
Karthik.
From my understanding, Your problem really is about how to keep test config and production config seperate.
If I am right, then here is my two cents.
Say if all your config is in web.config, why not use the config transformation, where you save your test config to git (master) and
use transform to change it to production config when publishing.
In essense, it is just creating another Web.{build profile name}.config where when you publish in that build profile, your web.config will be transorm
more detail check
https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/web-config-transformations
For configuration changes use web config transformations. You can run those enable transformations on build with Visual Studio
Use dependency injection for mocking/faking implementations. You can set some key in web.config (the value is going to be set in web config transformations) which will determine whether to use fake implementation or the real-one

Rails: creating a test website that is not local

How is a test site created with Rails 4?
I'm building a Rails 4 app. I develop locally, have a github repo, and have a live production Heroku site.
Now I want a 'test' or 'dev' site that is on the web, so all the employees working with the app can see features even before they are rolled out.
It sounds like a standard enough issue that I suspect Rails has some built in approach, making use of the "dev", "test, and "production" environment variables.
Heroku has a methodology for this --
https://devcenter.heroku.com/articles/multiple-environments
I prefer to use standard git mechanics to control the flow. On a web application we develop this really helps us. We have a reasonable sized team and what we do is:
Create a feature branch (tools like git-flow can help with keeping standards in your team)
When done we push up to our git remote, create a pull request and someone reviews the contribution. Once the changes are good they get merged into master.
As part of continuous integration (after our specs are run successfully) we have a simple Jenkins job that clean rebases into the appropriate branch and pushes to the remote.
Everyone has their own flow, but you can use your master branch as development then when you're ready merge/rebase into your other environment branches.
On your destination Rails platform (in my case Ninefold, because it's really easy), pick the branch and deploy. On Ninefold as soon as you push to your branch your app is redeployed via a Post-receive hook.
We configure up the application's environment by passing RAILS_ENV=staging / RAILS_ENV=production, and ensure you have an appropriate (environment).rb file with all the relevant settings for your environment.

How do maintain different production.rb files on different branches of the same project?

We have a Rails app that's deployed on two servers. One server uses the master branch while the other uses the staging branch. We use staging internally to test the application, and then we merge with master and deploy.
The staging branch has different email settings in config/production.rb than the master branch. How can I maintain different production.rb/email settings for each branch while still merging everything else?
Adding the file to .gitignore would pull it from the repo, so that's not an option.
Make another environment called staging.
Other option is to put the environment file in shared folder on server and link to it while deploying.
Dont put these settings into production.rb. Use an initializer file in config/initializers/email.rb (or something like that) to set these initial settings based on Rails.env

git repository move rails application code to live to test repositories

Hello I am having Two Branches on Github for the Rails Application.
One is Test and Other is Live.
Problem is Live branch is having the latest changes on it and Test is not having the lates changes.
so I want to transfer the code from Live to test on github.
Both the environment having different Database name and having different deploy.rb file with their environment.
So my concern is how to update the Test environment code with live environment code without changing the database and deploy.rb file.
Please Help me.
Thanks.
You could put a merge driver which would always keep your local version for those two files (deploy.rb and database.yml).
See as an example "How do I tell git to always select my local version for conflicted merges on a specific file?".
You can declare that merger driver in a .gitattributes file, which mean it will be published from upstream repo to upstream repo (as opposed to a git config solution which would be purely local to your repo)

Resources