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: Bayes Scott F <email@hidden>
- Date: Thu, 03 Nov 2011 12:49:08 -0700
> Furthermore, when launching Terminal.app with a script, say from a Xcode Post-action like this:
>
> open -a Terminal.app path/to/theScript
>
> Terminal.app opens a new window and executes the script in the shell, which is nice. However, non of Xcode's Build settings are available in the script "theScript" and I don't know how to export them. Any ideas?
>
> I could however export DYLD_FRAMEWORK_PATH as I desire *within* "theScript" and then source the unit test. But unless I get also Xcode's Build settings, this is useless since I need the path to the AllTest executable which is located in $(BUILD_PRODUCTS_DIR).
It feels like maybe the whole approach is wrong, though unfortunately I don't know what's right, not having done Unit Test or a console app under Xcode, nor grokked the fullness of Schemes yet.
Wish I could help, but I think I know shells much better than I know the deeper details of Xcode 4.
ScottB
On Nov 3, 2011, at 12:07 , Andreas Grosam wrote:
>
> On Nov 3, 2011, at 6:04 PM, Bayes Scott F wrote:
>
>> Hi Andreas,
>>
>> Is it feasible to put the env variable into .bash_profile or somewhere like that, depending on whether you get a login shell?
> Well, of course.
>
> I tried several approaches, even using launchctl sentenv. Environment variables will be correctly inherited - except DYLD_FRAMEWORK_PATH. Experimenting with random variables yield the expected results. However, there seems to be e special rule for DYLD_FRAMEWORK_PATH in launchctl. If DYLD_FRAMEWORK_PATH is set to what I need and when launching Terminal, the shell won't know about it, but every other random variable appears.
>
> Furthermore, when launching Terminal.app with a script, say from a Xcode Post-action like this:
>
> open -a Terminal.app path/to/theScript
>
> Terminal.app opens a new window and executes the script in the shell, which is nice. However, non of Xcode's Build settings are available in the script "theScript" and I don't know how to export them. Any ideas?
>
> I could however export DYLD_FRAMEWORK_PATH as I desire *within* "theScript" and then source the unit test. But unless I get also Xcode's Build settings, this is useless since I need the path to the AllTest executable which is located in $(BUILD_PRODUCTS_DIR).
>
>
>
> Andreas
>
>>
>> I suspect the export in your script is executing in a sub-shell, and that environment disappears before you reach the following cd. The classic solution is either to put the env variable into a standard startup file for the shell as above, or to stick it into a separate specialized file, e.g. ~/.testenv, and replace your export line with the shell's "sourcing" command, "."
>>
>> . ~/.testenv
>>
>> There's also a third-party System Preferences panel (probably available on MacUpdate) called Environment Variables that seems to set up your login environment with the values you put into it. You can bypass it by editing ~/.MacOSX/environment.plist apparently. Requires logout/in, so is very sticky and global for your account.
>>
>> ScottB
>>
>> On Nov 3, 2011, at 08:51 , 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>
>>>
>>> I have no issue setting up the arguments and environment variables in the Scheme editor, and launching the executable from Xcode works fine, or launching the executable from within Terminal.app (after setting the DYLD_FRAMEWORK_PATH).
>>>
>>> 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:
>>>
>>> dyld: Library not loaded: <path to library>
>>> Reason: image not found
>>> Trace/BPT trap: 5
>>> logout
>>> [Process completed]
>>>
>>>
>>> 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.
>>>
>>>
>>> The following script works from within a post action in Xcode when directly invoking the executable:
>>> export DYLD_FRAMEWORK_PATH=/Users/path/to/library
>>> cd ${BUILT_PRODUCTS_DIR}
>>> ./AllTests
>>>
>>> The output goes to the Console.app, though.
>>>
>>> So, how can I launch Terminal with proper environment variables set - or get this to work by other means?
>>>
>>>
>>> Thanks in advance for tips!
>>>
>>> Andreas _______________________________________________
>>> 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
>>
>
> _______________________________________________
> 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
_______________________________________________
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