• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Differences between building within the IDE and via xcodebuild
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Differences between building within the IDE and via xcodebuild


  • Subject: Re: Differences between building within the IDE and via xcodebuild
  • From: Anders Bertelrud <email@hidden>
  • Date: Wed, 15 Sep 2004 10:01:59 -0700

Hello Mike,

Like other Mac OS X apps, Xcode stores its preferences (such as the build location) in the "user defaults" of the account in which you're running Xcode when you set the preferences. In the case of Xcode, the user defaults domain is 'com.apple.Xcode'. The 'xcodebuild' tool knows to look in that domain, in addition to its own domain 'xcodebuild', when you run it.

The trouble is that if you run xcodebuild using sudo, you're really running in a different account. So xcodebuild then looks in the preferences set in the 'com.apple.Xcode' domain in the root account, not in the account from which you ran the sudo. This all happens automatically, because Xcode uses Cocoa's NSUserDefaults class -- the same behaviour occurs for any command line tool that uses NSUserDefaults.

This is arguably a workflow bug, but it can also be considered the expected behavior of using 'sudo', since the command is in that case really being run in a different account. Arguably Xcode should have an additional feature such that it would try to find the 'com.apple.Xcode' domain in the account from which the user issued the 'sudo' command (assuming that it has access to them, once it's run as root -- it might not, if your account is on a remote file system). Alternatively, perhaps Xcode could ask for authentication itself, so that you wouldn't have to run the outermost xcodebuild command using sudo. I don't know how advisable that might be from a security standpoint, however.


If you run:

  defaults read com.apple.Xcode PBXApplicationwideBuildSettings

in your own account, you should see something like:

  {OBJROOT = "/Build/Intermediates"; SYMROOT = "/Build"; }

(of course, your paths may be different).


Then if you run:

  sudo defaults read com.apple.Xcode PBXApplicationwideBuildSettings

you'll probably see:

2004-09-15 09:54:43.846 defaults[3969]
The domain/default pair of (com.apple.Xcode, PBXApplicationwideBuildSettings) does not exist


That's because the second call is looking the preferences set for Xcode in the root account, not in your account.


A workaround is to then run:

sudo defaults write com.apple.Xcode PBXApplicationwideBuildSettings '{OBJROOT = "/Build/Intermediates"; SYMROOT = "/Build"; }'

(of course, substituting in your own paths). This will set those defaults in the root account as well. Of course, if you then change those paths in your own account, you would have to manually change them in the root account as well. That part is really just due to how Mac OS X user accounts work.

Hopefully this explanation helps.

Anders


On Sep 15, 2004, at 08.18, Michael Cashwell wrote:

Greetings all,

I have absolute paths set for the "Place Build Products In" and "Place Intermediate Build Files In" settings in the General tab of my Xcode (1.5) project. These are honored when I build within the IDE. But because my installed products include a root-owned kext I must build the real McCoy via "sudo xcodebuild ... install". However, when I do that those settings are ignored and the default paths are used.

I suspect I can override the BUILD_DIR and BUILD_ROOT variables by adding them to the xcodebuild command line, but I don't know those are the most basic variables from which all the other incorrect ones are derived. And even if that approach worked, it's lame because I'd be duplicating settings within my install-build script and within the project. That's just asking for mistakes down the road. I'd also be worried about what other settings I think my project file specifies that are being silently ignored by the xcodebuild tool.

Has anyone else seen this? Are these differences between an in-GUI build and a command line xcodebuild intentional and documented? Is it a bug? Does anyone know of a work around to make the environment between these two ways of building the same short of identifying the differences and duplicating a bunch of settings?

Thanks,
Mike

_______________________________________________
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


References: 
 >Differences between building within the IDE and via xcodebuild (From: Michael Cashwell <email@hidden>)

  • Prev by Date: Re: Known bugs?
  • Next by Date: XCode include references (Was: #include "xxx.inc" problem)
  • Previous by thread: Differences between building within the IDE and via xcodebuild
  • Next by thread: XCode include references (Was: #include "xxx.inc" problem)
  • Index(es):
    • Date
    • Thread