tags:

views:

345

answers:

1

I have written a couple Core Data iPhone apps and I've run into a consistent problem that I would expect to be a common pattern for iPhone development. Namely, I have one or more command line data loaders to create the Core Data database and then I have my iPhone app. Since the model files are shared and the loaders are a integral part of the project, I want it to be a single project.

What is the right approach to create a project with an iPhone OS target and a command line target? All my attempts have not worked well -- I have code signing, debugging, and configuration troubles.

Here's my best attempt so far:

  • Create an iPhone project
  • Add a new Cocoa Shell Tool target
  • Change the base SDK to "Current Mac OS" in the target's build configuration

At this point I have no executable. (By contrast, if you create a new Command Line Utility project then an executable is automatically associated with your target.)

If I create a Custom Executable then I have a few troubles: (1) changing the target doesn't change the executable because you can't link a custom executable to a target, (2) debugging the command line program is problematic because breakpoints set in XCode don't get registered (the chevrons at the line numbers turn orange when debugging the executable), so I have to break into the running code and then handle debugging manually from the console, (3) most frustratingly, if I create a properly provisioned distribution version of my iPhone app, then transferring the iPhone app to the device fails complaining that the provisioning profile doesn't match the Code Signing Entitlement. This is definitely not the case because I set the provisioning profile and entitlement file for only the distribution version of the iPhone target, but no matter how much fiddling I can't get the target installed on devices. (If I create a new project with identical code and code signing withOUT the command line tool then I can install an AdHoc provisioned app.)

So... is there some other pattern I should be following? Xcode configurations are serious voodoo.

A: 

Note of one interesting thing.

If you make a Mac OS X app project, and add a new iOS app target, you can switch both of them! You can even compile both of Mac OS X/iOS targets.

BUT!!!

It's only for iOS device platform. If you choose simulator once, the project fixed to iOS app, never compile for Mac OS X again. (you still can choose Mac OS X app target, but it does not being compiled anymore)

So it's unusable.

One more thing...

Close your Xcode. If you see inside of .xcodeproj folder, you can see several files. And you can find a .pbxuser file. Open it with text editor, and find a line activeSDKPreference=... If there it is, erase the line, and save the file. Re open the project with Xcode. Oops! it's reset! You can compile Mac OS X target again!

Eonil