Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

This question already has an answer here:

I have the following situation: I have Mac OS bundle with application which uses some 3rd party dylib's and those dylib's depend on some env variable, let's name it ENV_VAR. I want to set ENV_VAR to some value for my application only because if I set it for the whole system it may breaks some other apps. And it should work transparently to the user i.e. he just run my app from the Application folder by double clicking it. How can I achieve it?

NOTE: dylibs are loaded before main functions starts hence setting this variable in the main doesn't help

share|improve this question

marked as duplicate by bmike Apr 24 '13 at 15:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
If you want to edit in precise details why this isn't covered elsewhere, feel free to edit those details in to the text of the question and flag this for further review. Depending on where you take this, it might be a SO question if your code isn't reading the variables being set, but it could also remain here if it's a bug in the OS. Hard to tell without more details... –  bmike Apr 24 '13 at 15:50

1 Answer 1

up vote 1 down vote accepted

By "main", do you mean the Info.plist file of your .app ? That's Apple recommandation so far: https://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW1

share|improve this answer
    
by main I mean C\C++ entry function. I've tried to add LSEnvironment to my Info.plist but getenv still returns an empty string hence it doesn't help. –  ixSci Apr 24 '13 at 8:10
    
This answer is correct and it didn't work for me due to Info.plist caching. –  ixSci Apr 25 '13 at 10:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.