Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Mac Port #80

wants to merge 626 commits into from

4 participants


I've created a new branch to prevent me from flooding the SVGKit people.

This patch adds Mac support with a Mac OS X framework.


Someone mentioned there were problems with the OS X linking when sharing code with main source project.

Yesterday, I hit similar problems on live projects when we upgraded from Xcode 4.6.0 to 4.6.2 - it seems that 4.6.1 or 4.6.2 changes the linking behaviour (!) for subprojects.

I'll do a review of this before merging, but can you confirm what version(s) of Xcode you're using, and whether the linking is working OK for you at the moment?

(if there's a version-specific problem with Xcode, I'd like to get as much info as possible before I try to find a workaround :))


I am using 4.6.2, and am having no issues linking my image rep bundle to the framework. Of course, I also am ahead of this branch: I didn't want to overwhelm you with my constant commits.


I've merged the other pull requests, I want to start merging this now.

I've built a merge branch, and I've resolved all the conflicts.

HOWEVER the Demo-iOS project is now broken. It is an "impossible" situation - clang won't build because of errors in a file THAT DOES NOT EXIST in the project. It appears to be a (major!) bug in Xcode: it's somehow grabbing a header file from the SVGKit-OSX project and using it in the Demo-iOS project eventhough there is literally no link and no reference between the two projects/files.

Do you have any ideas what's happened / how to fix it? This completely blocks any merging of the branches :(


The problem:

Something in the "Demi-iOS" project is now tricking Apple into saving all the intermediary build data into the project folder!

This is very wrong, but I can't find a way to turn it off. It means you can compile the project ONCE and then never again (because the "build" sub-folder confuses Xcode, and breaks everything)


At least for me, the demo-iOS project is trying to include my "AppKit Additions" headers by accident. I found out that this is because the Demo-iOS project recursively includes everything in Source, including the AppKit additions.


Ah, yes, I see. IIRC that was to work around a bug in Xcode where it kept removing files from the build even though they were in the project (and you had to manually "remove/re-add" them each time Xcode did this). Telling Xcode to "just compile everything in Source/" fixed it.


There were a few odd and wrong things in the Header Search Paths.

But ... cleaning that out, iOS can't build any more, because Xcode's longstanding bugs in finding headers for sub-projects.

