From: Brian M. <ma...@ex...> - 2008-02-07 19:01:57
|
Using RubyCocoa from Leopard (10.5.1) : You can declare environment variables in a Cocoa app's Info.plist file like this: <key>LSEnvironment</key> <dict> <key>VEX</key> <string>acious!</string> </dict> In an Objective-C app, that value carries over into the environment: NSDictionary *env = [[NSProcessInfo processInfo] environment]; NSLog(@"====Here is the value of VEX in the processInfo environment: %@", [env objectForKey:@"VEX"]); NSDictionary *lsEnv = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"LSEnvironment"]; NSLog(@"====Here is the value of VEX from the Info.plist environment: %@", [lsEnv objectForKey:@"VEX"]); Feb 7 12:34:56 frex Test[1660]: ====Here is the value of VEX in the processInfo environment: acious! Feb 7 12:34:56 frex Test[1660]: ====Here is the value of VEX from the Info.plist environment: acious! However, the value from Info.plist doesn't seem to make it into ENV. More surprisingly, it doesn't make it into the Cocoa processInfo environment: $stderr.puts "==== Here is the value of VEX in the environment:" $stderr.puts ENV['VEX'].inspect $stderr.puts "==== The value of VEX in the processInfo environment:" cocoa_env = NSProcessInfo.processInfo.environment $stderr.puts cocoa_env.objectForKey("VEX") $stderr.puts "==== The value of VEX in Info.plist:" plist_env = NSBundle.mainBundle.objectForInfoDictionaryKey("LSEnvironment") $stderr.puts plist_env.objectForKey("VEX") Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: ==== Here is the value of VEX in the environment: Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: nil Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: ==== The value of VEX in the processInfo environment: Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: nil Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: ==== The value of VEX in Info.plist: Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: acious! ----- Brian Marick, independent consultant Mostly on agile methods with a testing slant www.exampler.com, www.exampler.com/blog, www.twitter.com/marick |
From: kimura w. <ki...@us...> - 2008-02-09 00:56:35
|
Hi, It works for me on 10.5.1. LSEnvironment is available for apps launched via Launch Service. - double-click in Finder - launch with "open" command LSEnvironment is not available without Launch Service. - "Run" on Xcode - execute YourApp.app/Contents/MacOS/YourApp directly On Thu, 7 Feb 2008 13:01:14 -0600, Brian Marick wrote: > Using RubyCocoa from Leopard (10.5.1) : > > You can declare environment variables in a Cocoa app's Info.plist file > like this: > > <key>LSEnvironment</key> > <dict> > <key>VEX</key> > <string>acious!</string> > </dict> > > In an Objective-C app, that value carries over into the environment: > > NSDictionary *env = [[NSProcessInfo processInfo] environment]; > NSLog(@"====Here is the value of VEX in the processInfo > environment: %@", > [env objectForKey:@"VEX"]); -- kimura wataru |
From: Brian M. <ma...@ex...> - 2008-02-15 17:04:58
|
Your code snapshot works for me. I've done some reorganization of my files, and now I can only find the Objective-C version of my test program, even in Time Machine. Trying to reconstruct the Ruby version produces a program that also works. Most likely I did something wrong. Sorry for the false bug report. On Feb 8, 2008, at 6:56 PM, kimura wataru wrote: > Hi, > > It works for me on 10.5.1. > LSEnvironment is available for apps launched via Launch Service. > - double-click in Finder > - launch with "open" command > > LSEnvironment is not available without Launch Service. > - "Run" on Xcode > - execute YourApp.app/Contents/MacOS/YourApp directly > > > On Thu, 7 Feb 2008 13:01:14 -0600, Brian Marick wrote: >> Using RubyCocoa from Leopard (10.5.1) : >> >> You can declare environment variables in a Cocoa app's Info.plist >> file >> like this: >> >> <key>LSEnvironment</key> >> <dict> >> <key>VEX</key> >> <string>acious!</string> >> </dict> >> >> In an Objective-C app, that value carries over into the environment: >> >> NSDictionary *env = [[NSProcessInfo processInfo] environment]; >> NSLog(@"====Here is the value of VEX in the processInfo >> environment: %@", >> [env objectForKey:@"VEX"]); > -- > kimura wataru > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk ----- Brian Marick, independent consultant Mostly on agile methods with a testing slant www.exampler.com, www.exampler.com/blog, www.twitter.com/marick |
From: Brian M. <ma...@ex...> - 2008-02-09 18:56:56
|
On Feb 8, 2008, at 6:56 PM, kimura wataru wrote: > Hi, > > It works for me on 10.5.1. > Can you send me the App bundle you used? I want to see what I'm doing differently. ----- Brian Marick, independent consultant Mostly on agile methods with a testing slant www.exampler.com, www.exampler.com/blog, www.twitter.com/marick |
From: kimura w. <ki...@us...> - 2008-02-10 02:57:54
|
Hi Brian, I uploaded an archive of the Xcode project I tested onto the following URL. http://kirika.la.coocan.jp/archive/misc/LSEnv.zip On Sat, 9 Feb 2008 12:56:41 -0600, Brian Marick wrote: > > On Feb 8, 2008, at 6:56 PM, kimura wataru wrote: > >> Hi, >> >> It works for me on 10.5.1. >> > > Can you send me the App bundle you used? I want to see what I'm doing > differently. > -- kimura wataru |