在RubyMotion中包含libgit2

时间:2014-07-26 19:54:03

标签: rubymotion libgit2 objective-git

我试图将客观git包含为红宝石动作。我尽力将客观gits网站上的要求转换为OS X ruby​​动作应用程序所需的内容。这是Rakefile,objective-git是位于供应商的子模块。

# -*- 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

这是错误:

$ 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)

2 个答案:

答案 0 :(得分:1)

创建ObjectiveGit.framework

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

ObjectiveGit.framework将在build/Release中生成。

设置应用

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

并将以下配置添加到Rakefile

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

答案 1 :(得分:0)

RubyMotion使用gen_bridge_metadata命令,该命令由Apple在从Objective-C / C头文件生成元数据时提供,以便正确地从Ruby调用API。

不幸的是,gen_bridge_metadata到目前为止还不支持C ++标头。您需要从`app.vendor_project'中删除C ++头目录路径。