Question: tvOS support


#1

Is there any plan to support Apple’s tvOS anytime soon?

If anyone has more information about tvOS, would be great. As far I can know (or can tell) it seems that they have a path that’s new designed for TV UI, but a path that allows UI kit, which in an illustration allowed porting of an iOS game in “10 seconds”

My first guess is that SDL2 is going to be compatible with tvOS, or nearly compatible, and once it has support (if it does not yet) it should be fairly simple for us to pull a newer version and have support – though we would have to fuss with dealing with Xcode template changes, probably, but not the end of the world :slight_smile:


#2

I am the one who originally asked the question, so I’m jumping straight in! :smile:

tvOS is a mix of existing iOS technology and some new stuff. I’m waiting for the Developer Preview kit to be delivered next week so that I will be able to get my hands dirty.

The other big issue is that apps cannot be larger than 200Mb, nothing can be saved on the hdd (you have to use CloudKit or iCloud KVS storage) and assets should be streamed if they do not fit in the 200Mb limit.

AFAIK Unreal Engine has a tvOS branch but it’s far from being ready for the next release of the engine. Unity has an alpha version that supports tvOS, but then it looks like no other big players are already working on it. Of course it would be a big plus to be able to get on the Apple TV store as soon as possible for obvious reasons.


#3

Yeah, let’s keep our eyes open. I’m inclined to believe it won’t be hard

200MB is probably okay, no local storage is a bummer, perhaps remote SharedObject could be implemented in the future


#4

After toying around with the Developer Preview Kit for a few days, I can tell you that it’s pretty much iOS without some frameworks plus a few frameworks that are just for the tvOS. Most games would probably work without any changes as long as they support a game controller.
Please let me know if I can be of any help.


#5

Do we need any changes to our Xcode project, or do we need to compile any differently?


#6

Yes, some changes are needed indeed. The best would probably be to have a different project just like you already do for iOS and Mac and make a tvOS one.

Right now I’m stuck because the iOS build uses CoreMotion but tvOS does not provide that framework.