(Xcode won't let you add headers, and it won't look for headers in the standards locations, nor in its own build folders, nor in the project. It changes from version to version too :( )

If I can't find a fix for this, we might have to split "Source/" into 3: "Source/Core", "Source/iOS-Additions", "Source/OSX-Additions"

NB: this is what the original SVGkit used to do. I don't know for sure, but I suspect it was to workaround the Xcode compilation and linking bugs.


Got it. Adding a User Header Search Path of "$(TARGET_BUILD_DIR)/usr/local/include/" (NB: quotes are required, Xcode doesn't automatically support folders with spaces!) fixes it. /usr/local/include is the folder structure that (supposedly) is standards correct and is exported to by the universal (iPhone + simulator) build-script, but Apple seems to prefer "/include" by default. I might change that later.

Now onto your commits ... I've got some crashing bugs (looks like over-release of memory or similar), probably something when I merged with latest 1.1.0 code.


Fixed the mem crash. This now seems to me correct with 1.1.0 :

But there's no "Demo-OSX" project, so I cannot check any of the changes on the OS X code, cannot see if they are working OK. Please can you try that branch and confirm that the OS X side is still working?

NB: going forward, we urgently need a "Demo-OSX" project that loads each of the SVGs in the "Demo-Samples/SVG/" folder and sub-folders. Otherwise we have no way of checking people's commits.


Going through the diffs, it appears you've removed lots of "autorelease" that were correct originally. Is there a specific reason for this?


Also: you've replaced a lot of "CGFloat = ... [something floatValue]" with " SVGKCGFloatValue]" - but a lot have been left untouched.

(EDIT: or maybe this is due to something going wrong with the merge?)

Is this something that should be changed everywhere? e.g. SVGElement is a messy mix of the two approaches right now.

(Without a demo OS X project to test against, I don't want to make that change)


Also: when you convert lots of 2-line:

"object = ...
return object;"

into 1-liners ... I thought the 1-liner prevents Xcode's debugger from telling you the value before it returns - or is there a feature in Xcode that makes this work even with 1-liners?


For the autorelease removals, I did it because I didn't want the iOS autorelease pools to be too big.

As for the return values, I think there is a way to see what the return value, or it shows the return value when you step out of the function. If this has changed, I can change those values back.

For the SVGKCGFloat, I tried to get all values that were CGFloats. I purposefully skipped over the SVGRect creation function because SVGRects right now are just floats.


As for writing an OS X demo project, I'll get around to that as soon as I can.


I have created an OS X demo app, which also made me realize that the layered view wasn't working on OS X (I have fixed it).

MaddTheSane added some commits
@MaddTheSane MaddTheSane Once again, making it harder and more complex than was necessary. d6905f0
@MaddTheSane MaddTheSane Fix the spelling of cielWidth.
Make sure the data size is correct.
@MaddTheSane MaddTheSane We don't need to worry about there being a subclass for cached SVGKIm…
@MaddTheSane MaddTheSane Add a method to clear the SVG cache. 1277a09
@MaddTheSane MaddTheSane Indentation. b830930
@MaddTheSane MaddTheSane I forgot to enclose the cameFromGlobalCache in a preprocessor switch …
…in SVGKImage.
@MaddTheSane MaddTheSane Fix an improper merge. d1a9b84
@MaddTheSane MaddTheSane Add a warning for problematic SVG in the image rep. 54c20dd
@MaddTheSane MaddTheSane Adding a function to get and make debug date formatter. 5a97d89
@MaddTheSane MaddTheSane Disable the SVGKImage cache on OS X. 7544201
@MaddTheSane MaddTheSane Check to see if SVGKImage's class responds to clearSVGImageCache on t…
…he OS X demo.
@MaddTheSane MaddTheSane Rely on SVGKSource's convenience functions for other data types. aee5922
@MaddTheSane MaddTheSane Add the definition of isEqualURL: to SKSVGObject's header. d666445
@MaddTheSane MaddTheSane Rename the self's in the XML helper functions to NSctx: using "self" …
…was confusing Xcode.
@MaddTheSane MaddTheSane Implement a drawInRect: function in the image rep. This should help w…
…ith scaling.

Add a block function around the image rep's TIFF exporting functions.
@MaddTheSane MaddTheSane Implement a way to get a TIFF with an arbitrary size from the image rep. f712cbb
@MaddTheSane MaddTheSane Changing how TIFF creation is handled on the image rep.
We don't have to worry about resetting the size: the next time the image is drawn it will reset the size.
@MaddTheSane MaddTheSane Set the image size in the image rep to the image rep's size when pass…
…ed the pixel size.
@MaddTheSane MaddTheSane Don't go further into SVGKImage's setSize: function if the size is th…
…e same as defined by the user.
@MaddTheSane MaddTheSane Add a method to init from an SVGKImage object. de78cb1
@MaddTheSane MaddTheSane Adding header guards to the SVGKImage header. This will be used later…
… in the image rep.
@MaddTheSane MaddTheSane Include initializations from SVGKit classes in the image rep header, …
…but only include them if we have the SVGKImage header included.
@MaddTheSane MaddTheSane Fix spelling mistake in a preprocessor macro. a6af438
@MaddTheSane MaddTheSane Include the SVGKitImageRep class directly in the image rep tester. 67648d1
@MaddTheSane MaddTheSane Implement an imageRepWithSVGSource: for the image rep. d8d7ba5
@MaddTheSane MaddTheSane Remove the autorelease pool in the OS X Demo's applicationDidFinishLa…
…unching: function.
@MaddTheSane MaddTheSane Make a warning go away in the OS X demo. 09571b7
@MaddTheSane MaddTheSane Make NSStringFromLibxmlString be a macro. ab9d047
@MaddTheSane MaddTheSane Include QuartzCore in OS X's SVGKit prefix header. 623e85b
@MaddTheSane MaddTheSane Revert the change of making NSStringFromLibxmlString a macro. 1742cb8
@MaddTheSane MaddTheSane Make NSStringFromLibxmlString a static inline. b9df813
@MaddTheSane MaddTheSane Go back to using a macro, this time accounting for null strings passe…
…d to it.

If you wish to use the function, just set the preprocessor macro USENSSTRINGFROMLIBXMLSTRINGFUNCTION to 1.
… in SVGKImage.m instead of in the header.

Implement functions that weren't available when image caching was disabled. These just print to the log that they aren't available, and they do nothing.
Trimming down the check for ENABLE_GLOBAL_IMAGE_CACHE_FOR_SVGKIMAGE_IMAGE_NAMED: it should always be defined, even if it's disabled.
Make imageWithData: available on OS X.
@MaddTheSane MaddTheSane Adding logging functions to OS X's image getters. c362de8
@MaddTheSane MaddTheSane Add a KVO observer for changes in the scale.
Check with the observer that the key being changed is either the domtree's viewport or the scale.
@MaddTheSane MaddTheSane Indentation change. cac2c2e
@MaddTheSane MaddTheSane Expanding an error message. 20113ab
@MaddTheSane MaddTheSane We no longer need the SVGKImage extension in the OS X demo app. d5216f9
@MaddTheSane MaddTheSane Minor change that probably won't be relevant until later. 1d064b4
@MaddTheSane MaddTheSane Use a macro in SKSVGKObject's accessors stating their unimplemented s…
@MaddTheSane MaddTheSane Add a helper function in SKSVGBundleObject to get the file name sans …
…extension and the extension.
@MaddTheSane MaddTheSane Use the tertiary operator in startElementSAX db6f97f
@MaddTheSane MaddTheSane Since there's only one object there, use arrayWithObject: instead. 1b5527a
@MaddTheSane MaddTheSane Implement an SVGKSource subclass for data. b4724c2
@MaddTheSane MaddTheSane Include the class name in Attr's description method.
Init the errcStr in errorEncounteredSAX to contain null bytes.
@MaddTheSane MaddTheSane Rename isEqualURL: in SKSVGObject to isEqualToURL:
Messing around with the isEqualToURL: method, mainly accounting for http urls.
@MaddTheSane MaddTheSane Don't use the bundle init code in the OS X demo by default. 983c1a5
@MaddTheSane MaddTheSane Minor code change in SVGKSourceData. 080c367
@MaddTheSane MaddTheSane Removing the autorelease pool in the CALayer's extension cloneRecursi…

Get rid of the copy calls in cloneRecursively: the copy command isn't needed because the setter automatically does this for us.
@MaddTheSane MaddTheSane Create a Lumberjack framework on OS X, and link and include it in the…
… SVGKit framework.
@MaddTheSane MaddTheSane Adding a Lumberjack main header file for the framework. be2b206
@MaddTheSane MaddTheSane Adding an inspect build configuration for SVGKit framework on OS X.
Remove the deployment target declaration on the Lumberjack framework: use the project's default.
@MaddTheSane MaddTheSane Move master to modern Objective-C syntax. c81a2e6
@MaddTheSane MaddTheSane Update the iOS side to modern Objective-C syntax. 2861cbb
@MaddTheSane MaddTheSane Getting rid of iOS-only code in OS X's SVGKFastImageView. ec78227
@MaddTheSane MaddTheSane More work on the caching system:
The cache is enabled by default on iOS and disabled on OS X.
You can turn the caching on and off programmatically.
@MaddTheSane MaddTheSane Add the ability to get images from the language subfolders in the OS …
…X demo.
@MaddTheSane MaddTheSane Handle objects in subdirectories correctly in the OS X demo. c167419
@MaddTheSane MaddTheSane Add missing semicolon.
Check for gradients on the iOS demo.
@MaddTheSane MaddTheSane Rework the OS X demo so that each view has its own list. 46f3fa1
@MaddTheSane MaddTheSane Check the last path component's extension in the OS X demo. dac84df
@MaddTheSane MaddTheSane Make the scroll views be directly on the split view, instead of in a …
@MaddTheSane MaddTheSane Obfuscate the fact we have a caching class.
Use modern syntax on the cache.
@MaddTheSane MaddTheSane Rework the cache initializing code. d38256c
@MaddTheSane MaddTheSane Don't check for the cache presence twice in the same function. 289cc07
@MaddTheSane MaddTheSane Get rid of the init method in the caching class: it's not used for an…
@MaddTheSane MaddTheSane Add a simple macro for showing that caching is disabled. 401b2da
@MaddTheSane MaddTheSane Change the order of theBundle property values. 942657e
@MaddTheSane MaddTheSane Add a menu in the OS X demo for toggling the cache. f2ff57d
@MaddTheSane MaddTheSane Attr has no subclasses. Remove class declaration from its description…
… method.

Include class name in unparsedEntityDeclaration.
@MaddTheSane MaddTheSane A few minor changes. 826a9de
@MaddTheSane MaddTheSane Show a warning window if caching isn't enabled and the user requests …
…to clear it.
@MaddTheSane MaddTheSane Use -[NSObject isMemberOfClass:] to get classes that are exactly what…
… we're looking for.

We are targeting 10.7 and later. The warning about missing functionality isn't needed.
Trim down the use of preprocessor ifdefs in SVGSVGElement.m by defining NSStringFromCGRect to NSStringFromRect on OS X.
@MaddTheSane MaddTheSane Change the way SKSVGObject's "unimplemented" methods are handled: sen…
…d the message to NSLog, and tell Objective-C we don't recognize that selector.
@MaddTheSane MaddTheSane Include the proper header. f6e70b0
@MaddTheSane MaddTheSane Use modern syntax to init a mutable dictionary in CALayerExporter. bca9446
@MaddTheSane MaddTheSane Minor spacing change. 50ba343
@MaddTheSane MaddTheSane Bypass the image rep's initWithSource: for a lot of the initializers.
Compress the TIFFs generated by the image rep test app.
@MaddTheSane MaddTheSane Trim down the preprocessor if statements on the image rep test app. 9858176
@MaddTheSane MaddTheSane Rely on super drawInRect more in the image rep. 59ffff9
@MaddTheSane MaddTheSane Fix the rpath in the SVGKit framework. f1663fc
@MaddTheSane MaddTheSane Set the caching variable after cache set-up/take-down. 7eeb17c
@MaddTheSane MaddTheSane Minor change. f22d5a4
MaddTheSane added some commits
@MaddTheSane MaddTheSane Get rid of the macro SVGKsvgStringDefaultContents, and replace the la…
…st mention of it with SVGKGetDefaultImageStringContents().
@MaddTheSane MaddTheSane Adding more verbosity to SVGKit's setRawLevel for developers. a865272
@MaddTheSane MaddTheSane Mess around with OS X's prefix headers. 43045b4
@MaddTheSane MaddTheSane Mess around on the frameworks on the OS X SVGKit project. 6452757
@MaddTheSane MaddTheSane I seem to like preprocessor macros.
We don't need parentheses around C strings made via the preprocessor to get NSStrings.
@MaddTheSane MaddTheSane Minor string change. d8d5fc6
@MaddTheSane MaddTheSane Get rid of unneeded autorelease pool. 8602f48
@MaddTheSane MaddTheSane Convert SVGLength to CGFloat. 1297344
@MaddTheSane MaddTheSane We no longer have an SVGKImageRep bundle to copy over.
Rename the Copy Files build phase in the OS X demo to the more-informative Copy Frameworks.
@MaddTheSane MaddTheSane Move header types around in OS X. e138c9c
@MaddTheSane MaddTheSane Merge branch 'master' into namespace
This BIG merge updates the namespace branch to the current master, as well as makes the source and project use the SVGKit header subdirectory correctly.

	Source/AppKit additions/SVGKFastImageView.m
	Source/AppKit additions/SVGKLayeredImageView.m
	Source/DOM classes/Core DOM/CSSPrimitiveValue.m
	Source/DOM classes/Core DOM/ProcessingInstruction.h
	Source/DOM classes/SVG-DOM/SVGGElement.h
	Source/DOM classes/SVG-DOM/SVGUseElement.h
	Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes.h
	Source/DOM classes/Unported or Partial DOM/SVGGradientElement.h
	Source/DOM classes/Unported or Partial DOM/SVGGroupElement.h
	Source/DOM classes/Unported or Partial DOM/SVGSVGElement.h
	Source/DOM classes/Unported or Partial DOM/SVGTextElement-iOS.m
	Source/DOM classes/Unported or Partial DOM/SVGTextElement.h
	Source/UIKit additions/SVGKFastImageView.m
	Source/UIKit additions/SVGKLayeredImageView.m
@MaddTheSane MaddTheSane Revert svgLengthZero to an earlier state. 1b27e1c
@MaddTheSane MaddTheSane I have encountered no issues with removing the observer in SVGKLayer'…
…s dealloc method.
@MaddTheSane MaddTheSane Move some mutable class addition headers to private. 9af88b1
@MaddTheSane MaddTheSane Merge branch 'namespace'
@MaddTheSane MaddTheSane Make CSSPrimitiveValue_ConfigurablePixelsPerInch.h a "project" header. 75d73ee
@MaddTheSane MaddTheSane Include the AppKit header in the CGPathAdditions header on OS X. f78c796
@MaddTheSane MaddTheSane Add a static library of SVGKit on OS X.
Better choosing of which logging storage method to use.
@MaddTheSane MaddTheSane Set the header folder path to be /usr/local/include/SVGKit for libSVG…
…Kit on OS X.
@MaddTheSane MaddTheSane Messing with OS X's frameworks. 1d9c80d
@MaddTheSane MaddTheSane More messing with OS X's frameworks.
Include the libxml library in OS X's project, instead of it being a linker flag.
@MaddTheSane MaddTheSane Updating read-me. ae5c30d
@MaddTheSane MaddTheSane Make SVGKit run (with limitations) on 10.6.8 1931892
@MaddTheSane MaddTheSane Add a test app that uses libSVGKit on OS X. 82a9707
@MaddTheSane MaddTheSane Logger uses 10.7 functions, dangit. e4bbd37
@MaddTheSane MaddTheSane Use the project's iOS deployment target instead of having a separate …
…one for the target.
@MaddTheSane MaddTheSane Apparently you need the linker flag "-ObjC" if you're linking a stati…
…c lib that has Objective-C categories.
@MaddTheSane MaddTheSane We don't have the namespace branch anymore. 191b9d4
@MaddTheSane MaddTheSane Uh, oops: Forgot to finish a sentence in the read-me. bd5880a
@MaddTheSane MaddTheSane Expanding a sentence. e1312dc
@MaddTheSane MaddTheSane Mess with the read-me. d49382e
@MaddTheSane MaddTheSane Only have an autorelease pool around SVGKImage's initWithSource:. c233096
@MaddTheSane MaddTheSane Allow accessing the image rep class directly in ImageRep-Demo program…
@MaddTheSane MaddTheSane Since we can programmatically set to use the image rep class directly…
…, repurpose the NSImage version to use the static library.
@MaddTheSane MaddTheSane Error checking in SVGKImage to see if CALayerTree creation succeeded.
Don't try to call functions in SVGKLayer when setting an image.
@MaddTheSane MaddTheSane Warn the user when they select Reinel_compass_rose that it might brea…
…k the program.
@MaddTheSane MaddTheSane Some minor tweaking time. 05ccb5b
@MaddTheSane MaddTheSane Oops, forgot a release there. e165c7e
@MaddTheSane MaddTheSane Add another "CGFloat" scan function, this time in +[SVGKPointsAndPath…
…sParser readCoordinate:].

Create a function to get more verbose data from an exception object.
@MaddTheSane MaddTheSane General fiddling around. c0e0392
@MaddTheSane MaddTheSane Make sure the fill color string has a length before trying to use it.
Minor changes in the read-me.
@MaddTheSane MaddTheSane Split the string in the NSBeginAlertSheet into separate lines. b0ed4c1
@MaddTheSane MaddTheSane Implement setting the log level in Lumberjack.
Have the DDLogLevel int hidden from other libs.
@MaddTheSane MaddTheSane Set the log level statically based on the debug flag at the number init. 264b31f
@MaddTheSane MaddTheSane Fix a leak, probably got introduced when popping a stash from arc to …

Define debug to zero in SKAppDelegate if it isn't defined so that exceptionInfo doesn't choke when building a release product.
@MaddTheSane MaddTheSane Predefine the SVGKSource class in SVGKImageRep's header, so we don't …
…need SVGKImage's header guards.

Remove SVGKImage's header guards.

Before you merge my code (because I have a lot of changes), merge other people's, then let me know so I can merge them on my branch and get them working.

MaddTheSane added some commits
@MaddTheSane MaddTheSane Fix spelling mistake. b747c66
@MaddTheSane MaddTheSane Add asynchronous parsing to SVGKParser, as well as having a delegate …
…that gets called when parsing is complete, either in the asynchronous or synchronous call.

Add a (commented out) tester for SVGKParser's asynchronous methods in OS X's Views demo.
@MaddTheSane MaddTheSane Change id<protocol> to NSObject<protocol>* on the sVGKParser. 5324a16
@MaddTheSane MaddTheSane Mangle a private setter name, while still making it available to thos…
…e who want to use KVO.
@MaddTheSane MaddTheSane Complain if we are sent a delegate while we're parsing.
More work on the parseAsynchronously tester.
@MaddTheSane MaddTheSane Add an Xcode workspace that has both iOS and OS X Xcode projects in it. cba1f5c
@MaddTheSane MaddTheSane Make it so SVGKImage doesn't throw an exception in dealloc if it fail…
…ed to init.
@MaddTheSane MaddTheSane Remove the header search path on master, too. f20ffb1
@MaddTheSane MaddTheSane Updating read-me, as well as doing some formatting. 218151b
@MaddTheSane MaddTheSane Adding documentation/read-me references to the OS X projects. 791640d
@MaddTheSane MaddTheSane Implement the CIImage getter in SVGKImage on iOS.
Despite being stated as needing to be linked to in the read-me, neither iOS projects includes or links against CoreImage. Fixing that.
@MaddTheSane MaddTheSane Grammar fix. d03b7f7
@MaddTheSane MaddTheSane Stop the render at the beginning of renderToContext if there's a rend…
…ering issue.
@MaddTheSane MaddTheSane Change the imageRep and UIImage exporters showWarning: to showInfo: a…
…s we're showing (debugging) info, and not a warning.

Add a private header for SVGKImage that has the renderInContext:… and export*:…showInfo: declarations in them.
Make SVGKImageRep use SVGKImage's private header
@MaddTheSane MaddTheSane Ifdef out checking for renderInContext:… in SVGKImages in SVGKImageRe…
…p and just use it.
@MaddTheSane MaddTheSane Remove the deprecated functions initWithPath: and initWithURL: from S…
…VGKImageRep: nothing is using them right now.
@MaddTheSane MaddTheSane Add a baseDescription method for SVGKSource and have its subclasses u…
…se it as part of their description.
@MaddTheSane MaddTheSane Trim down the ImageRep's include. fb7d6f9
@MaddTheSane MaddTheSane Delete .gitmodules
We don't have any submodules being used right now.
@MaddTheSane MaddTheSane Fix commented-out includes. 351fae0
@MaddTheSane MaddTheSane Fixing read-me spelling and stuff. 1fcb726
@MaddTheSane MaddTheSane Change NS_INLINEs back to static inlines. e26377c
@MaddTheSane MaddTheSane Setting the view that has the list to not resize when the window is r…
…esized on OS X.
@MaddTheSane MaddTheSane Fix a warning in 64-bit code. 5030d0a
@MaddTheSane MaddTheSane Changing the umbrella framework mention. 9b745f1

I've just checked out the new 1.1.0 code and will merge it shortly. Note that you might want to modify the read-me, as mine is specific to my branch.

MaddTheSane added some commits
@MaddTheSane MaddTheSane Merge remote-tracking branch 'svgkitmain/1.1.0' into 1.1.0
	Source/DOM classes/SVG-DOM/SVGHelperUtilities.m
	Source/DOM classes/Unported or Partial DOM/SVGGradientElement.h
	Source/DOM classes/Unported or Partial DOM/SVGGradientElement.m
@MaddTheSane MaddTheSane Update the code to work with OS X. 6d6f3a3

There, the merge should be fairly painless against current code in the 1.1.0 branch.


Please use the comments available via GitHub. Thank you.
As for using copy, it makes the setter copy mutable strings to immutable strings, as well as retain immutable strings.


Unfortunately my computer is having issues so it will be awhile before I can do anything.


This has too many commits for it to be merged, and the 1.1 branch isn't going to be updated with these requests. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.