Skip to content
This repository
Browse code

merging pull request 24

  • Loading branch information...
commit c18561e954c445fdc904f0c999a3d289ddd594f6 1 parent 42184f4
Steven Fusco authored July 16, 2012
109  README.mdown
Source Rendered
... ...
@@ -1,22 +1,103 @@
1  
-SVGKit
2  
-======
  1
+# SVGKit
3 2
 
4  
-SVGKit is a cross-platform Cocoa framework for rendering SVG files as Core Animation layers. All shapes are represented by instances of the `CAShapeLayer` class, and are, by design, animatable. SVGKit is compatible with the latest OS X and iOS SDK's.
  3
+SVGKit is a Cocoa framework for rendering SVG files as Core Animation layers. 
  4
+All shapes are represented by instances of the `CAShapeLayer` class, and are, by design, animatable. 
  5
+SVGKit works on OS X and iOS.
5 6
 
6  
-Installation
7  
-------------
  7
+## Xcode Projects Included
8 8
 
9  
-Dependencies:
  9
+- SVGKit - the core library, builds the frameworks, also runs a shell script to build a fat lib
  10
+- SVGPadDemo - demo using the core libs on iOS
  11
+- SVGTesterDemo - demo + test app that uses core libs on OSX
10 12
 
11  
-  git submodule init && git submodule update
  13
+## Fetching
12 14
 
13  
-XCodeProjects:
  15
+    git clone <svgkit url>
  16
+    
  17
+    # if you want to export CALayers using the iPad project....
  18
+    cd SVGKit/
  19
+    git submodule init
  20
+    git submodule update
14 21
 
15  
-1. SVGKit - the core library, builds the frameworks, also runs a shell script to build a fat lib
16  
-2. SVGPadDemo - demo using the core libs on iOS
17  
-3. SVGTesterDemo - demo + test app that uses core libs on OSX
  22
+Without the git submodules, the iOS test project will fail to compile.
  23
+You don't need the calayer exporter to use SVGKit, it's just something nice for debugging in the simulator.
  24
+If you don't care about that, you don't need them.
18 25
 
19  
-Bugs
20  
-----
  26
+## iOS
21 27
 
22  
-Please report any issues or suggest improvements in the issue tracker and attach **as much info as you can** including the source SVG used that failed to parse, core dumps, instruments logs, patch code, etc.  Anything helps.
  28
+iOS support is robust.  The development team uses iOS as the primary target.
  29
+
  30
+## Desktop
  31
+
  32
+Desktop support is...  not quite as robust.
  33
+You may find many places things fail or break entirely.
  34
+We try to keep up with it, and we appreciate any help we can get.
  35
+
  36
+## Cross Platform Library Build
  37
+
  38
+To build a single library that can be linked from the simulator and from a device, you'll need to do these steps:
  39
+
  40
+1. Open the project "XcodeProjects/SVGKit/SVGKit"
  41
+2. Select the target "SVGKit Library > iOS Device" scheme selector dropdown in the top left
  42
+3. In the main content area, select the "Build Phases" tab, expand the "Run Script" step, and make sure "Run script only when installing" is not checked.
  43
+4. Build
  44
+5. Select Window > Organizer > Projects > SVGKit, then follow the link arrow to the "Derived Data" folder.
  45
+6. Using finder, navigate to Build > Products > Debug-universal
  46
+7. Drag/drop the library file, and the headers folder (should be called "usr") into your iPhone/iPad project.
  47
+8. Edit your build settings and set "C/C++ Compiler Version" = "LLVM Compiler 2.0"
  48
+9. Edit your build settings and add "Other Linker Flags" = "-ObjC"
  49
+10. Edit your build settings and add "Header Search Paths" = "/usr/include/libxml2"
  50
+11. Add the framework "libxml2.dylib"
  51
+
  52
+## Using on iOS
  53
+
  54
+    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  55
+    {
  56
+        // Override point for customization after application launch.
  57
+        [self.window makeKeyAndVisible];
  58
+
  59
+        NSString* svgFilename = @"Monkey";
  60
+
  61
+        NSLog( @"[%@] Loading SVG document, filename = %@", [self class], svgFilename );
  62
+
  63
+        /** Optional: if you're using the parser extensions, add them here
  64
+        [SVGDocument addSVGParserExtension:[[SVGParserConquest alloc] init]];
  65
+        */
  66
+
  67
+        SVGDocument* svgDocument = [SVGDocument documentNamed:svgFilename];
  68
+
  69
+        SVGDocumentView* docView = [SVGDocumentView documentViewWithDocument:svgDocument];
  70
+
  71
+        [self.window.layer addSublayer:docView.rootLayer];  
  72
+
  73
+        return YES;
  74
+    }
  75
+
  76
+## Using on OS X
  77
+
  78
+    SVGDocument *document = [SVGDocument documentNamed:@"image"]; // located in the application bundle
  79
+    // or...
  80
+    SVGDocument *document = [[SVGDocument alloc] initWithContentsOfFile:@"filepath"]; // possibly not in application bundle
  81
+
  82
