1

I'm trying to use xcconfig file to create different configurations for development, qa & production versions of my application. I've different api end-points for those 3 environment, so I've defined that value in my config file like:

api_url = https://api-qa.mydomain.com

But when I read back, I only get https: the remaining part will be taken as a comment and won't be treated as part of the string.

Approach 1:

api_url = "https://api-qa.mydomain.com"

Result 1:

\"https://api-qa.mydomain.com\"

Approach 2:

api_url = api-qa.mydomain.com

Result 2:

It gave me back what I've defined (api-qa.mydomain.com) and I'm prefixing https:// in front of this result in my code.


Is there any clean way to define my API url in the config file? I don't want to prefix http or https in my code (My dev runs on http & qa and production runs on https, I don't want to change it in code each and every time when I change my environment). Any help would be much appreciated

Additional resource I've referred: https://help.apple.com/xcode/#/dev745c5c974

Midhun MP
  • 103,496
  • 31
  • 153
  • 200

1 Answers1

0

How about two entries, api_host and api_scheme? You could then build the URL based on these two values, either with string concatenation, or via the URLComponents structure.

Joshua Kaden
  • 1,210
  • 11
  • 16