How does one use Obj-C 2.0 with GNUstep?

旧巷老猫 提交于 2019-11-30 09:38:30

Since the GNUStep ObjC2 FAQ has already been referenced, I'll assume you've had a look. I would like to point this out, however:

For more advanced features, currently only supported if you compile with Clang, you will need the GNUstep runtime. This is not currently considered production ready. It should work as a drop-in replacement for the GCC runtime, but some of the advanced features are not well-tested.

The FAQ also calls out the following:

If you are using a recent version of GCC to compile your code then you should have a copy of the Objective-C runtime library that came with your compiler.

If you compile with the -fobjc-nonfragile-abi flag then you will use the new ABI. This is only supported with the GNUstep runtime. This adds:

  • Property introspection
  • Introspection on optional protocol methods
  • Non-fragile instance variables
  • Forwarding proxy support

So, if you're looking for older functionality via GCC, this tutorial would do the job nicely, as would this one. You've explicitly called out that you're looking to do this with the functionality provided by Clang (via libobjc2), which has its own bed of documentation.

Obtaining a release of Clang and getting set up seems fairly cut and dried. The LLVM Getting Started document is exceptionally robust (full documentation archive here), which should provide insight into getting the backend set up and compiling properly. Some additional insight into the expected build procedure can be found here.

However, compiling an Objective-C application in Clang seems extremely underdocumented and untested at the time of this writing. As features become available and the codebase stabilizes, I imagine more user documentation will go live.

According to the GNUstep Wiki, you need just need to compile your code with -fblocks and -fobjc-nonfragile-abi. Then you just use the language features in your code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!