+    // then
  83
+    NSView *v = ... ;  // make sure your instance of `NSView` is layer-backed.
  84
+    [v setWantsLayer:YES];
  85
+    [v.layer addSublayer:[document layerTree]];
  86
+
  87
+Your SVG file should now be rendered on-screen.
  88
+You can query for specific layers by using the `layerWithIdentifier:` method, also defined on `SVGDocument`.
  89
+The identifier corresponds to the `id` attribute defined on elements.
  90
+Once a reference to a subclass of `CALayer` is returned, its properties can be animated using  implicit or explicit [Core Animation](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/AnimatingLayers.html%23//apple_ref/doc/uid/TP40006085-SW1) animations.
  91
+
  92
+## ARC Support
  93
+
  94
+Call us old fashioned, to stay compatible with a wider variety of environments we don't use ARC in SVGKit.  
  95
+There is a fork of the code that is ARC based but because of the other many  big changes happening, it is severely out of date and is more there for "historical purposes".
  96
+Linking from an ARC project should  not pose an issue, but do let us know if you run into one.
  97
+If you did not do the cross-compile using our build script mentioned above and did a drag-drop install like some folks like to do, then remember to pass `-fno-objc-arc` on each of the `.m` files using the build settings.
  98
+You can [read more about ARC build flags here](http://clang.llvm.org/docs/AutomaticReferenceCounting.html).
  99
+
  100
+## I did all that, it doesn't work, you guys suck.
  101
+
  102
+Please report any issues or suggest improvements in the issue tracker and include as much detail as you can including build output, logs, error messages, stack traces, example code, whatever.
  103
+This is a volunteer effort, we have wives, kids, businesses, and apps of our own, please be patient with us.
6  XCodeProjects/SVGKit/SVGKit.xcodeproj/project.pbxproj
@@ -161,7 +161,7 @@
161 161
 		3BF5039D148C5FBC00CC7D17 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; };
162 162
 		3BF5039F148C5FC600CC7D17 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
163 163
 		3BF503A1148C5FCE00CC7D17 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
164  
-		3BF503A3148C5FD400CC7D17 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree =  SDKROOT; };
  164
+		3BF503A3148C5FD400CC7D17 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
165 165
 		6604FCF314A0CDA800B4D2D9 /* SVGPointsAndPathsParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVGPointsAndPathsParser.m; sourceTree = "<group>"; };
166 166
 		6604FCF414A0CDA800B4D2D9 /* SVGPointsAndPathsParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPointsAndPathsParser.h; sourceTree = "<group>"; };
167 167
 		6604FCF514A0CDA800B4D2D9 /* SVGTextElement.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVGTextElement.m; sourceTree = "<group>"; };
@@ -660,14 +660,14 @@
660 660
 /* Begin PBXShellScriptBuildPhase section */
