Objective-C/Cocoa cross platform compatibility.

Discussion in 'Mac Programming' started by Dragonlance1561, Feb 5, 2009.

  1. macrumors member


    I have been looking around on the web and I have seen mixed answers about Objective-C and Cocoa being compatible with windows and linux and other OS's. I'm thinking that Objective-C is while Cocoa is not. Am I correct?
  2. macrumors regular

    Yes, you are correct. Objective C can be compiled on any platform with a suitable compiler, including windows and linux, but Cocoa is apple specific.
  3. macrumors 603


    Depends. As far as I know Objective-C 2 is Apple only still.
  4. macrumors G4

    You are correct.

    Apple uses the Open Source gcc compiler as part of x-code. gcc runs on every computer and OS known to man (almost) and gcc does Objective-C (and C, C++, FORTRAN, Ada and Java as well). So the language itself is portable to every place that gcc runs.

    Cocoa however is Mac-only.

  5. macrumors member


    ok thanks, I'm learning C++ now, how transferable is knowledge of C++ to Objective-C? From what I have read it's quite transferable.

    Also, can anyone point me to any websites or books that will teach me to make GUI's on other OS's (mostly windows) in Objective-C and/or C++?

    I want to be able to write my source code on my mac so I can't use MS Visual C++ for windows. Linux isn't a big issue, mainly windows i want to run my programs on, and I know i can just use interface builder on mac. (but learning the hard way is always a bonus)

    EDIT!: Even better would be books or websites about making cross-platform GUI's if possible.
  6. macrumors 6502a


    Has anyone here tried using Cocotron? They claim to make a subset of cocoa multiplatform. I'd be interested to hear any experiences.
  7. macrumors 603


    Windows uses Win32 or the .Net platform to do its GUI programming. Mac OS X uses Carbon or Cocoa. No matter what you do you will need to write separate code for the GUIs for each platform.

    A better solution would be to use the Qt framework which is written in C++ and works on Windows, Mac OS X and Linux and would allow you to do all your GUI programming for all platforms on the Mac and would just require a recompile on the other platforms (assuming of course the rest of your code is platform agnostic).

    Edit : Of course this means you won't be able to use Interface Builder at all but would need to use Qt Designer to build your GUIs. See http://www.trolltech.com/qt for more information.

    Oh and as long as the applications you write are open source it is free. If you want to write commercial software you need to pay a license fee.
  8. macrumors member


    That sounds great to me. I would rather just learn C++ for now anyways.
    I am doing this for personal use and school work, no commercial use intended.

    What does agnostic mean I never seen that word before.:eek:
  9. macrumors 603


    Well when used in the religious sense it means undecided basically. So when used in the programming sense it basically means cross platform compatible as you have not decided on which platform to use. Does that make sense?

Share This Page