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

  • 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

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

  • 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 .