Search code examples
rubymotionlibgit2objective-git

Include libgit2 in RubyMotion


I am trying to get objective-git included as ruby motion. I tried my best to translate the requirements on objective gits site into what is needed for an OS X ruby motion app. Here is the Rakefile, objective-git is a submodule located in vendor.

# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/osx'

require 'bundler/setup'
Bundler.require :default

Motion::Project::App.setup do |app|
  app.name = 'commit-zero'
  app.vendor_project 'vendor/objective-git', :xcode,
                     xcodeproj: 'vendor/objective-git/ObjectiveGitFramework.xcodeproj',
                     headers_dir: 'vendor/objective-git/External/libgit2/include'
end

Here is the error:

$ rake
     Build ./build/MacOSX-10.10-Development
Received exception: No headers to parse:
/usr/bin/gen_bridge_metadata:980:in `prepare'
/usr/bin/gen_bridge_metadata:776:in `parse'
/Library/RubyMotion/bin/gen_bridge_metadata:118:in `block in <main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/optparse.rb:885:in `initialize'
/Library/RubyMotion/bin/gen_bridge_metadata:38:in `new'
/Library/RubyMotion/bin/gen_bridge_metadata:38:in `<main>'
No headers to parse
Usage: gen_bridge_metadata [options] <headers...>
Use the `-h' flag or consult gen_bridge_metadata(1) for help.
rake aborted!
Command failed with status (1): [RUBYOPT='' '/Library/RubyMotion/bin/gen_br...]
/Library/RubyMotion/lib/motion/project/xcode_config.rb:366:in `gen_bridge_metadata'
/Library/RubyMotion/lib/motion/project/vendor.rb:221:in `block in build_xcode'
/Library/RubyMotion/lib/motion/project/vendor.rb:153:in `chdir'
/Library/RubyMotion/lib/motion/project/vendor.rb:153:in `build_xcode'
/Library/RubyMotion/lib/motion/project/vendor.rb:44:in `build'
/Library/RubyMotion/lib/motion/project/builder.rb:67:in `block in build'
/Library/RubyMotion/lib/motion/project/builder.rb:66:in `each'
/Library/RubyMotion/lib/motion/project/builder.rb:66:in `build'
/Library/RubyMotion/lib/motion/project/app.rb:78:in `build'
/Library/RubyMotion/lib/motion/project/template/osx.rb:41:in `block (2 levels) in <top (required)>'
/Library/RubyMotion/lib/motion/project/template/osx.rb:59:in `block in <top (required)>'
Tasks: TOP => build:development
(See full trace by running task with --trace)

Solution

  • Create ObjectiveGit.framework

    $ brew install cmake xctool
    $ git clone https://github.com/libgit2/objective-git.git && cd objective-git
    $ script/bootstrap
    $ xcodebuild
    

    ObjectiveGit.framework will be generated in build/Release.

    Setup App

    $ motion create TestGit --template=osx && cd TestGit
    $ rsync -av path/to/build/Release/ObjectiveGit.framework vendor
    

    And add following configuration into Rakefile.

    app.embedded_frameworks << 'vendor/ObjectiveGit.framework'