Can we compile objective c on windows platform?
Quick answer: no, not to any useful degree.
Long answer: Objective-C is just a standard language, and GCC compiles it just fine. But when most people talk about Objective-C, they are including Apple's (formerly NEXTstep) libraries, as the bare language isn't too useful without them. There are projects around to let you use these libraries on non-Mac systems, for example GNUstep, but from my experience they are immature and more trouble than they are worth. I haven't looked recently, but I wouldn't spend too much effort trying to get it to work.
If your framework needs are basic, you can try cocotron, but I understand it is not yet "there" in many areas. http://www.cocotron.org/
Related
Does anyone know how to setup Objective-C with KDevelop? I've been searching and searching for a supposed "patch", which is supposed to integrate support in with the IDE, yet I haven't been able to find it.
This has been partially treated on StackOverflow already. Apart from the discussion over there, I sometimes use Emacs besides Xcode. I use Emacs for most of my editing and coding needs, and it comes with a nice Objective-C mode. Autocompletion in Xcode is the big selling point, but I just found out there is an answer on Stackoverflow as well. I haven't tried it yet, but it might be worth checking out.
I would go to GnuStep.org, and ask this question on their mailing list. They're the guys who do the most obj-c development on Linux that I know of.
I'm also interesting in developing on Linux using Objective-C. Due to the success of the language on Apple platforms, there are an increasing number of skilled Objective-C Developers whose efforts could benefit OSS if only the gap in Linux tooling were closed.
GNUstep is a fantastic effort and, along with LLVM and Clang, goes much of the way to achieving this. But: there is no modern IDE which supports Objective-C in Linux. ProjectCenter is the official GNUstep IDE but honestly it is showing its age.
JetBrains seem to be in the best position to change this situation: they are producers of the foremost Objective-C IDE for iOS: AppCode, and have just released a C/C++ IDE for Linux called CLion. If enough interest is shown, perhaps they would consider integrating Objective-C support from AppCode into CLion. Compiling against GNUstep, this would breathe new life into cross-platform Objective-C development.
I would encourage anyone interested in this possibility, to sign into JetBrains request tracker and vote for this issue: https://youtrack.jetbrains.com/issue/CPP-3353
Is there a REPL for Objective-C?
I am learning Objective-C and am sorely missing a REPL, coming from a Python background.
F-Script provides a Smalltalk-inspired REPL for Cocoa development, and Nu provides a Lisp-based one. F-Script seems a bit more polished and offers an object browser.
They both seem to be targeting OS X, rather than iOS development. There are scattered forum and blog posts with people describing using Nu for developing iOS apps, but they all seem to be from about two years ago. There's also a YouTube video, "Using a Scheme REPL to debug iPhone apps real-time" with a screencast of a fellow using Scheme to debug an iPhone app.
I haven't experimented with any of these technologies, but I would love to hear from anyone who has.
I just realized there's a simpler answer to all this. If you're coming from Python, and want to experiment with Cocoa in a REPL, you should just use the Python REPL. OS X ships with a Python to Objective-C bridge. Just run Python, do import objc, and you're off. There are also bridges for Ruby and Common Lisp, among others.
Of course, all these REPLs only let you write dynamic code to interact with Cocoa, but they don't let you write actual Objective-C code, and interpret it or compile it on the fly to interact with it dynamically. So none truly meets your original requirement.
When a breakpoint is triggered the debugger should pop open. When in the debugger, you can type whatever you want into gdb. You can use p [someObj someMethod] to print things out that are in scope to your breakpoint. gdb is a powerful utility well documented all over the web.
That's going to be as close as you get to what I think you are after. This is just a much clunkier thing to do in compiled languages, as there isn't any eval in Objective-C.
As far as I know, the closest you can get to a REPL at the moment is indeed through debuggers (i.e. GDB or the LLVM debugger LLDB).
For pure C, there is CCons.
Most things in Apple's Objective-C APIs (particularly Foundation) also have direct C equivalents (e.g. CFRelease(obj); is the same as [obj release];), which you can use in CCons.
CCons is built on top of LLVM and Clang, which also support Objective-C. It is probably possible to extend CCons for to also support Objective-C.
The 'trial' of CoderPad gives a public facing self-only REPL for zillions of languages including objc!!! I just used it and it's really a good sales tool for them (I'm not affiliated; they make tools for people interviewing coders). https://coderpad.io/
In the Gambit Objective-C project there seems to be an attempt to create a Scheme based REPL.
The REPL in Ruby Motion is also supposed to be good for exploratory purposes (I haven't tried it myself, though).
Yes, the REPL is in the output window.
"print object"
po object
but also execute commands which are running as app code with
expression i = 5
Read this interesting full debugging article for more information.
I googled a lot. Some people are saying do this. Some are saying it's not possible. Install Mac OS X on a virtual machine, etc., etc.
I have a simple question.
Is it possible that I can practice Objective-C programming on a Windows 7 machine?
If yes, how? Please, if possible, provide me with a necessary link. My ultimate goal is to go for iPhone development. But right now I can't afford a MacBook.
So is it possible?
Objective-C, the language, definitely yes. At the very least, GCC (GNU Compiler Collection) compiles Objective-C just fine. You can get either Cygwin for the full POSIX-like environment, or MinGW which gives just the GNU toolchain for programming to the Win23 API
But, iPhone needs the Apple API, which is totally proprietary; if they say 'No Windows', then it's just not available for Windows
Of course the iPhone API is based on Cocoa, which is based on NextSTEP. You can get the feel of the API with OpenSTEP.
But it's not iPhone.
Yes you can compile Objective-C on Windows. But for iPhone development this question was already asked.
And there are several similar questions about iPhone development here on Stackoverflow, just search for it.
It's worth taking a look at Cocotron— that aims to implement a cross-platform Apple-compatible version of the core NeXTStep libraries, the FoundationKit and ApplicationKit. Windows included.
GCC (http://gcc.gnu.org/) can compile Objective-C.
The answer is yes, but it will probably require quite a lot of work on your part:
www.gnustep.org
www.cocotron.org
This page on StackOverflow, answer 4. It worked great in my case.
Objective C for Windows
I'd like to give Objective-C a try in game programming. The problem is I'd need some tools and libraries for this.
First thing that comes into mind I need is the GUI and graphics library.
What choices do I have?
There are Four non Mac implementations of OpenStep/Cocoa type Objective C platforms:
OpenStep/NextStep : Openstep/NeXT support machines only - Discontinued.
p..... can remember name or find it on web - it's out there somewhere ! - Linux
Cocotron - Windows only
GNUStep Linux/Windows
GNUSTep is the way to go for Linux... I mention there others because 2 and 3 are available in source and they can be used to patch holes in code the GNUStep doesn't have and they might.
When it comes to Graphics library - you may have problems because Apple moved away from the old OpenStep APIs and has kept evolving their APIs far faster than the GNUStep people can play catch up. There is no support for the latest graphics libraries such as Core Animation.
As Objective C is C and C++ friendly you can use any of these libraries as is, or by making the Objective C friendly by making a wrapper.
You may or may not want to be Mac compatible and do versions for that so it may not be important.
If you do you might want to do a Linux Wrapper for something like OpenGL if it is missing, which I think it is but have a check yourself....
There are Linux development tools including a project IDE and GUI builder for GNUStep on Linux.
Tony
I believe you're asking for GNUStep.
SDL is a C library which is popular for game programming.
If you're looking for Foundation/AppKit stuff you can also look at Cocotron. I've never tried it though.
Supporting SDL there are Objective-C bindings here. However since Objective-C is a thin OO layer on top of C you can use most of the existing C libs for game development, SDL, Clanlib, etc...
I do not have a Mac, or an iPhone. However, the concept of taking C and making it more dynamic towards the idea of smalltalk, python or ruby is really attractive to me. I'd love to start on objective C.
Is objective C just a syntax superset of C or is it really like C. As in, can it be compiled with gcc etc..?
I do most of my programming in Ruby. Objective C seems so much more forgiving than C. You can write native extensions for Ruby in C. Can you write native extensions for Ruby in Objective C?
How can I get started with Objective C outside of owning an Mac/iPhone and having XCode?
Wikipedia says
Today it is used primarily on Apple's
Mac OS X and iPhone OS, two
environments based on, although not
compliant with, the OpenStep standard,
and it is the primary language used
for Apple's Cocoa API though it was
originally used as the main language
on NeXT's NeXTSTEP OS. Generic
Objective-C programs which do not make
use of these libraries can also be
compiled for any system supported by
gcc, which includes an Objective-C
compiler.
Objective-C today is often used in
tandem with a fixed library of
standard objects (often known as a
"kit" or "framework"), such as Cocoa
or GNUstep.
Maybe you should get a Linux vm if you are mainly running Windows and get GNUStep running.
apple contributed the objective c changes back to gcc (not that they had much choice, being GPL). So wherever you can set up gcc, you can set up an objective-c compiler.
Beyond that, the Gnustep environment can give you a bit of the flavor of the original OpenStep/NextStep environment.
Yes, you can write, compile and run objective c programs outside a MAC/IPhone
Please check the link below for details
http://www.otierney.net/objective-c.html#settingup
http://www.faqs.org/faqs/computer-lang/Objective-C/faq/
There's a difference between Objective-C the language, and the frameworks that Apple has built on top of it. Those frameworks consist of a bunch of objects which you can use in your code and are especially helpful if you're targeting the Mac or the iPhone. There are some similar objects for parts of it in GNUStep, but it's not a complete replacement for the Cocoa/etc library and especially doesn't cover anything iPhone related.
GNUStep and the Objective-C language (via gcc) are available for many platforms, and you can write your own programs that use Objective-C objects and interact with any C api from Objective-C.
Objective-C is a superset of C and so is not really more forgiving than C, but it is arguably more forgiving than C++ (an almost-superset of C). You can also mix Objective-C and C++ with GCC but that gets a little complicated, especially regarding exception handling.
For getting started and playing around with the language though, GNUStep and GCC would be a good way to go.
I don't see any compelling reason why you cannot use Objective C for native ruby extensions, except that you won't benefit much. You will still have to use the lower level C Api calls, since as far as i know, there aren't any ruby to objective-c bindings. Additionally, Objective C comes with a fairly substantial library of utility classes that, while helpful, won't easily justify their size and weight in the context of a ruby extension.
You can you this page for simple experiments with ObjC: http://www.codesign.cz/LearnObjC/