如何将SVGKit包含在Rubymotion项目中?

时间:2014-02-24 15:27:55

标签: ios xcode rubymotion

我正在尝试在我的Rubymotion项目中使用SVGKit但似乎无法构建它。

到目前为止,我已将SVGKit代码移动到vendor / SVGKit中,并将以下内容添加到我的Rakefile中(这是一个空白的项目)

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

begin
  require 'bundler'
  Bundler.require
rescue LoadError
end

Motion::Project::App.setup do |app|
  app.name = 'SVGKitMotion'
  app.frameworks += %w[ CoreText CoreImage libxml2.dylib QuartzCore CoreGraphics UIKit ]

  app.vendor_project('vendor/SVGKit', :static,
      :products => ["libSVGKit-iOS.1.2.0pre.a"])

end

当我尝试构建它时 - 我得到以下内容:

     Build ./build/iPhoneSimulator-7.0-Development
     Build vendor/SVGKit
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/AppleSucksDOMImplementation.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/Attr.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CDATASection.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CharacterData.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/Comment.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CSSRule.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CSSRuleList.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CSSStyleDeclaration.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CSSStyleRule.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CSSStyleSheet.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CSSValue.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/CSSValueList.m
Source/DOM classes/Core DOM/CSSValueList.m:47:2: warning: implicit declaration of function 'DDLogVerbose' is invalid in C99 [-Wimplicit-function-declaration]
        DDLogVerbose(@"[%@] received new CSS Text, need to split this and save as CSSValue instances: %@", [self class], _cssText);
        ^
1 warning generated.
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/Document.m
Source/DOM classes/Core DOM/Document.m:26:2: warning: implicit declaration of function 'DDLogVerbose' is invalid in C99 [-Wimplicit-function-declaration]
        DDLogVerbose( @"[%@] WARNING: SVG Spec, missing feature: if there are known attributes with default values, Attr nodes representing them SHOUL...
        ^
1 warning generated.
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/DocumentFragment.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/DocumentType.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/DOMHelperUtilities.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/Element.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/EntityReference.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/MediaList.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/Node.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/NodeList.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/ProcessingInstruction.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/StyleSheet.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/StyleSheetList.m
   Compile vendor/SVGKit/Source/DOM classes/Core DOM/Text.m
   Compile vendor/SVGKit/Source/DOM classes/SVG-DOM/SVGAngle.m
   Compile vendor/SVGKit/Source/DOM classes/SVG-DOM/SVGAnimatedPreserveAspectRatio.m
   Compile vendor/SVGKit/Source/DOM classes/SVG-DOM/SVGDefsElement.m
In file included from Source/DOM classes/SVG-DOM/SVGDefsElement.m:1:
Source/DOM classes/SVG-DOM/SVGDefsElement.h:5:9: fatal error: 'SVGElement.h' file not found
#import "SVGElement.h"
        ^
1 error generated.
rake aborted!
Command failed with status (1): [/Applications/Xcode.app/Contents/Developer...]
/Library/RubyMotion/lib/motion/project/vendor.rb:114:in `block (2 levels) in build_static'
/Library/RubyMotion/lib/motion/project/vendor.rb:72:in `each'
/Library/RubyMotion/lib/motion/project/vendor.rb:72:in `block in build_static'
/Library/RubyMotion/lib/motion/project/vendor.rb:65:in `chdir'
/Library/RubyMotion/lib/motion/project/vendor.rb:65:in `build_static'
/Library/RubyMotion/lib/motion/project/vendor.rb:42:in `build'
/Library/RubyMotion/lib/motion/project/builder.rb:65:in `block in build'
/Library/RubyMotion/lib/motion/project/builder.rb:64:in `each'
/Library/RubyMotion/lib/motion/project/builder.rb:64:in `build'
/Library/RubyMotion/lib/motion/project/app.rb:76:in `build'
/Library/RubyMotion/lib/motion/project/template/ios.rb:46:in `block (2 levels) in <top (required)>'
/Library/RubyMotion/lib/motion/project/template/ios.rb:63:in `block in <top (required)>'
Tasks: TOP => build:simulator
(See full trace by running task with --trace)

有人可以就我出错的地方提出建议吗?

1 个答案:

答案 0 :(得分:1)

DDLogVerbose是来自CocoaLumberjack的函数。让这个变得简单的最好方法是通过CocoaPods安装SVGKit。为此,请先安装motion-cocoapods

sudo gem install motion-cocoapods

这应该安装cocoapods和motion-cocoapods。你需要设置cocoapods,所以运行

pod setup

现在您可以将动画cocoapod添加到Gemfile

gem 'motion-cocoapods'

接下来将pod添加到您的rake文件

app.pods do
  pod 'SVGKit'
end

最后运行以下rake命令下载SVGKit

rake pod:install

下次你耙,理论上一切都应该编译和工作!祝你好运:)