Live data from Hacker News

Is it possible to write plain C iOS app in 2025?

news.ycombinator.com

21–30 of 74 posts

Re: Is it possible to write plain C iOS app in 2025?

#21
post #14

There is Objective-C++ (.mm extension), which I used extensively, where you have what is essentially a C/C++ implementation file, but you can use types and syntax from Objective-C, e.g. allowing you to call iOS APIs (UI, bluetooth, etc). Disk acccess can be done directly without objective C. Also network access. It is surprisingly unrestricted. This was a year or two ago. You need to get a path string to the app's Do…

Objective-C is a C superset, while Objective-C++ is a C++ superset, where C++ is a mostly C superset. You're not really buying anything using Objective-C++ by adding another form of OOP, except perhaps for interop with C++.

Re: Is it possible to write plain C iOS app in 2025?

#22

Objective-C is designed in such a way that, generally speaking, anything you can do with Objective-C syntax can also be done with a simple C function call to one of the Objective-C runtime functions. So you can write an entire iOS app in pure C. However, the Objective-C stuff is a lot more pleasant to use if you use the syntax for it. As others have mentioned, for something like a simple game (rather than a normal GU…

On macOS there used to be Carbon, which is technically gave a C API. It could technically be used (although they stopped supplying header files) until the 32-bit deprecation. Still, I think maybe as a legacy of that a lot of Cocoa APIs do have private Core* equivalents, so if you're willing to do a lot of reverse engineering it might be possible to skip even the objc runtime.

Re: Is it possible to write plain C iOS app in 2025?

#23
post #15

Earlier quoted context omitted.

Clang has a pretty cool flag to compile objc to c. I believe it exists for Apple to port their few apps to windows (eg iTunes), but I suspect it could be used to build a pure c environment as well.

That is very cool, I think it's `-rewrite-objc`. Presumably it still needs to be linked to the objc runtime. It says it lowers to C++ instead of C though, now I wonder what pieces cannot be implemented using pure c.

I don’t think it really works anymore, unfortunately.

Re: Is it possible to write plain C iOS app in 2025?

#25

Here is the original StackOverflow question that inspired that GitHub project: https://stackoverflow.com/questions/10289890/how-to-write-io... One of the other answers also explains how to write a MacOS app using pure C.

> “A Real Programmer would do this using ARM assembler.”

Re: Is it possible to write plain C iOS app in 2025?

#27
post #14

There is Objective-C++ (.mm extension), which I used extensively, where you have what is essentially a C/C++ implementation file, but you can use types and syntax from Objective-C, e.g. allowing you to call iOS APIs (UI, bluetooth, etc). Disk acccess can be done directly without objective C. Also network access. It is surprisingly unrestricted. This was a year or two ago. You need to get a path string to the app's Do…

If you just need C instead of C++ then .m suffices, ojective-c is a strict superset of C.

It‘s a superset of ANSI-C. One needs to be carful to mention this. I‘m not aware that this had changed and also added some small grieve back in the days for me. But I sadly can‘t remember anymore what didn‘t work for me.

Re: Is it possible to write plain C iOS app in 2025?

#28

Earlier quoted context omitted.

That is very cool, I think it's `-rewrite-objc`. Presumably it still needs to be linked to the objc runtime. It says it lowers to C++ instead of C though, now I wonder what pieces cannot be implemented using pure c.

I don’t think it really works anymore, unfortunately.

It doesn't support ARC so it's not very useful.

Re: Is it possible to write plain C iOS app in 2025?

#29
Yes, technically it's possible by wrapping the ObjC runtime API, see solutions like these:

- https://github.com/garettbass/oc

- https://github.com/mitchellh/zig-objc

Whether that's better than writing ObjC directly is another question, think of ObjC as a convenient syntax sugar wrapper around macOS/iOS APIs which you only need in those parts of your application that talk directly to operating system APIs.

Also Apple is maintaining a C++ Metal API wrapper now (ok, technically that's not C): https://developer.apple.com/metal/cpp/

If you just want do to simple 'game-y stuff' (3D rendering, audio, low level touch input) you can also check out the Sokol headers (shameless plug): https://github.com/floooh/sokol, or I guess SDL will work too (especially with the new GPU API in SDL3) - at least the sokol header implementation code needs to be compiled as ObjC on macOS/iOS though (e.g. pass `-x objective-c` to Clang), since the macOS/iOS specific code paths are written in ObjC.

For the general case or when you need to access OS frameworks that are not wrapped by 3rd-party libraries:

If your app is mainly C code, have a thin layer of ObjC code that sits on top of the system ObjC APIs and which exposes a C API to the rest of the application.

Don't just tunnel every ObjC call through to C, instead wrap small feature blocks in ObjC and expose those features through a much simplified C API.

E.g. a hybrid C/ObjC application with only the necessary amount of ObjC code for talking to OS APIs, and all the 'business logic' in C (or another language, like C++, Zig or Rust).

Re: Is it possible to write plain C iOS app in 2025?

#30
post #26

objective-c is an ugly thing. a main reason i dont develop for macos.

Modern ObjC is nowhere near the level of ugly that it once was. (And even then it was never that bad)

Not to mention you should probably opt for Swift first anyway, ObjC hasn’t been the default choice for quite some time now. ;P

Post reply on HN