patrickgill / SVGKit

Display and interact with SVG Images on iOS / OS X, using native rendering (CoreAnimation)

Home Page:(currently only supported for iOS - OS X code needs updating)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SVGKit

SVGKit is a Cocoa framework for rendering SVG files natively: it's fast and powerful. Some additional info and links are on the wiki

Twitter

We have a Twitter account http://twitter.com/SVGKit_free you can follow for release info, or tweet at for contact (any bugs, please report via the Issues page instead).

Versions:

Latest info at: https://github.com/SVGKit/SVGKit/wiki/Versions

  • v2.x = current "in development" branch with latest changes, fixes, features
    • NB: this is now automatically selected in GitHub as the "default" branch when you visit SVGKit's project page
    • CocoaPods users: It is recommended that you setup your podfile to get svgkit from this 2.x branch (or a local fork from the 2.x branch). To do this enter the following in your podfile:
      pod 'SVGKit', :git => 'https://github.com/SVGKit/SVGKit.git', :branch => '2.x'
      

Getting Started

Run the Demo

NB: April 2015: new Demo app, many more features, may have teething troubles with this one.

  1. Open up "Demo-iOS.xcodeproj", and run it (on simulator or device). Try different SVG's. Zoom, pan, and (with the Monkey only:) hit the "Animate" button. Tap the images to see bounding-boxes / hit dectection (might need you to hit the Debug button first)
  2. If you have ANY problems building the library and embedding it in your app, compare your build settings to the Demo-iOS build settings - if something's different, it's probably the problem.

Installation (add SVGKit to your app)

You have 3 main options for installing SVGKit:

  1. Drag/drop the .framework file into your project <-- PREFERRED / RECOMMENDED
  2. Drag/drop the static library into your project, and configure the build settings in your project
  3. Use CocoaPods (not supported, but we try to update the podspec when people submit Pull Requests for it)

NB: the "static library" is our backwards-compatible, manual install that always works if you have problems either with CocoaPods or with the Framework. But the other two are a lot quicker/easier.

Use the Framework - drag, drop, done!

  1. Open "SVGKit-iOS.xcodeproj"
  2. Build the project once
  3. In Project Navigator, expand the Products folder
  4. Drag/drop SVGKit.framework into your app-project

NB: Frameworks are the preferred way to use libraries in Xcode. But this is a new feature, it might have bugs. If you have ANY problems, please create an Issue, but also try the Static Library method below

You MAY also need to manually add the following Apple Frameworks to your app:

  • CoreText
  • CoreImage
  • libxml2.dylib
  • QuartzCore
  • CoreGraphics
  • UIKit

You MAY also need to add the following 3rd party Frameworks to your app (included with SVGKit):

  • CocoaLumberjack (in the SVGKit-iOS project, select the "3rd-party-frameworks" folder, and drag/drop whichever versions you need: iOS, tvOS, etc) Remember to embed the library too (should show under Target -> General -> Embedded Binaries)

Build the static library

Until 2016, this was the PREFERRED way of shipping SVGKit.

We have a build script that automatically builds ALL versions of the library at once, and ships them as a single file: http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4/3647187#3647187

It's all setup already, all you need to do is:

  1. Open "SVGKit-iOS.xcodeproj", and Build it (cmd-B)
  2. in left navbar, scroll to bottom, and open the "Products" section
  3. right click the library ("libSVGKitBLAHBLAH.a") and select "show in finder"
  4. GO UP ONE FOLDER
  5. select the "Debug-universal" (or Release-universal if you were building in Release mode) folder
  6. Drag/drop the .a file and the "usr" folder into your project (select the "Copy files" checkbox)
  7. In Build Settings, select "Other Linker Flags" and add "-ObjC"
  8. Edit your build settings and set "C/C++ Compiler Version" = "LLVM Compiler 2.0"
  9. Add ALL the frameworks and 3rd party libraries listed below (go to "Build Phases", and "Link Binary with Libraries"):
  • CoreText
  • CoreImage
  • libxml2.dylib
  • QuartzCore
  • CoreGraphics
  • UIKit

Everything else is automatic.

Recipes for using the library

Here are some posts on using SVGKit, with advice on which methods to use and why:

I get a crash with "unrecognized selector" ?

If you get this error:

"+[NSCharacterSet SVGWhitespaceCharacterSet]: unrecognized selector sent to class "

... you're probably building the Static Library, but forgot to do the step below:

"Edit your build settings and add "Other Linker Flags" = "-ObjC""

Usage - OS X

We need someone to integrate the OS X fork into the main project - please help.

The fork is over here: https://github.com/MaddTheSane/SVGKit/tree/master

About

Display and interact with SVG Images on iOS / OS X, using native rendering (CoreAnimation)

(currently only supported for iOS - OS X code needs updating)

License:Other


Languages

Language:Objective-C 94.3%Language:HTML 4.0%Language:C 1.4%Language:Ruby 0.2%Language:CSS 0.1%Language:JavaScript 0.0%