TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

160 点作者 iMario大约 1 个月前
I know this has been lately decaying.. most referenced are very old, such as this one: https:&#x2F;&#x2F;github.com&#x2F;richardjrossiii&#x2F;CBasediOSApp<p>Hence my question: Is it possible?

24 条评论

TazeTSchnitzel大约 1 个月前
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.<p>As others have mentioned, for something like a simple game (rather than a normal GUI application), SDL offers a convenient wrapper that allows you to avoid touching anything Objective-C-related yourself, so you could write an entire app using only the SDL API, which is pure C. A nice bonus of that approach is that it would then work on other platforms with zero code changes.<p>Another source of C wrappers is Apple themselves, as iOS has a number of C interfaces like CoreFoundation that reduce how much Objective-C stuff you have to directly interact with, but there&#x27;s nothing like that for UIKit, and every iOS app has to use UIKit at least a little.
评论 #43725534 未加载
评论 #43731810 未加载
TheNewAndy大约 1 个月前
If you just want to write C and are ok linking to stuff that is in other languages, then I used SDL2 for my game which I wrote in C and is on the app store. It was a very pleasant experience, and if I were doing an iOS thing again, I would likely do something similar.<p>I think I had one objective C file in there for calling a library function I needed, but otherwise I just wrote C code.
评论 #43724757 未加载
评论 #43728052 未加载
评论 #43724673 未加载
评论 #43728945 未加载
评论 #43727267 未加载
Frieren大约 1 个月前
Yes. And many are when you require a common code-base for iOS, Android, and other devices. (But C++ is used more commonly)<p>Video games are the ones that do this by default. It would be close to impossible to have feature parity by coding a game for iOS in Swift, for Android in Java, for Steam in C++, etc. Unreal or Unity will have C&#x2F;C++ code-bases with very light integration layers to do system calls.(The payment system may have code in Objective-C, for example, but mostly a wrapper for convenience reasons)<p>The other extreme is to just use webapps in an electron wrapper. But electron itself is build in C++.<p>My guess is that most developers are going to use the default Java&#x2F;Swift combination for mobile development because that is what each company taught in their websites. I would prefer, thou, that engineers were more inclined to use opensource solutions to create common interfaces and avoid vendor lock-in. But cool events and free tutorials are hard to beat.
评论 #43727274 未加载
评论 #43728321 未加载
flohofwoe大约 1 个月前
Yes, technically it&#x27;s possible by wrapping the ObjC runtime API, see solutions like these:<p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;garettbass&#x2F;oc">https:&#x2F;&#x2F;github.com&#x2F;garettbass&#x2F;oc</a><p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;mitchellh&#x2F;zig-objc">https:&#x2F;&#x2F;github.com&#x2F;mitchellh&#x2F;zig-objc</a><p>Whether that&#x27;s better than writing ObjC directly is another question, think of ObjC as a convenient syntax sugar wrapper around macOS&#x2F;iOS APIs which you only need in those parts of your application that talk directly to operating system APIs.<p>Also Apple is maintaining a C++ Metal API wrapper now (ok, technically that&#x27;s not C): <a href="https:&#x2F;&#x2F;developer.apple.com&#x2F;metal&#x2F;cpp&#x2F;" rel="nofollow">https:&#x2F;&#x2F;developer.apple.com&#x2F;metal&#x2F;cpp&#x2F;</a><p>If you just want do to simple &#x27;game-y stuff&#x27; (3D rendering, audio, low level touch input) you can also check out the Sokol headers (shameless plug): <a href="https:&#x2F;&#x2F;github.com&#x2F;floooh&#x2F;sokol">https:&#x2F;&#x2F;github.com&#x2F;floooh&#x2F;sokol</a>, 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&#x2F;iOS though (e.g. pass `-x objective-c` to Clang), since the macOS&#x2F;iOS specific code paths are written in ObjC.<p>For the general case or when you need to access OS frameworks that are not wrapped by 3rd-party libraries:<p>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.<p>Don&#x27;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.<p>E.g. a hybrid C&#x2F;ObjC application with only the necessary amount of ObjC code for talking to OS APIs, and all the &#x27;business logic&#x27; in C (or another language, like C++, Zig or Rust).
pjmlp大约 1 个月前
No, not really.<p>You will notice that everyone that is replying that you can, also mentions that actually you have to make use from the Objective-C runtime from C.<p>So for all pratical purposes you will be writing an Objective-C application, manually writing the code that the Objective-C compiler used to generate when it was originally designed as a macro pre-processor generating C code at StepStone.<p>The way iOS is designed the bottom layer for userspace applications is Objective-C, not pure C UNIX style, and using the C APIs from the Objective-C runtime hardly changes that, you will be calling into the Objective-C runtime one way or the other.
krackers大约 1 个月前
Yes, it&#x27;s basically writing a nibless objective-c application but manually translating all invocations to objc_msgsend yourself. You&#x27;re not going to be able to avoid the objective-c runtime though.
评论 #43725228 未加载
quelsolaar大约 1 个月前
Yes, Objective C is built on some deep C calls you can call directly. I was a part of a project that built an automatic wrapper generator for C. Check it out at <a href="https:&#x2F;&#x2F;felixk15.github.io&#x2F;posts&#x2F;c_ocoa&#x2F;" rel="nofollow">https:&#x2F;&#x2F;felixk15.github.io&#x2F;posts&#x2F;c_ocoa&#x2F;</a>
评论 #43726298 未加载
enriquto大约 1 个月前
There is this beautiful single-header library to write simple graphical programs in C, portably to standard unixes, macos, and windows:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ColleagueRiley&#x2F;RGFW.git">https:&#x2F;&#x2F;github.com&#x2F;ColleagueRiley&#x2F;RGFW.git</a><p>It was discussed recently around here: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=42217535">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=42217535</a><p>The macos backend is a neat hack, written in pure C.
throwaway2037大约 1 个月前
Here is the original StackOverflow question that inspired that GitHub project: <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;10289890&#x2F;how-to-write-ios-app-purely-in-c" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;10289890&#x2F;how-to-write-io...</a><p>One of the other answers also explains how to write a MacOS app using pure C.
评论 #43725796 未加载
Suppafly大约 1 个月前
Give it a shot. The project you linked to, despite being old seems like it&#x27;d get you most of the way there.
edg5000大约 1 个月前
There is Objective-C++ (.mm extension), which I used extensively, where you have what is essentially a C&#x2F;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&#x27;s Document folder through an Objective-C call though.<p>The benefit of using C&#x2F;C++ is that you are not writing 100% vendor locked code, only the HAL portion that interacts with some of Apple&#x27;s Obj-C APIs will be platform-specific.<p>For example, if you write Linux-HAL then you can run your code, at least for testing, locally. And of course it opens the door to an Android port.
评论 #43725507 未加载
评论 #43725497 未加载
anshargal大约 1 个月前
Obj-C apps are not deprecated yet, so the approach in that GitHub repo must still work. That app is indeed written in C, but a big chunk is about building Obj-C classes and using other Obj-C objects - so it’s not quite C. You won&#x27;t get much performance benefits or additional flexibility this way.<p>C is Turing-complete, so you can technically write anything in it. But on iOS, you&#x27;d need to build your own C library for application-level Apple SDKs, since Apple doesn&#x27;t provide one. For simple apps (like small games or toy utils) - a minimal wrapper in Objective-C or Swift could be just a few hundred lines.
jokoon大约 1 个月前
I remember having to set up an Ogre3D (A C++ 3D engine) project so I could compile it with XCode.<p>For some reason it required a bit of objective C for it to work with opengl.<p>I sold my macbook about 2 years later, around 2015.
colleagueRiley大约 1 个月前
I made RGFW, which calls Objective-C MacOS&#x27;s API functions in Pure C.<p>BUT I would also like to mention a project a friend and I made called Silicon. Silicon is a single-header C wrapper around the Pure-C calls, which makes it far more convenient to use.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;eimamei&#x2F;silicon">https:&#x2F;&#x2F;github.com&#x2F;eimamei&#x2F;silicon</a><p>I no longer use it in RGFW because I wanted to remove the extra dependency.
m463大约 1 个月前
I think a better question is - could people practically write macos&#x2F;ios apps without xcode.<p>I remember the feeling I first got (decades ago) when moving from C to objective C.<p>Having an xcodeproj was like the camel&#x27;s nose under the tent, and then you couldn&#x27;t go back. And you frequently had a big mess going forward when the next xcode version came out and it wouldn&#x27;t work.
david422大约 1 个月前
I wrote an app that has minimal Objective C that then just calls C++ code. You can either add .cpp files to your project, or if I recall correctly, you can just define C++ functions in your obj c files. In my app, Objective C just sets up the UI and then it calls C++ functions to do calculations. Not exactly your question, but might be helpful.
mintflow大约 1 个月前
Recently I have built a iOS network extension by porting fd.io vpp to Darwin platform, though the UI part is written by SwiftUI. But the core is written using good old C and dns component is written using rust with hickory library, I was considering using c-ares but wanna get a try with rust.<p>So I think if UI stuffs can be written using C it then can build app using pure C.
hwpythonner大约 1 个月前
Well, you could basically do any llvm supported language. I remember a few years ago I tried creating a DSL just for fun and the sake of testing on iOS.<p>You can create a frontend of whatever language you want for llvm so it’d translate it to llvm-ir.<p>You just need a small wrapper in objective c to make it work.
seiferteric大约 1 个月前
Ha I ported my c solitaire program (uses SDL2) to iOS a couple years ago and it was pretty smooth. I didn&#x27;t know or think this was unusual, but I suppose most people would not start an iOS app this way.
评论 #43726304 未加载
snadal大约 1 个月前
Yes. It is absolutely possible. We have been including for more than 10 years a pure C web server on some of our apps that is currently 100% compatible for both Android and iOS
uwagar大约 1 个月前
objective-c is an ugly thing. a main reason i dont develop for macos.
评论 #43725992 未加载
评论 #43725929 未加载
johntitorjr大约 1 个月前
I read about someone doing this in android. The C app wrote directly to the framebuffer. Absurdly small apk.
评论 #43727508 未加载
simonhfrost大约 1 个月前
Definitely. Just find a use case where you need the performance
评论 #43726002 未加载
评论 #43725612 未加载
评论 #43703628 未加载
SonuSitebot大约 1 个月前
Yes, it&#x27;s still technically possible to write an iOS app in plain C in 2025 — but with caveats. You’ll need to wrap your C code in a minimal Objective-C or Swift layer to satisfy UIKit&#x2F;AppKit requirements and Xcode’s project structure. Apple’s SDKs are built around Obj-C&#x2F;Swift, so things like UI, lifecycle, and event handling need some glue code. The CBasediOSApp repo you linked is still a good starting point, but expect to adapt it for modern toolchains and signing requirements. Realistically, you&#x27;d write most logic in C (e.g. a game engine, parser, or core library) and interface with minimal Obj-C or Swift for the UI. Anyone trying it in 2025 will likely be doing it for fun, education, or embedded-style constraints — not App Store production unless there’s a really good reason.