As I've recently found myself with some free time I've been focussing on iOS stuff. I'm going to write down any tips or issues I find here, and hopefully make some progress towards proper iOS support in SFML. I'm mostly just using my SFML-DOOM project to test with, so I'd also like to gather together anyone who has a project they are currently developing for iOS, or plan to develop for iOS in the future.
SFML Installation:Since the iOS toolchain has been added this is much simpler
cmake .. -GXcode -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/iOS.toolchain.cmake
To generate the example(s) add the usual flag -DSFML_BUILD_EXAMPLES=TRUE
then install as you would normally.
sudo cmake --build . --target install
Notes:
- IOS_PLATFORM cmake variable is used to specify target platform: OS for a real device, SIMULATOR for the simulator
- Currently the toolchain forces static libs. I need to research this more, but I don't think this is a requirement for every iOS version, so may want more flexibility in future
- Make sure you don't have the desktop SFML dependencies installed in your search path, or CMake might pick them up instead, giving you a compilation error
An iOS project using SFML:If your project is also using cmake, it's just a case of copying the SFML toolchain file and using it in your project to generate the Xcode project.
You'll need to add some extra code to your CMakeLists to generate an app bundle, and set some Xcode parameters, e.g.:
if(APPLE)
# Set some details for the app bundle. Without these my xcode crashes when debugging ios :S
set(MACOSX_BUNDLE_IDENTIFIERcom.sfml.boop.SFML-APP)
set(MACOSX_BUNDLE_NAME SFML-APP)
set_source_files_properties( ${CMAKE_SOURCE_DIR}/apple/icon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
set_source_files_properties( ${CMAKE_SOURCE_DIR}/assets PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
#Include resources when creating executable
add_executable(SFML-DOOM MACOSX_BUNDLE ${INCLUDE} ${SOURCE} ${CMAKE_SOURCE_DIR}/apple/icon.icns
${CMAKE_SOURCE_DIR}/assets)
# Set the app bundle icon
set_target_properties( SFML-DOOM PROPERTIES MACOSX_BUNDLE_ICON_FILE icon.icns )
endif()
Notes:
- Make sure to use the same IOS_PLATFORM as you did when building SFML
- Make sure you have included SFML/Main.hpp in your main file, and make sure main function signature has no parameters (i.e. must be int main())
- No Shaders!
Outstanding issues/PR's (Please help test if you can!)
If you follow
https://github.com/jonnyptn/sfml-doom I'll update that as I go along.
If anybody has an existing SFML project using cmake and are curious about an iOS build, feel free to mention it in here as I could use as many test projects as possible.
Version support:These are the platforms and Xcode versions I've tested on, if you've had success with any others please comment here so I can add to the list:
iOS:
Xcode: