Code Monkey home page Code Monkey logo

c_ocoa's Introduction

C-OCOA Code Generator

This project is a code generator that generates C code that can ultimately be used to program against the Apple Cocoa API without having to use Objective-C. More details about this can be found on this blog post.

How to build

To use this project, you have to build it for yourself. This is because for the project to be able to extract information from the Cocoa API to generate to C API, it has to have to access to the Framework that you want to generate C code for. Eg: If you want to generate the C API for the GLKit framework, you have to build this project with the -Framework GLKit compiler option (or the equivalent XCode flag).

OSX

You can either use the XCode project to build this project or the command line. If you want to use the commandline, you can use the osx/build.sh script. The linked frameworks can be changed in line 33 of the script. To be able to build the program, XCode has to be installed and clang has to be installed (should come with XCode).

iOS

To be able to use this project for iOS, you are bound to use the XCode project. You don't have to have an iOS device to be able to use this project for iOS - you can simply use a iOS simulator.

How to use

Once the project is build, you can run the executable without any parameter. In that case it will generate the API for all classes that are contained within the framework that the executable has been build with. If you're only interested in a subset of the available classes you can specify one or more filters as arguments when running the executable (wildcards using * are also supported).

eg: If you're only interested in classes that start with NS you can start the executable with this argument:

c_ocoa_generator NS*

The project has additional support for these options:

    -o <output>     | Specifies where to write the generated C files. Default: Working Directory
    -p <prefix>     | Specifies a prefix that should be added to the name of the generated C files. Default: No prefix
    -t              | Enables the export of all objc types that are used by the exported classes into `c_ocoa_types.h`

eg: This will generate the C API for classes that start with CG. The generated C files will be written to the ~/c_ocoa/output/ directory and all generated files will be prefixed with awesome_company_.

c_ocoa_generator -o ~/c_ocoa/output/ -p awesome_company_ CG*

Note: When running the executable on an iOS or iOS Simulator, you have to make sure that the code generator only writes to folders that it has write-access to

Once the code has been generated you can use it by including the generated *.h files and adding the generated *.c files to your project.

c_ocoa's People

Contributors

felixk15 avatar felixklinge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

g40

c_ocoa's Issues

Thank you and an issue.

Many thanks - Great idea and could be very useful.

Built and run on Ventura using:

build_release % clang -v
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Seeing lots and lots of errors in the following form. Is this known and is anyone working to fix it? Or should I just get stuck in a make the relevant modifications?

[error] Couldn't resolve return type '{?=[16q]}' of function 'mpsndarrayorsecondarygradient_stridesForSourceIndex'.
[error] Skipping function 'stridesForSourceIndex:' of class 'MPSNDArrayORSecondaryGradient' because of unknown argument type.
[warning] could not resolve type name '(?=I{?=b8b8b16})'.
[error] Couldn't resolve 2. argument type name '(?=I{?=b8b8b16})' of function 'mpsndarrayorsecondarygradient_setFileVersion'.
[error] Skipping function 'setFileVersion:' of class 'MPSNDArrayORSecondaryGradient' because of unknown argument type.
[warning] could not resolve type name '(?=I{?=b8b8b16})'.
[error] Couldn't resolve return type '(?=I{?=b8b8b16})' of function 'mpsndarrayorsecondarygradient_fileVersion'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.