Page 1 of 1

Mac Compatibility - Suggestion

Posted: 11 Nov 2011, 15:54
by leftygames
I made a few tweaks to the iPhone code to get it to work on my mac.... if useful for anyone:

1) Update where you import CFNetwork.h:

Code: Select all


//JBC: fixed imports so this works on mac too
#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED)

    //CFNetwork appears in CoreServices on mac
    #import <CoreServices/CoreServices.h>

#elif defined (__IPHONE_OS_VERSION_MAX_ALLOWED)

    //CFNetwork has its own framework on iphone
    #import <CFNetwork/CFNetwork.h>

#endif
2) update the handshake code to handle mac:

Code: Select all

//JBC: determine correct version number (different on IOS and MAC)        
#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED)
        
    //piece together the version of the OS
    int maj, min, fix;
    Gestalt(gestaltSystemVersionMajor, &maj);
    Gestalt(gestaltSystemVersionMinor, &min);
    Gestalt(gestaltSystemVersionBugFix, &fix);
    NSString *clientType = [NSString stringWithFormat:@"Mac version: %i.%i.%i", maj,min,fix];
        
#elif defined (__IPHONE_OS_VERSION_MAX_ALLOWED)
        
    //get device system version
    NSString *clientType = [NSString stringWithFormat:@"IOS version: %@", [[UIDevice currentDevice] systemVersion]];
        
#endif

[/code]

Posted: 11 Nov 2011, 17:30
by Lapo
You mean to make it work under MacOS X as opposed to iOS?

Posted: 11 Nov 2011, 23:20
by mmilen
The suggested changes does make sense. Those are the only changes I made to the API and it is working as a charm on Mac OS 5, OS 6 and OS 7. My Bridge game is with Mac clients since June and there has been no complains at all. You can make those changes and safely label the API iPhone / MAC OS

Posted: 15 Nov 2011, 20:20
by leftygames
Lapo wrote:You mean to make it work under MacOS X as opposed to iOS?
Those changes allow it to work under both Mac OS (tested with Lion) as well as iOS.

Note that you need to import the CoreServices framework in your Mac project.

I have tested it with a codebase that runs on both Mac and iOS.

Posted: 16 Nov 2011, 08:11
by Bax
Thanks for the suggestion. Added to our todo list :D