661 661
 		66213464148AF3A7006881E1 /* ShellScript */ = {
662 662
 			isa = PBXShellScriptBuildPhase;
663  
-			buildActionMask = 8;
  663
+			buildActionMask = 12;
664 664
 			files = (
665 665
 			);
666 666
 			inputPaths = (
667 667
 			);
668 668
 			outputPaths = (
669 669
 			);
670  
-			runOnlyForDeploymentPostprocessing = 1;
  670
+			runOnlyForDeploymentPostprocessing = 0;
671 671
 			shellPath = /bin/sh;
672 672
 			shellScript = "# Version 2.0 (updated for Xcode 4, with some fixes)\n# Changes:\n#    - Works with xcode 4, even when running xcode 3 projects (Workarounds for apple bugs)\n#    - Faster / better: only runs lipo once, instead of once per recursion\n#    - Added some debugging statemetns that can be switched on/off by changing the DEBUG_THIS_SCRIPT variable to \"true\"\n#    - Fixed some typos\n# 4\n# Purpose:\n#   Create a static library for iPhone from within XCode\n#   Because Apple staff DELIBERATELY broke Xcode to make this impossible from the GUI (Xcode 3.2.3 specifically states this in the Release notes!)\n#   ...no, I don't understand why they did this!\n#\n# Author: Adam Martin - http://twitter.com/redglassesapps\n# Based on: original script from Eonil (main changes: Eonil's script WILL NOT WORK in Xcode GUI - it WILL CRASH YOUR COMPUTER)\n#\n# More info: see this Stack Overflow question: http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4\n\n#################[ Tests: helps workaround any future bugs in Xcode ]########\n#\nDEBUG_THIS_SCRIPT=\"false\"\n\nif [ $DEBUG_THIS_SCRIPT = \"true\" ]\nthen\necho \"########### TESTS #############\"\necho \"Use the following variables when debugging this script; note that they may change on recursions\"\necho \"BUILD_DIR = $BUILD_DIR\"\necho \"BUILD_ROOT = $BUILD_ROOT\"\necho \"CONFIGURATION_BUILD_DIR = $CONFIGURATION_BUILD_DIR\"\necho \"BUILT_PRODUCTS_DIR = $BUILT_PRODUCTS_DIR\"\necho \"CONFIGURATION_TEMP_DIR = $CONFIGURATION_TEMP_DIR\"\necho \"TARGET_BUILD_DIR = $TARGET_BUILD_DIR\"\nfi\n\n#####################[ part 1 ]##################\n# First, work out the BASESDK version number (NB: Apple ought to report this, but they hide it)\n#    (incidental: searching for substrings in sh is a nightmare! Sob)\n\nSDK_VERSION=$(echo ${SDK_NAME} | grep -o '.\\{3\\}$')\n\n# Next, work out if we're in SIM or DEVICE\n\nif [ ${PLATFORM_NAME} = \"iphonesimulator\" ]\nthen\nOTHER_SDK_TO_BUILD=iphoneos${SDK_VERSION}\nelse\nOTHER_SDK_TO_BUILD=iphonesimulator${SDK_VERSION}\nfi\n\necho \"XCode has selected SDK: ${PLATFORM_NAME} with version: ${SDK_VERSION} (although back-targetting: ${IPHONEOS_DEPLOYMENT_TARGET})\"\necho \"...therefore, OTHER_SDK_TO_BUILD = ${OTHER_SDK_TO_BUILD}\"\n#\n#####################[ end of part 1 ]##################\n\n#####################[ part 2 ]##################\n#\n# IF this is the original invocation, invoke WHATEVER other builds are required\n#\n# Xcode is already building ONE target...\n#\n# ...but this is a LIBRARY, so Apple is wrong to set it to build just one.\n# ...we need to build ALL targets\n# ...we MUST NOT re-build the target that is ALREADY being built: Xcode WILL CRASH YOUR COMPUTER if you try this (infinite recursion!)\n#\n#\n# So: build ONLY the missing platforms/configurations.\n\nif [ \"true\" == ${ALREADYINVOKED:-false} ]\nthen\necho \"RECURSION: I am NOT the root invocation, so I'm NOT going to recurse\"\nelse\n# CRITICAL:\n# Prevent infinite recursion (Xcode sucks)\nexport ALREADYINVOKED=\"true\"\n\necho \"RECURSION: I am the root ... recursing all missing build targets NOW...\"\necho \"RECURSION: ...about to invoke: xcodebuild -configuration \\\"${CONFIGURATION}\\\" -target \\\"${TARGET_NAME}\\\" -sdk \\\"${OTHER_SDK_TO_BUILD}\\\" ${ACTION} RUN_CLANG_STATIC_ANALYZER=NO\"\nxcodebuild -configuration \"${CONFIGURATION}\" -target \"${TARGET_NAME}\" -sdk \"${OTHER_SDK_TO_BUILD}\" ${ACTION} RUN_CLANG_STATIC_ANALYZER=NO BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\"\n\nACTION=\"build\"\n\n#Merge all platform binaries as a fat binary for each configurations.\n\n# Calculate where the (multiple) built files are coming from:\nCURRENTCONFIG_DEVICE_DIR=${SYMROOT}/${CONFIGURATION}-iphoneos\nCURRENTCONFIG_SIMULATOR_DIR=${SYMROOT}/${CONFIGURATION}-iphonesimulator\n\necho \"Taking device build from: ${CURRENTCONFIG_DEVICE_DIR}\"\necho \"Taking simulator build from: ${CURRENTCONFIG_SIMULATOR_DIR}\"\n\nCREATING_UNIVERSAL_DIR=${SYMROOT}/${CONFIGURATION}-universal\necho \"...I will output a universal build to: ${CREATING_UNIVERSAL_DIR}\"\n\n# ... remove the products of previous runs of this script\n#      NB: this directory is ONLY created by this script - it should be safe to delete!\n\nrm -rf \"${CREATING_UNIVERSAL_DIR}\"\nmkdir \"${CREATING_UNIVERSAL_DIR}\"\n\n#\necho \"lipo: for current configuration (${CONFIGURATION}) creating output file: ${CREATING_UNIVERSAL_DIR}/${EXECUTABLE_NAME}\"\nlipo -create -output \"${CREATING_UNIVERSAL_DIR}/${EXECUTABLE_NAME}\" \"${CURRENTCONFIG_DEVICE_DIR}/${EXECUTABLE_NAME}\" \"${CURRENTCONFIG_SIMULATOR_DIR}/${EXECUTABLE_NAME}\"\n\n#########\n#\n# Added: StackOverflow suggestion to also copy \"include\" files\n#    (untested, but should work OK)\n#\nif [ -d \"${CURRENTCONFIG_DEVICE_DIR}/usr/local/include\" ]\nthen\nmkdir -p \"${CREATING_UNIVERSAL_DIR}/usr/local/include\"\n# * needs to be outside the double quotes?\ncp \"${CURRENTCONFIG_DEVICE_DIR}/usr/local/include/\"* \"${CREATING_UNIVERSAL_DIR}/usr/local/include\"\nfi\nfi\n";
673 673
 			showEnvVarsInLog = 0;

0 notes on commit c18561e

Please sign in to comment.
Something went wrong with that request. Please try again.