views:

72

answers:

2

This question comes from this other one I asked earlier: http://stackoverflow.com/questions/3180574/calling-custom-objective-c-from-a-pyobjc-application

I want to re-use a small part of the app logic from my iPhone app in its server-side component, which runs on OSX. Based on what I was told in the other question, it looks like I need to compile a "framework" for both iOS and OSX from this little piece of app logic.

If we assume that I am able to isolate all the code that is to be in this framework into a single .h/.m pair of files that has no other non-Cocoa dependencies, what would be the easiest way in XCode to build this framework for each architecture and avoid double-coding all this logic on the server?

I tried adding a new OSX framework build target to my iPhone project, but this doesn't get very far and XCode bails out pretty quickly with:

target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphonesimulator' platform

Any help much appreciated, as I am currently dupe-implementing to keep things moving forward, but this is pretty obviously becoming a huge waste of time and source of errors when the implementations become slightly out-of-sync.

+1  A: 

Depends on what you used in your custom class. If you did not use anything from UIKit / AppKit then the class is probably going to live well on either platform, otherwise, you’d have to use target conditionals and include separate code specially written for both platforms.

You can have multiple targets in one Xcode project, their Base SDK set separately for the Mac / iDevices.

Evadne Wu
Hi Evadne, yes there is nothing from AppKit in the class that would require conditional #includes to make it work on OSX. I tried setting up the additional target in XCode with (Architectures = 32/64-bit Universal) and (Base SDK = Current Mac OS) but still got the error mentioned in my original post. Is there anything else that needs to be done in the project config to make this work within a single XCode project that you can think of?
glenc
A: 

Adam's comment to my original question answers this question. Although still interested to see if there is a way to do it all from a single XCode project, the solution I have now is plenty good enough for what I wanted to achieve.

glenc