Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve OSX compatibility #4

Merged
merged 2 commits into from
Oct 15, 2012
Merged

Improve OSX compatibility #4

merged 2 commits into from
Oct 15, 2012

Conversation

mcianni
Copy link
Contributor

@mcianni mcianni commented Oct 12, 2012

I fixed a couple syntax errors encountered when building for OSX.

@arielelkin
Copy link
Collaborator

Hey there,

Thanks for the pull request! It's looking good, but building for OS X fails as there's a problem on line 12 of PocketSVG.h: 'UIKit/UIkit.h' file not found

I don't understand why, as the ifdefs are working fine on the .m file. I tried adding #include "TargetConditionals.h" to the top of the file but still get the same problem... Any ideas?

Ariel

@mindbrix
Copy link

Hi Ariel. This works for me:

#if TARGET_OS_IPHONE

#import <UIKit/UIKit.h>

#else

#import <Cocoa/Cocoa.h>

#endif

@mcianni
Copy link
Contributor Author

mcianni commented Oct 14, 2012

Good catch mindbrix, when building for osx, TARGET_OS_IPHONE is defined, but as 0.

My last commit fixes it throughout the project.

I also saw that error, but assuming it was a discrepancy between our environments I just #undef'd TARGET_OS_IPHONE in my .pch

Mike

arielelkin added a commit that referenced this pull request Oct 15, 2012
Improve OSX compatibility
@arielelkin arielelkin merged commit 81f3510 into pocketsvg:master Oct 15, 2012
@arielelkin
Copy link
Collaborator

Hey Mike (and Nigel),

Thanks for your contribution. I've now merged your pull request.

I would now like to add an example Xcode project for OS X, I'm working on it on the project's develop branch.

As you might see, things are working fine except for the CAShapeLayer's rendering upside down (uncomment line 290 of PocketSVG.m on the develop branch). I'm trying to find a way of doing this without calling CGContextTranslateCTM...

Let me know if you have any ideas..

Ariel

@mindbrix
Copy link

Hi Ariel. This translates from UIKit to Quartz coordinate spaces, vertically inverting the coordinates. It might work for SVGKit on OS X too.

Nigel.

CGAffineTransform uiKitCTM( CGRect viewBounds )
{
return CGAffineTransformConcat( CGAffineTransformMakeScale( 1.0f, -1.0f ), CGAffineTransformMakeTranslation( 0.0f, viewBounds.size.height ));
};

@mcianni
Copy link
Contributor Author

mcianni commented Oct 16, 2012

Ariel,

If you move the drawing code to a subclass of NSView, you can override

- (BOOL)isFlipped
{
    return YES;
}

to flip the vertical plane. (I'm sure this just uses Nigel's solution.)

Mike

@arielelkin
Copy link
Collaborator

Hey guys,

I now created separate directories for the iOS and OS X sample projects, they both use PocketSVG.h and PocketSVG.m which stays in the root directory.

Ariel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants