简体   繁体   中英

Is there a library for loading in SVG layers to an Mac OS X application using Objective-C?

I want to use the SVG format for theming my game ui using Objective-C. The problem is the existing framework that would do everything I need (loading in specific SVG layers by their name, being very accurate) does not build for some reason with the following errors:

Warnings

Implicit declaration of function 'NSStringFromCGRect' is invalid in C99

Errors

_NSStringFromCGRect", referenced from: -[SVGDocument parseAttributes:] in SVGDocument.o Symbol(s) not found for architecture x86_64 Clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have no idea what either of these mean, but it is safe to say it makes this unusable.

I found another solution in the form of a game on gottcode ; the only problem with this as you will probably see is that it uses the QT framework, not Objective-C.

  • Is it possible to fix SVGKit so that the framework compiles?
  • Is it possible to port Qsvg?

If the answer to either the questions is yes, then please point me in the right direction.

I managed to find a working one with help in one of the comments but the output has a green tint to it. Does anyone know what could cause this? And how to fix it?

NSStringFromCGRect is one of the UIKit additions to Core Graphics, so it's likely you've tried to build an iOS-oriented library. That particular method isn't very hard to rewrite but it sounds like you might just have made some sort of selection error somewhere, as the Git repository for SVGKit seems to show a Mac target. I grabbed a copy from there (using the download as .tar.gz link ), opened that in Xcode and hit build for 'My Mac 64-bit' and received four warnings but compilation completed.

SVGKit has almost support for OS X - but the focus is on getting the core library up to full SVG Spec compliance, and nearly everyone working on it is using iOS only.

So ... there's a few places where people have accidentally used iOS-only libraries (although we've been ironing most of those out on the new branch here: https://github.com/adamgit/SVGKit/tree/transforms - but that branch is currently "in development").

If you get build errors with a current SVGKit version, it usually means you just need to put an #if build switch for IOS around each error, and replace it with the identical OS-X only method (usually the same name, but using "NS" instead of "UI")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM