Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: iOS development progress  (Read 24374 times)

0 Members and 1 Guest are viewing this topic.

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
iOS development progress
« on: January 25, 2018, 10:12:51 pm »
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:
  • 9.3
  • 11.2

Xcode:
  • 9
« Last Edit: April 25, 2018, 06:39:24 pm by Jonny »

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: iOS development progress
« Reply #1 on: January 28, 2018, 05:34:09 pm »
This is really nice to get some kind of status about iOS development.
I've seen some IOS "if" conditions in CMake code but always wondered how to actually do an iOS build. Now I know :D

Is there a more or less defined list of what's left to do before it can be publicly released? I saw your notes but I don't expect them to be complete.

Are you the main maintainer of the iOS port? Are you currently working alone on it? Also I'm wondering, in case there were other maintainers in the past, who they were and up to where they went.

And one more question (sorry ;D ), how is the iOS port being made consistent with Android port? Both are mobile platforms and I'd expect that problems that affect one platform are very likely to affect the other one. So I'd expect kind of a synchronized development to ensure common API and shared solutions when appropriate.
Want to play movies in your SFML application? Check out sfeMovie!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: iOS development progress
« Reply #2 on: January 28, 2018, 06:17:10 pm »
Pretty much right after Laurent did the initial implementation of the iOS port, he said, he didn't want to maintain it. Ever since we haven't had any maintainer and generally the interest was quite low.
Jonny has been fixing up iOS in the past few weeks and I'd be happy to add him as iOS maintainer if he wishes it.

Android and iOS are build on completely different tech, so problems are most often not shared, unless they are of a architectural matter.
Given that we don't have anyone maintaining thr iOS code, there was so far no need for synchronization.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: iOS development progress
« Reply #3 on: January 28, 2018, 11:00:31 pm »
Pretty much right after Laurent did the initial implementation of the iOS port, he said, he didn't want to maintain it. Ever since we haven't had any maintainer and generally the interest was quite low.
Oh ok. Do you know how far it went?

Jonny has been fixing up iOS in the past few weeks and I'd be happy to add him as iOS maintainer if he wishes it.
Now you've put pressure ;D (good luck Jonny)

Android and iOS are build on completely different tech, so problems are most often not shared, unless they are of a architectural matter.
Given that we don't have anyone maintaining thr iOS code, there was so far no need for synchronization.
Hmm I don't know enough about both platforms but my feeling says there is a lot to share: how to design the input API and the window API, how to deal with sandboxed resources (in terms of API), should it be a different API from SFML's desktop one, or just an extended one (probably with feature that wouldn't apply to desktop platforms). Things like that. As for the background stuff yeah it's very different, but that's just implementation detail, you're free to do what you want there, you don't need to talk to people (huhu) to decide what to do. So I find this part easier and less time consuming.

Of course if there's no maintainer there's no synchronization. I thought there was one :)
Want to play movies in your SFML application? Check out sfeMovie!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: iOS development progress
« Reply #4 on: January 28, 2018, 11:24:23 pm »
To my knowledge it's fully featured. The audio module is still disabled, but Jonny is looking into fixing this. The original reason was that we were using libsndfile which doesn't allow static linking (LGPL) which is required for iOS, but since we moved away from libsndfile this is working fine now (once the CMake bits are updated).

The API is non different to the desktop API, no idea if inner working concepts can be shared, but given the nature of two totally different architectures, I doubt there's that much in common. But I've little knowledge on either platform, so I'm not the best to answer here.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: iOS development progress
« Reply #5 on: January 30, 2018, 07:13:51 am »
The Audio module has been enabled for a few weeks now, so it's fully featured, and actually looks to be working really good for me right now, other than the afore-mentioned screen size/rotation issue

Can't commit to being maintainer right now, but I'll work on it as much as I can, and maybe the situation will change in future  :P. BlueCobold on IRC has been helping a lot too, although they haven't been able to reproduce the screen issue which is bothering me right now :S

I'm hoping this thread can help some more people to dive into iOS and get something working, I'll add some example cmake script to the OP to show how to set up the bundle properly for Xcode


Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: iOS development progress
« Reply #6 on: January 30, 2018, 10:04:24 pm »
Tried a bit to have SFML compiled for iPhoneSimulator but it can't find OpenAL headers. I just set IOS_PLATFORM to SIMULATOR64 as you suggested in CMake GUI.
(click to show/hide)

In file included from /Users/ceylo/Development/SFML/src/SFML/Audio/ALCheck.cpp:28:
/Users/ceylo/Development/SFML/src/SFML/Audio/ALCheck.hpp:33:14: fatal error: 'OpenAl/al.h' file not found
    #include <OpenAl/al.h>
             ^~~~~~~~~~~~~
1 error generated.

I'm using Xcode 9.1 and current master branch of SFML repo. Not all changed to get it working are pushed to master branch?
Want to play movies in your SFML application? Check out sfeMovie!

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: iOS development progress
« Reply #7 on: January 30, 2018, 10:06:09 pm »
Probably related to this PR: https://github.com/SFML/SFML/pull/1263


Something else I saw recently is that according to this commit message the iOS implementation of the Clipboard API was never tested at the time. So now that we have some developers using iOS it would be great if one of you could test it :)
« Last Edit: January 31, 2018, 06:52:44 pm by Foaly »

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: iOS development progress
« Reply #8 on: January 31, 2018, 04:21:48 pm »
Yeah, let me know if the clipboard feature works; I'm curious to know ^^


correct link: https://github.com/SFML/SFML/commit/0637a2ef9938b842252056a1b2e69963391ed3ee

SFML / OS X developer

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: iOS development progress
« Reply #9 on: February 01, 2018, 12:15:57 am »
Just dropping by to say I’m offline this week due to moving house. Subject to Shaw engineers competency I should be back online on the 8th feb and will pick everything up again then.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: iOS development progress
« Reply #10 on: February 12, 2018, 10:33:57 pm »
Hello,

I've tried again to build SFML for iOS but to me it looks like there are so many issues at the moment. Just to have it compile :(
- First when targeting a real device, it tries to compile for armv7 but emit compilation errors because it also targets the latest iOS for deployment target (iOS 11) which doesn't support armv7 (this is 32-bits arm). So I made change to have iOS 10 as deployment target for now.
- Then although the toolchain file sets CMAKE_OSX_ARCHITECTURES correctly, this is set when project(SFML) is called in main CMakeLists.txt, but at that time CMAKE_OSX_ARCHITECTURES is already set to x86_64. And by default CMake doesn't change already set cache entries. So you get a x86_64 build for your iOS device :D (have fixed that on my side too)
- Also I don't understand why find_host_package() is used to find dependencies, because from what I understand this means finding dependencies for the host platform, not the target platform. But when you build for an iOS device you need to build with dependencies made for the target platform. On the other side I can't get anything to work with find_package() so I guess find_host_package() exists for a reason ;D
- find_host_package() finds frameworks in /Library/Frameworks if I don't remove the vorbis, ogg and FLAC frameworks there, instead of choosing the static libraries from SFML's extlibs dir.

Apart from that it builds ;D

Edit: i've put my changes there for now: https://github.com/Ceylo/SFML/compare/feature/CMakeTargetExport...Ceylo:feature/iOSCompilation
Could get all examples to build (with a few tweaks related to OpenGL vs OpenGL ES) not comitted yet as it's WIP. It's based on my other branch because eventually it's easier to setup everything and propagates properties correctly.
« Last Edit: February 12, 2018, 11:33:45 pm by Ceylo »
Want to play movies in your SFML application? Check out sfeMovie!

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: iOS development progress
« Reply #11 on: February 16, 2018, 03:10:06 am »
I'm back online now, so will start picking things up again.

Ceylo - massive thanks for the input. Great to have another set of eyes, and you've confirmed some things I wasn't sure about. I also had a ping from tlein on IRC who provided the toolchain, but unfortunately I was offline and seemed to have missed them.

As far as the architecture stuff goes, I see no reason to support 32bit, it will be far more hassle than it's worth. all hardware has been 64 bit for several years, and you can't release a 32 bit app on the App Store anymore.

I'm also not 100% clear on the intention of find_host_package :P

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: iOS development progress
« Reply #12 on: February 17, 2018, 11:57:31 am »
Good to know that 32 bits support can be dropped! That's what I thought but wasn't sure. From what I saw this excludes iPhone 5C (released in 2013) and older. Should be quite ok. Also found this grid which provides a nice overview: http://blakespot.com/ios_device_specifications_grid.html

So will drop armv7 support and probably let the user choose the deployment target. I noticed however that the externals static libs for iOS were built with iOS 10.2 as min target. So unless we recompile these we'll probably have to stick with 10.2 as a minimal requirement for now.
Want to play movies in your SFML application? Check out sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: iOS development progress
« Reply #13 on: February 17, 2018, 03:39:23 pm »
I've removed ARM 32 bits support, added an option to choose the iOS deployment target and made sure iOS static libs are found first, even if "matching" frameworks are installed in /Library/Frameworks.
Changes are still visible at https://github.com/Ceylo/SFML/compare/feature/CMakeTargetExport...Ceylo:feature/iOSCompilation

Also the crashes when launching examples in the simulator look to be related to code signing / bundle identifier. After setting them and doing clean/rebuild it launches correctly in simulator.

For now I could launch both the "window" and "opengl" example in simulator and real iOS device, but the display remains full black without any errors in logs. And pausing the app shows a normal running event loop.

Also I couldn't build the pong example because the freetype static lib wasn't built with bitcode enabled. I guess there'll be the same issue with the flac, ogg and vorbis static libs. According to Apple documentation, bitcode is optional when building for iOS, but is required for tvOS and watchOS. Also even for iOS it is enabled by default, so it feels like it will be much simpler if we stick with their default. I have no idea how iOS dependencies were previously built though. If we go with rebuilding them, we should also take this occasion to lower the iOS deployment target (currently 10.2) as I don't see any reason not to support iOS 9 for example.


Edit: I fixed CMake code to always the bundle identifier on examples so no more IDE crash. Also did half of the work for code signing to ease building for real devices. I say half because Xcode looks to automate some parts when a developer chooses a "Development Team" and I don't know how to do that with CMake.
« Last Edit: February 17, 2018, 06:04:53 pm by Ceylo »
Want to play movies in your SFML application? Check out sfeMovie!

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: iOS development progress
« Reply #14 on: February 17, 2018, 07:20:20 pm »
Now I have the "window" example that launches and runs "correctly". It displays the cube, but orientation handling looks wrong, and it doesn't take advantage of the whole screen (on iPad it shows a x1/x2 button to scale contents, booh!).
"pong" and "opengl" also launch but stop because of missing image files for now.

The whole point to not stay with a black screen was including <SFML/Main.hpp> in the example's main file. To avoid further issues with this I added a check in SFAppDelegate.mm, so that this doesn't go unnoticed.
Want to play movies in your SFML application? Check out sfeMovie!

 

anything