Mac Compatibility - Suggestion

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

Post Reply
leftygames
Posts: 5
Joined: 04 Nov 2011, 01:39

Mac Compatibility - Suggestion

Post 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]
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

You mean to make it work under MacOS X as opposed to iOS?
Lapo
--
gotoAndPlay()
...addicted to flash games
mmilen
Posts: 311
Joined: 09 Nov 2010, 00:48
Contact:

Post 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
leftygames
Posts: 5
Joined: 04 Nov 2011, 01:39

Post 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.
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

Thanks for the suggestion. Added to our todo list :D
Paolo Bax
The SmartFoxServer Team
Post Reply