Search code examples
iosxcoderubymotion

How can I include the SVGKit into my Rubymotion project?


I'm trying to use SVGKit in my Rubymotion project but can't seem to get it to build.

So far I've moved the SVGKit code into vendor/SVGKit and added the following to my Rakefile (it's an otherwise blank project)

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

when I try to build it - I get the following:

     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)

Can anybody offer suggestions on where I've gone wrong?


Solution

  • DDLogVerbose is a function from CocoaLumberjack. Your best bet to make this easy would be to install SVGKit via CocoaPods. To do so, first install motion-cocoapods

    sudo gem install motion-cocoapods
    

    This should install cocoapods and motion-cocoapods. You need to setup cocoapods so run

    pod setup
    

    Now you can add motion-cocoapods to your Gemfile

    gem 'motion-cocoapods'
    

    Next add the pod to your rake file

    app.pods do
      pod 'SVGKit'
    end
    

    Finally run the following rake command to download SVGKit

    rake pod:install
    

    Next time you rake, everything should theoretically just compile and work! Good luck :)