• Examples (iOS)
• Examples (Android)
• Examples (C++)
Server API Documentation

 

» Client API setup | Objective-C

The Objective-C API provides a number of frameworks to develop native applications and games for Apple's iOS, tvOS and MacOS X.

View the instructions for your target platform:

» iOS, with Xcode 5 and higher

Compatibility note: the lowest version of iOS currently supported is iOS 6.

In the Project navigator, select your project, and select your target. Click on the Build Phases tab and expand Link Binaries With Libraries. Click the plus icon (+) and select Add Other... at the bottom left of the Frameworks window. Navigate to the SFS2XAPIIOS.framework folder that was unpacked previously, and select the SFS2XAPIIOS.framework folder (not the SFS2XAPIIOS file). Click Open.

» Other dependencies

Keep the Link Binaries With Libraries tab open from the previous step and click the plus icon (+).

» Other Linker Flags

Display your project settings by clicking on your project in the Project navigator and select the Build Settings tab. Type "other linker flags" in the search field. Enter -lz and -ObjC as values.

Finally import <SFS2XAPIIOS/SmartFox2XClient.h> in order to start using the SFS2X API for iOS.

» tvOS development with Xcode 7.1+ and higher

Compatibility note: the lowest version of tvOS currently supported is tvOS 9.0.

NOTE: A known bug in Xcode 7.1 currently prevents to use frameworks that are located outside of the project's folder. Make sure to copy the SFS2XAPI_tvOS.framework inside your project's main folder.

In the Project navigator, select your project, and select your target:

Keeping the same tab open, expand Link Binary with Libraries and add the following:

» Other Linker Flags

Display your project settings by clicking on your project in the Project navigator and select the Build Settings tab. Type "other linker flags" in the search field. Enter -lz and -ObjC as values.

Finally import <SFS2XAPI_tvOS/SmartFox2XClient.h> in order to start using the SFS2X API for OSX.

» OS X, with Xcode 5 and higher

Compatibility note: the lowest version of Mac OS X currently supported is Mac OS X 10.9 (Mavericks).

In the Project navigator, select your project, and select your target. Click on the Build Phases tab and expand Link Binaries With Libraries. Click the plus icon (+) and select Add Other... at the bottom left of the Frameworks window. Navigate to the SFS2XAPIOSX.framework folder that was unpacked previously, and select the SFS2XAPIOSX.framework folder. Click Open.

» Other dependencies

Keep the Link Binaries With Libraries tab open from the previous step and click the plus icon (+).

» Other Linker Flags

Display your project settings by clicking on your project in the Project navigator and select the Build Settings tab. Type "other linker flags" in the search field. Enter -lz and -ObjC as values.

Finally import <SFS2XAPIOSX/SmartFox2XClient.h> in order to start using the SFS2X API for OSX.

NOTE: in order to run an OSX application that is dependent on the SFS2X API you will need to have a copy of the library in your /Library/Frameworks/ folder. Failing to do so will cause a library loading error as soon as you hit the "Run" button.

» Notes on developing with Swift

If you're going to use Swift as your main language for iOS/tvOS/macOS development you will need an extra step to make sure you have a "bridging header" file, which allows to import and work with Objective-C libraries, such as the SFS2X API.

Once your project is created go ahead and create a bridging header by choosing File > New > File > (iOS, watchOS, tvOS, or macOS) > Source > Header File. The name of file must be be the product module name followed by "-Bridging-Header.h".

In other words if the project is called "MyGame" the header file name must be "MyGame-Bridging-Header.h". Inside the file we will import the Objective-C headers required by the SFS2X API:

#import <Foundation/Foundation.h>

#import <CFNetwork/CFNetwork.h>
#import <QuartzCore/QuartzCore.h>
#import <Security/Security.h>

#import <SFS2XAPIIOS/SmartFox2XClient.h>

Save the file and we are ready to get started developing in Swift.

« back to client API list