Setting per-build DefaultValue in Settings.bundle/Root.plist - xcode

I have two custom build configs development and release with some values defined. Here is what my Development.xcconfig looks like:
//
// Development .xcconfig
//
// Include Pods config.
#include "Pods/Target Support Files/Pods-MyApp/Pods-MyApp.debug.xcconfig"
// Server URL
HOST_NAME = 127.0.0.1:6060
// Use TLS (https, wss)
USE_TLS = NO
// App Settings
APP_NAME = MyApp (test)
APP_BUNDLE_ID = co.my-domain.myapp-test
I reference these values in Info.plist as $(HOST_NAME) and it works fine. But I also want to expose these custom parameters in application preferences as DefaultValue. I.e. I want the app to use localhost:6060 as default host name preference when the target is development and the address of production host when the target is release.
The preferences are defined in Settings.bundle/Root.plist. Unfortunately xcode does not expand references like $(HOST_NAME) in Settings.bundle/Root.plist. I suppose I have to write a build script to update the values. I know how to use PlistBuddy to update entries in Root.plist. What I can't figure out is how to read values from Info.plist and at what point in the build process I should update Root.plist.
I can't read Info.plist early in the build because the values are not yet expanded. The host name still reads as literal string "$(HOST_NAME)".
I suppose I can read the Info.plist as the last step in the build process and then update "$TARGET_BUILD_DIR/$EXECUTABLE_FOLDER_PATH/Settings.bundle/Root.plist", but which Info.plist to read, the one at
"$TARGET_BUILD_DIR/$INFOPLIST_PATH" or the one at
"$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist"??? Does it matter? Are they always the same? Are they both always present?
Thanks!

Related

How to Prevent Project.params from Syncing when Saving

In Visual Studio SSDT, I have set up multiple Project Configurations, DEV, QA, PROD. Also, I have parameters set up for each configuration, so I can easily deploy to each environment with different parameters. However, when i edit a parameter's value and save, the new value is saved to the parameter for each configuration.
Here are the steps I followed:
First I edit the value in aNewTestParameter
Then, I save the Project.params file and switch to the QA Configuration. Notice it also has the DEV Value.
How do I prevent this save from overwriting the values in my other configurations?
You will need to add the parameter to configurations (third button above the Name field in the screen-shots). Next, set these values accordingly in the "Manage Parameter Values" window that will follow. Upon doing this, the parameter values will correspond to whichever configuration is chosen in the configuration drop-down.

Checking a remote url depending upon config

I am a new NativeScript user and I am trying to understand how to have my app make a GET call to a remote server, depending upon environment. In Java world we pass in an environment variable, but I have not found an example (that I understand) demonstrating how my NativeScript mobile app will know which environment it is running in, and how to get values based upon that.
I am presuming that I will have a config/ with files such as
prod.conf.js and dev.conf.js - and there is where I will put in my urls and other config values.
How do I get my NativeScript (which I will eventually build into iOS) to reach those values to use in an http request upon startup. Any example to direction to documentation would be greatly appreciated.
Answer:
I finally got the problem solved by using Manoj suggestion of nativescript-dev-appconfig. For any newbie looking for help, try this:
{PROJECT_ROOT}/config - create the environment files as {env}.json. These files are just json, with name-value pairs of the values you want. In may case that is
When you do your build: tns build ios --bundle --env.config {dev | test | prod }
This will take the contents of the selected env.config file (ie -env.config dev and copy it as - {PROJECT_ROOT}/app/config.json .
To use it within your code,
import config from "../config.json";
axios.get(config.MY_URL).then(result => {...}
Unfortunately using environment based config files are not officially supported but there is a plugin hook you could try.
We also have webpack based environment variable support, read more about that in the docs.

TeamCity to change template parameter without changing it in children

I have a lot of deployment configurations that are adopting root template.
And now I want to change one Parameter (environment variable) in the root template, but to pin the old value in all children deployment configuration.
The goal is to force all new deployment configuration that would be created to have a new value inside their deployment. And then step-by-step move with old deployment configuration and change this value only where it is required.
Option 1:
Create a new template with new value and use it for all new configuration. Let old configuration continues with old root template. Then incrementally you can migrate your old configuration to new template.
Option 2:
If you don't have more configuration from root template, You can change the value in the root template. The movement you change the new value That will be reflected in all children configuration. Then go to each children configuration and manually change the value(old value). I know it is a very tedious job if you have more configuration.
Instead of copying the template, you can change the parameter of your template, to set a variable value.
Your parameter will have inside the template the value of %EnvVarSomething%
Define the value at <Root> level with you old value for the parameter EnvVarSomething.
Then, you can easily migrate your configuration by overriding the parameter EnvVarSomething in each Build Configuration or Project.
Go into the root edit project settings and find the configuration template in question. at the very right of the row containing your template there should be a drop down. Inside the dropdown should be an option called copy template. Make a copy of the template with a different name and make changes to that instead. Then you will have a new template to use that doesn't have children to worry about.

Svn2Rally Connector Extension

I have used the latest connector from Rally and set it up with Task Scheduler to run periodically. It works well, however I have encountered problems when trying to extend it.
Within the config.yml file used, there is an UpdateArtifactState flag that I believe, when set to True, will make use of the statex.rb file. This file handles how the commit message from SVN is parsed. It is here that I find my problem;
I want to extend the connector to allow for the # symbol to be included in the Rally task identifier (DE55555 -> #DE5555 for example). However, upon testing this file does not seem to be used.
Question: if my assumption is correct, and the statex.rb file is merely an example and not used in execution, how can I extend the Rally Connector to pick up tags the way I see fit?
You may try the following:
make a new Ruby class and put it in to the extension subdirectory.
Example: extension/my_state_extractor.rb
in this file he has a class defined as 'MyStateExtractor'
Pattern your file from the statex.rb file.
Then, in your config in the Rally section, you'll need an entry of
StateExtractorClass : MyStateExtractor(message)
Customarily this entry will follow the entry for UpdateArtifactState : True

Per-User Defines In Xcode

My team is currently working a project. We all have to connect to specific session of our software when debugging our work. The original solution to this was to hard code the session ID into our login screens when working, but of course this meant having that stuff checked in and wiped out when doing SVN updates.
I thought setting up a User-Defined setting in Xcode would do the trick, but that turns out to be project wide as well.
Is there a way I could store this data in a per-user way, like in xcuserdata, and have it be easily editable as well? I know something like an environment variable would do the trick, but if there's some way to do this via the Build Settings, that would be great.
Why not simply use a compiler constant which can be unset when you want to test with a real session id?
To define:
To use:
NSString *sessionId;
#if USE_TEST_SESSION_ID
sessionId = TEST_SESSION_ID;
#else // !USE_TEST_SESSION_ID
sessionId = sessionIdTextEdit.stringValue; // or whatever
#endif // USE_TEST_SESSION_ID
Put the session info into a new plist file (mySession.plist) in the project folder. Add that plist file to the .gitignore. Add the plist file to the build and have the app grab it from the bundle.

Resources