How to connect native Xsolla SDK for iOS to your project
You can use native Xsolla SDK for iOS to implement features, such as social login and returning to applications after purchase for mobile applications.
To connect the native SDK to a Cocos Creator project, follow these steps:
- Generate a project for Xcode.
- Connect the Xsolla SDK for iOS to the project.
- Set up the project in Xcode.
Generate project for Xcode
- In the Cocos Creator editor, go to
Project > Build in the main menu. If the application wasn’t built for platforms before, a window for creating a new configuration for build will open. If the editor already has configurations to build, clickNew Build Task to create a new configuration. - In the
New Build Configuration window, make the following changes:
- In the
Platform field, selectiOS from the list of available build platforms. - In the
Developer Team section, specify your developer profile.
- In the
- Click
Build . - In the main menu, go to
File > Project Settings . - In the
Build System field, specifyNew Build System .
As a result, a project for Xcode is generated in the <CocosProjectPath>/build/iOS/proj
directory. Files that are used for all iOS builds, are generated in the <CocosProjectPath>/native/engine/ios
directory.
Connect Xsolla SDK for iOS to project
Add connector scripts for the Xsolla SDK libraries to the source code. To do this:
- Copy files from the
<CocosProjectPath>/extensions/xsolla-commerce-sdk/native/ios/Scripts
folder to the<CocosProjectPath>/native/engine/ios
folder. - Open the
<CocosProjectPath>/native/engine/ios/CMakeLists.txt
file with any text editor and add the following lines to thePROJ_SOURCES
list:
Copy
${CMAKE_CURRENT_LIST_DIR}/XsollaUtils.h
${CMAKE_CURRENT_LIST_DIR}/XsollaUtils.mm
${CMAKE_CURRENT_LIST_DIR}/XsollaNativeUtils.mm
${CMAKE_CURRENT_LIST_DIR}/XsollaSDKLoginKitObjectiveC-Bridging-Header.h
Set up project in Xcode
- In Xcode, open your project from the
<CocosProjectPath>/build/ios/proj
directory. - Connect the frameworks from the Xsolla SDK to the project. To do this:
- Go to project settings.
- Select the target with the name of your project.
- Go to the
General > Embedded Content section and click on the + icon. - In the window that appears, select
Add Other > Add Files from the drop-down list. - Select all the framework folders in the
<CocosProjectPath>/extensions/xsolla-commerce-sdk/native/ios/Frameworks
directory and clickOpen .
Was this article helpful?
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.Found a typo or other text error? Select the text and press Ctrl+Enter.