• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Runtime lookup of build variables ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Runtime lookup of build variables ...


  • Subject: Runtime lookup of build variables ...
  • From: Luther Baker <email@hidden>
  • Date: Thu, 20 Mar 2014 13:38:22 -0500

Lets say I've written a networking engine shared amongst multiple projects. For convenience, the networking engine's SDK requires paths and payloads but AUTOMATICALLY determines the hostname.

The hostname is a function of the "environment" that the application is targeting. Note that this is the core problem I am attempting to solve here - and feel free to suggest I go about this a different way.

Solution #1:

- create unique Configurations for each environment. Specifically, a "Configuration" in Xcode is "Debug" or "Release". This means I now have Dev, Test, Stage and Production configurations - and no more Debug and Release.
- add a key value pair to the app's Info.plist ... Configuration=${CONFIGURATION}
- create a scheme for each environment and then pick the corresponding Configuration ... so we end up with 4 schemes: Dev, Test, Stage and Prod each pointing to their similarly named Configuration.
- at runtime, look in the Apps bundle for the value of "Configuration"
- use that value to key into a single, shared plist file that includes hosts for all environments.

This works great, except for a few things:

- All debug symbols are lost. The "Dev" configuration was simply a name change from the original "Debug" ... and yet, values are not showing up in the debugger. The settings screen indicates that Symbols are not stripped - and yet we can't see anything in debug mode. Everything is essentially nil.

- Is "Debug" a special word?

- the other part we notice is that we're essentially duplicating work since we create 4 configs and 4 schemes. Technically, we really only need 2 configs and 4 schemes. Debug and Release are just fine ... and actually convey more information in this case per their context.

- so, instead of trying to figure out what happened to our debug info, it seems like we should revert back to Debug and Release configurations (that would feel more standard) - but we need to find a clean way to get the environment qualifier we need ... maybe ala the Schemes?


WHAT ABOUT USING SCHEMES?

- Again, we chose this way initially because Configuration=${CONFIGURATION} was an easy win. ${CONFIGURATION} was clearly available via Xcode so we captured it and then looked it up.

- Is there something similarly available for Schemes? I see that schemes have "Arguments passed on Launch" as well as "Environment Variables". Would it be reasonable to require apps using this shared library to create an environment variable per scheme that would be something like "DEPLOYMENT_ENVIRONMENT"="TEST".

- Unfortunately, things like "Analyze" and "Archive" don't provide an obvious way to include arguments or environment variables - seems like that'd cause problem in instruments? and when we go to build the actual final archive?

- I was hoping for something automatic like SchemeName=${SCHEME_NAME} that I could put in the apps Info.plist but I don't see any automatic scheme based variables via "xcodebuild ... -showBuildSettings"


WRAPUP

I'm hoping for a good, convention over configuration solution so I'd prefer not to require the client apps to follow 5 or 6 steps to get this working. Configuration=${CONFIGURATION} fit that bill nicely.

At any rate, thoughts or suggestions would be much appreciated. And thanks in advance if you actually read through all of this :-) I essentially need a some build functionality that my runtime can lookup and know "how" she was built.

-Luther

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Runtime lookup of build variables ...
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Force Xcode to code sign my unit test bundle?
  • Next by Date: Re: Runtime lookup of build variables ...
  • Previous by thread: Re: Force Xcode to code sign my unit test bundle?
  • Next by thread: Re: Runtime lookup of build variables ...
  • Index(es):
    • Date
    • Thread