As you can see the error is the following:

Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_CMMotionManager", referenced from:
  objc-class-ref in liblime.a(d9029685_SDL_sysjoystick.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

On top of that, we need to change something during the build phase of the Haxe stuff as well as this is the kind of warnings I’m getting:

...
ld: warning: URGENT: building for tvOS, but linking in object file (/Users/tanis/Documents/openfl-test-tvos/DisplayingABitmap/Export/ios/DisplayingABitmap/lib/arm64/liblime.a(77b64e4f_x509.o)) built for iOS. Note: This will be an error in the future.
ld: warning: URGENT: building for tvOS, but linking in object file (/Users/tanis/Documents/openfl-test-tvos/DisplayingABitmap/Export/ios/DisplayingABitmap/lib/arm64/liblime.a(bd4c46fa_md2.o)) built for iOS. Note: This will be an error in the future.
ld: warning: URGENT: building for tvOS, but linking in object file (/Users/tanis/Documents/openfl-test-tvos/DisplayingABitmap/Export/ios/DisplayingABitmap/lib/arm64/liblime.a(bd4c46fa_bigint.o)) built for iOS. Note: This will be an error in the future.
...

If you can guide me in some way to tell liblime not to link against CoreMotion, that would be awesome. I might end up with a working tvOS project to share with you guys.

I hope to hear from you soon. Cheers!


#7

I suppose the problem lies in this file which is used by the iOS build (and could be used for tvOS as well with some changes).

https://github.com/openfl/lime/blob/64df4270b6fb7d79b4305788e2e11384d3c1c708/legacy/project/src/iPhone/UIStageView.mm

It makes use of CoreMotion for the accelerometer, but as far as I can see there should be a different way to access the accelerometer. CoreMotion isn’t in the tvOS SDK, so no way to use that. The UIAccelerometer class that lies in UIKit has been removed as well.
Right now I have no clue where it’s hidden. But I see that Unity is able to read from the accelerometer of the Apple TV remote, so there must definitely be a way to access that. My guess is that it’s being done through the GameController framework, as the GCController class now has a new property:

@property(nonatomic, retain, readonly) GCMotion *motion

which is a new object that handles the acceleration and gyroscope.

Again, if you can point me in the right direction I can try to fix that as well.


#8

@singmajesty if you can lend me a couple of your hours this Monday or any other time soon, we can probably quickly iron this out through a TeamViewer+Skype session, what do you think about it?


#9

i have a tvOS developer preview kit as well. i can try to help out, even if it’s only with testing. while i have a lot of iOS development experience, i don’t have much experience with building openFL-- i could help more if i had some guidance in how to get to the point you are at. thanks :slight_smile:

also, i see that luxeengine is running on tvOS, at least in some preliminary form https://twitter.com/snowkitorg/status/645416697546063872 although it seems the SDL changes have not been shared anywhere yet?


#10

Thanks for pointing out about Luxe. I dug further and here’s the Apple TV branch of SDL:
https://bitbucket.org/slime73/sdl-experiments/branch/AppleTV

All they did was add a bunch of defines to the iPhone target to avoid using frameworks that aren’t there in tvOS.
On top of that they added support for the micro game controller which is another thing to do. They still haven’t figured out how to correctly read the D-Pad and accelerator stuff though.

Here’s the plan I have in mind:

  • fork Lime and add a new target which is tvOS, just like iOS and Mac.
  • The tvOS target should be a copy of the iOS one with some changes, pretty much the same way the guys at SDL already did, but without all the defines. It’s probably better to keep it separated to make the code clearer.
  • Bring in the micro game controller code from the SDL branch
  • Add a new tvOS template to Lime so that we get a new platform with the correct XCode template

This should enable us to get a working OpenFL running on the Apple TV. But I’d love to hear from @singmajesty if that’s the correct route to follow before starting messing with the OpenFL/lime codebase :wink:


#11

@bunnyhero here’s the repo with my test project, so that you are on par with me: https://github.com/tanis2000/openfl-test-tvos


#12

If it is nearly the same as iOS, we could consider a target flag (such as windows versus windows -neko) but I suppose it warrants it’s own target (tvos)

To save on coding time, perhaps the TVOSPlatform could extend IOSPlatform, so it’s a few tweaks instead of its own large block of code. I think we should watch the SDL project (here: https://hg.libsdl.org/SDL/shortlog/) to see if tvOS changes work their way in. In the meantime, it should be possible to test some manual changes.

Perhaps we could consider a branch of the native-toolkit SDL project to do this.

BTW, there are two things that I think might be helpful that may be worth looking into. First, when I tried the latest SDL commits, I did not have retina resolution. I tried using HINT for retina, and got retina resolution at first, but the stage size seemed wrong, and it reset when rotating. I’m not sure if this is a problem with SDL itself (in newer dev commits) or just using it wrong?

The other is that it would be nice if our template used a custom *.mm file as the entry point, wrapping the SDL class, rather than hitting SDL directly. This might help with giving us an entry point for tweaks (such as if we decided to add game controller support ourselves instead of patching it into SDL, though is this related? https://hg.libsdl.org/SDL/rev/1496e502e51d)


#13

I’d go with its own target if it was my decision :smile:

Those changes haven’t made their way to the master branch yet. They are still on a personal branch of Alex Szpakowski (here: https://bitbucket.org/slime73/sdl-experiments/branch/AppleTV ).

Yes, that’s exactly the support for the Micro Game Controller and the accelerator as a joystick (Apple did it this way for the Apple TV remote).

@singmajesty is the SDL version included in Lime a modified version of the original SDL? Or is it just a copy of the original repo at a certain point in time? Any chance I could just replace it with the latest and hope it works out of the box?

@singmajesty is the new lime source code or the legacy one that’s being used for the iOS target on the master branch of lime’s repo?


#14

Lime is using a slightly modified copy of SDL (just with a minor fix for Raspberry Pi). You can find the repository here:

I’m on the September 7th commit in Lime, since iOS had the screen size thing (that I mentioned) in the newer dev release, but this might be something we could workaround if we use SDL differently?

Lime 2 uses SDL for iOS, but legacy has it’s own custom iOS code. I’d prefer to stick with SDL moving forward as it’s great to share in the efforts of other developers instead of maintaining our own code (that’s liable to be a maintenance problem)


#15

I agree with you on moving forward with SDL as it’s a much better option. Less maintenance overhead is good.

So the code I need to touch lies in the templates/ and tools/ folders. I’ll leave the legacy/ stuff untouched.

I’m pretty sure we can solve the Retina problem as well. Right now my main concern is to get something running on the Apple TV.

I will probably need some guidance at some point. I’ll keep you posted on my findings.


#16

I’m stuck at trying to tell lime to build the ndll for the tvOS architecture. I forked openfl/lime and you can have a look at the changes I made until now here: https://github.com/tanis2000/lime/commits/tvos

It looks like lime build tvos is doing something but it’s not generating the liblime. Any clues?

Cheers!


#17

Maybe you need to add something around here https://github.com/openfl/lime/blob/master/tools/CommandLineTools.hx#L128 there’s a switch with target name a little lower.

And maybe something in there too https://github.com/openfl/lime/blob/master/project/Build.xml#L10


#18

Thanks @ibilon!

I did add the following lines to the first file you suggested but I doubt it’s got anything to do with the compilation of the liblime itself.

					case "tvos":
						
						target = Platform.TVOS;

The Build.xml file also shows a lot of stuff for desktop platforms but there’s no reference to iOS. The only directive seems to be the one that says that if it’s iphone, it should be treated as ios.

Nonetheless, no file is being written in the ndll/ folder. Not even the tvOS/ folder is being created at the moment.


#19

Does adding the verbose mode -v give you more information?

Also maybe worth trying after manually creating the tvOS folder.


#20

This is the output:

iMacValerio:DisplayingABitmap tanis$ lime -v build tvos
 ___
/\_ \    __
\//\ \  /\_\    ___ ___      __
  \ \ \ \/\ \ /' __` __`\  /'__`\
   \_\ \_\ \ \/\ \/\ \/\ \/\  __/
   /\____\\ \_\ \_\ \_\ \_\ \____\
   \/____/ \/_/\/_/\/_/\/_/\/____/

Lime Command-Line Tools (2.6.6)

Initializing project...
Using project file: /Users/tanis/Documents/DisplayingABitmap/project.xml
Reading HXCPP config: /Users/tanis/.hxcpp_config.xml
Using target platform: TVOS

Running command: UPDATE
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ/haxe/Build.hxml -> Export/tvos/DisplayingABitmap//haxe/Build.hxml
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ/haxe/makefile -> Export/tvos/DisplayingABitmap//haxe/makefile
 - Copying template file: /Users/tanis/Documents/lime/templates/haxe/ApplicationMain.hx -> Export/tvos/DisplayingABitmap//haxe/ApplicationMain.hx
 - Copying template file: /Users/tanis/Documents/lime/templates/haxe/DefaultAssetLibrary.hx -> Export/tvos/DisplayingABitmap//haxe/DefaultAssetLibrary.hx
 - Copying template file: /usr/lib/haxe/lib/openfl/3,3,6/templates/haxe/ApplicationMain.hx -> Export/tvos/DisplayingABitmap//haxe/ApplicationMain.hx
 - Copying template file: /usr/lib/haxe/lib/openfl/3,3,6/templates/haxe/NMEPreloader.hx -> Export/tvos/DisplayingABitmap//haxe/NMEPreloader.hx
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ/Classes/Main.mm -> Export/tvos/DisplayingABitmap//Classes/Main.mm
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ/Images.xcassets/AppIcon.appiconset/Contents.json -> Export/tvos/DisplayingABitmap//Images.xcassets/AppIcon.appiconset/Contents.json
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ/Images.xcassets/LaunchImage.launchimage/Contents.json -> Export/tvos/DisplayingABitmap//Images.xcassets/LaunchImage.launchimage/Contents.json
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ/PROJ-Entitlements.plist -> Export/tvos/DisplayingABitmap//DisplayingABitmap-Entitlements.plist
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ/PROJ-Info.plist -> Export/tvos/DisplayingABitmap//DisplayingABitmap-Info.plist
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ/PROJ-Prefix.pch -> Export/tvos/DisplayingABitmap//DisplayingABitmap-Prefix.pch
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ.xcodeproj/project.pbxproj -> Export/tvos/DisplayingABitmap.xcodeproj/project.pbxproj
 - Copying template file: /Users/tanis/Documents/lime/templates/tvos/PROJ.xcodeproj/project.xcworkspace/contents.xcworkspacedata -> Export/tvos/DisplayingABitmap.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Error: Source path "/Users/tanis/Documents/lime/ndll/iPhone/liblime.iphoneos.a" does not exist

The error at the end is due to the fact that I cloned the IOSPlatform.hx to my TVOSPlatform.hx but I didn’t change all the file names and extensions (more on that later).

But the real problem is that if I do lime build ios -clean it actually compiles all of the cpp stuff to build the liblime.a library
If I do the same for tvOS just like this, lime build tvos -clean it doesn’t compile anything from the cpp stuff. I need to find what I’m missing before I can get back to the other libraries.

About the file names and extensions, I had to stick to iphoneos because the hxcpp stuff doesn’t come with a tvOS equivalent and I do not know if I should patch that project as well or if the libraries in there are being built by lime and thrown in there through some magic. Unfortunately this is the first time I’m looking at the whole toolchain and I still need to grasp where stuff is and what every tool does. That’s the reason why I hoped @singmajesty or any other core developer could lend me some time :stuck_out_tongue: