Re: How To Run Terminal.app from Xcode
Re: How To Run Terminal.app from Xcode
- Subject: Re: How To Run Terminal.app from Xcode
- From: Ken Thomases <email@hidden>
- Date: Thu, 03 Nov 2011 11:56:19 -0500
On Nov 3, 2011, at 10:51 AM, Andreas Grosam wrote:
> My unit test app runs as a console program. In order to run, it requires an environment variable set:
> DYLD_FRAMEWORK_PATH=<path/to/library>
> Well, now to streamline my workflow I would like to run the unit test directly after the build phase in Terminal.app. My attempts to setup the a "Post-action" in the Build section in the Scheme editor so far failed. The Terminal.app will be launched which a new window starting the required executable, but the environment variable DYLD_FRAMEWORK_PATH is not set. So,I get a dynamic linker error at runtime
> The bash script looks as follows:
>
> export DYLD_FRAMEWORK_PATH=/Users/path/to/library
> cd ${BUILT_PRODUCTS_DIR}
> open -a Terminal.app AllTests
>
> This above also fails when launched from within Terminal. It seems, the environment variables will not be inherited.
First, this only _launches_ Terminal.app if it wasn't already running. If it launches it, then Terminal.app does inherit the environment variable. If Terminal was already running, then the above doesn't affect Terminal's environment. Either way, though, the shells which are running within Terminal's windows initialize fresh environments and then sets then up using /etc/profile and the like. So, the shells effectively never inherit the environment of the Terminal process itself.
> So, how can I launch Terminal with proper environment variables set - or get this to work by other means?
You can have Terminal launch a shell which first sets the environment variable and then runs your test program. Or, you can use AppleScript to open a new Terminal window and issue individual commands to it. In that way, you can issue one command to set the environment variable and another to run the test program.
Regards,
Ken
_______________________________________________
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