3

What all languages are supported for iOS application. Is it only objective-C?

Thanks

macdev30
  • 245
  • 2
  • 3
  • 9
  • See also [Are C/C++/ObjC/JS Apple's only allowed langauges for iPhone development?](http://stackoverflow.com/questions/2603279/are-c-c-objc-js-apples-only-allowed-langauges-for-iphone-development) – Brad Larson Aug 16 '11 at 00:55
  • "Swift" is Apple's latest offering. Google that. – rghome Aug 03 '17 at 07:04

5 Answers5

5

All UIs must use UIKit, which is an Objective-C API. Back-end code can be written in C or C++ (Objective-C++ as well).

There are frameworks which provide a wrapper on top of UIKit, such as MonoTouch, which allows you to use C# to develop iOS applications. There are other solutions such as Titanium, or embedding a Lua runtime in your application.

You can also implement all of your drawing as OpenGL and use plain C or C++, with a thin Objective-C wrapper to receive touches, load system resources (files, etc) and generate the GL context.

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82
  • Thanks ! Actually i am writing library in obj-c which will be used by iOS applications. So looking for what all languages are used to develop iOS applications. Can it be C ? – If so, can you please provide me insight on how to link obj-c library with c-code base. Or how to call obj-c functions from c function. Few library methods are class methods n few are instance methods. library is having singleton object – macdev30 Aug 15 '11 at 17:16
  • Objective-C is a strict superset of C, so any C code is in fact Objective-C (but Objective-C code is not C). You cannot call Objective-C methods from C, but Objective-C can directly call C code. – Yann Ramin Aug 15 '11 at 17:19
  • ya i know about calling c functions from Obj-C. But a little confused about can i provide C wrapper APIs in my library, so that it can be used by Obj-C / C code. Likewise we can call C++ code from C, if we use "extern" in C++ APIs – macdev30 Aug 15 '11 at 17:22
  • @macdev30: There is no `extern "C"` support for ObjC - just make a normal C API (not an Objective-C API) and everything will work (provided your header uses plain C). Note that you can even have an Objective-C object cast back and forth from `void*` and `id` to make an opaque handle. – Yann Ramin Aug 15 '11 at 17:58
1

There are other solutions, e.g. Monotouch, but Objective-C is what Apple does, what most people use, and what I would recommend.

Johan Kool
  • 15,637
  • 8
  • 64
  • 81
  • Obj-C is a superset of C. You can mix them freely, and even throw in some C++, or even Obj-C++ if you are so inclined. – Johan Kool Aug 15 '11 at 17:10
1

It is possible to write an iOS app solely in C++ using a third-party framework like nui.

But I've found Objective-C and Objective-C++ to be the most productive and straightforward languages to use for iOS.

Luke
  • 7,110
  • 6
  • 45
  • 74
1

Objective-C is the officially supported language.

You can also use C# (MonoTouch), JavaScript (PhoneGap & AppCelerator), and Ruby (rhodes).

Jason
  • 86,222
  • 15
  • 131
  • 146
0

You may find various libraries that allow you to code in languages other than Obj-C. I have myself used phonegap and spiked out titanium (both allow coding in javascript). But ultimately, there is nothing better than the language supported by Apple themselves, since it gives you much flexibility and independence (from third party libraries) for coding. We (me and my team) had to abandon the phonegap and titanium code in favor of Obj-C (though that may be because of some particular needs or our project).

Sailesh
  • 25,517
  • 4
  • 34
  • 47
  • Thanks to all of you ! Actually i am writing library in obj-c which will be used by iOS applications. So looking for what all languages are used to develop iOS applications. Can it be C ? – If so, can you please provide me insight on how to link obj-c library with c-code base. Or how to call obj-c functions from c function. Few library methods are class methods n few are instance methods. library is having singleton object – macdev30 Aug 15 '11 at 17:15
  • The library you ship can't be a dylib. It has to be statically linked into other peoples iPhone apps. For a library you likely want to avoid .mm or C++ files. – Tom Andersen Aug 15 '11 at 17:32
  • As of now, it is having .m files only, objective C. But i wonder whether library can be statically linked by application which is using C code base. And then how C code base can call APIs which is written in obj-c – macdev30 Aug 15 '11 at 17:38
  • Since Obj-C is a SUPER set of C, I don't think there is any direct way of calling obj-c methods from C code. (C methods can be called just normally). I found this question related to this though: http://stackoverflow.com/questions/1061005/calling-objective-c-method-from-c-method. – Sailesh Aug 15 '11 at 17:43