In the last few months twice I've wanted to access the source code of our application. The first time I did it I came up with a pretty neat hack, but it wouldn't really work in many places. The second time however, I asked the internet, and the internet replied.
TLDR: You can use your project's scheme to expose derived Xcode environment variables to your source code.
The rest of the blog post is a little bit about why I wanted to do that and what I did with it.