Search code examples
objective-crubymotion

How do I include an Objective C category in a RubyMotion project


In my Xcode projects I have sometimes used a category for adding zoom level functionality to MKMapView. Now I want use the category in my RubyMotion project. The files are in the vendor dir and I have included them with

app.vendor_project('vendor', :static)

It looks like the compilation goes ok, but ld complains that

ld: in /Users/admin/gitrep/bgApp/vendor/build-iPhoneSimulator/libvendor.a, 
archive has no table of contents for architecture i386

Does anyone know if this approach for including categories (and possibly also stand alone classes) work?


Solution

    1. With Xcode, create a project as "Cocoa Touch Static Library" and put your codes into this project.

    2. Put this project into your vendor/.

    3. Then write like this in Rakefile to use in RubyMotion.

    Rakefile

      app.vendor_project('vendor/UIFoo-Bar',
                     :xcode,
                     :headers_dir => 'UIFoo-Bar')