SFS2X Docs / GettingStarted / client-api-cpp-ios-xcode7
» Client API setup | C++
» iOS — Xcode 7 and higher
» Libraries compilation
To compile the required libraries, please check that you are using at least the release 1.59 of Boost.
Launch a Terminal on the file system path [api_folder]/Core/BoostAsio/Unix and type in the command chmod -R a+rwx+X ./
Now type in: ./bootstrap.sh –prefix=boost/ and wait for the command execution.
When completed, type in: ./b2
If all has been done with success, you will find out that a new directory named [api_folder]/Core/BoostAsio/Unix/stage/lib has been created, containing the built libraries.
The Terminal can now be closed.
The client API needs of OpenSSL library.
Please note that if you are working on a Mac computer based on OS X El Capitan, Apple has removed the OpenSSL header files.
This change in OS X makes it hard to build OpenSSL-dependent projects.
In OS X El Capitan you can get OpenSSL library from official website looking for version 1.0.2 in download section.
Note that OpenSSL project has delivered since 2016 newest versions of the library like the version 1.1.0. Do not use versions greater than 1.0.2 because they are not compatible
with Boost Library 1.59 used from client API.
Launch a Terminal to uncompress the archive got from OpenSSL website by command
tar -xvzf openssl-1.0.2h.tar.gz
Then move into created folder and type in
./Configure darwin64-x86_64-cc -shared
When completed, type in:
make
If all has been done with success, you will find out the built libraries libcrypto.a and libssl.a
The Terminal can now be closed.
Launch Xcode, and choose File\New\Project.
When the "Choose a template" dialog appears, select iOS\Framework & Library\Cocoa Touch Static Library
and create an iOS Cocoa Touch Static Library project for STL C++
Add all SmartFox API folders and files to created project.
Leave only SmartFox API source files in Targets->Build Phases->Compile Sources.
Leave only Boost libraries in Targets->Build Phases->Link
Binary With Libraries.
Set Preprocessor Macro to SMARTFOXCLIENTAPI_EXPORTS.
Set Preprocessor Macro to BOOST_THREAD_PROVIDES_FUTURE.
Disable the usage of precompiled headers.
Set Header Search Paths to [api_folder]/Core/BoostAsio/Unix.
Set Header Search Paths to [openssl_folder]/include.
Set Library Search Paths to
[api_folder]/Core/BoostAsio/Unix/stage/lib,
Set Library Search Paths to [openssl_folder].
Set Prelink libraries to
[openssl_folder]/libcrypto.a.
Set Prelink libraries to
[openssl_folder]/libssl.a.
Set Prelink libraries to
[api_folder]/Core/BoostAsio/Unix/stage/lib/libboost_thread.a.
Set Prelink libraries to
[api_folder]/Core/BoostAsio/Unix/stage/lib/libboost_system.a.
Set Perform Single-Object Prelink to Yes.
Set Other Linker Flags to -lz.
You can now build the SmartFoxServer 2X API and use it in your project.
» Setting up an SFS2X project
Move to the project settings of your Xcode client application. Select the topmost node from the Project Navigatorand select Build Settings.
Under Header Search Path add:
- [SFS2X-API-Folder]/Boost-Unix/
- [SFS2X-API-Folder]/
Under Library Search Path add:
- [Compiled-API-Folder]/
- [SFS2X-API-Folder]//Boost-Unix/stage/lib/
where [Compiled-API-Folder] is the path where you have stored the static API library file.
Under Other Linker Flags add -lz
Finally click on Build Phases in the top bar, select Link Binary with Libraries and add the API compiled .a file.