Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter for apple tv

a modification of the flutter engine + test application to demonstrate that flutter applications run on apple tv

this project (and liberty global repositories referred to) are for testing purposes only!

flutter and the related logo are trademarks of google llc we are not endorsed by or affiliated with google llc.

approach:

  • engine:
  • framework
    • no modifications in “flutter” tool (/framework)
    • platform tvos not supported, ios target cannot be used because without modifications it would the use wrong sdk(ios) to compile the application
  • application
    • changes compared to ios application setup:
      • modified main storyboard
      • icon set for tvos
      • custom script to compile application which replaces code_backend.sh in the “build phases” step. this script is based on scripts from the engine test application which only use tools from the engine. the normal script cannot be used because it used the standard “flutter” tool which does not support tvos.
    • copy generated resources from real ios app target. the test app target actually overwrites the ios build to use the resources.
    • change targets for application and pods to ‘tvos’ and set minimum os version to 12.0

known limitations

  • not all pods will compile. ios target is used and some api’s are not supported by tvos. e.g. webview
  • no debugging capabilities
  • no apple tv look and feel widgets, no integration of virtual keyboard, …
  • resource monitoring is not supported by tvos (using flutter tools)

known issues

  • when a debug version is installed on a simulator or apple tv device, then the app will not load when selected on screen. it will only load from the xcode debugger. this is not an issue for release builds. this has most likely to do with the fact that the app is trying to connect to 127.0.0.1 which is not started because the flutter tools are not used.

supported devices

  • apple tvos 12.0 or later

workarounds

setting up engine / development environment

compiling the engine

  • the script will build 5 targets for tvos in the src/out folder:
    • ios_debug_unopt, ios_debug_sim_unopt, ios_release, host_debug_unopt and host_release release
  • note: fectching all repositories and compiling the engine for apple tv (all targets) requires at leaste 29gb of free diskspace!
  • run in /engine/src/ script sh ninja_build.sh (located in script folder, see ninja_build.sh)
    • add paramter clean for a full rebuild.
    • note: the --no-lto flag can be removed on 32gb host systems
  • based on: https://github.com/flutter/flutter/wiki/compiling-the-engine. the problem with the order described on this wiki is that the generated files for the host point to the ios/tvos sdk instead of macos

compiling application

  • 1st build real ios target to make sure the resources(images, fonts, …) are generated by the flutter tools and can be used for tvos
    • flutter build ios
  • note: the application will regardless of the target, always be compiled to /build/ios/release-iphoneos. the main reasone for this is that the resouces generated by the normal ios build are located here and are re-used.
    • this means that if any of the resource will change, added or removed that normal ios build must be done first. in order to do this, the step below must be un done first!
  • rename tvos folder to ios
    • flutter tools assume the folder name is ios. flutter pub get will fail if the folder has a different name!
    • run command: sh scripts/switch_target.sh tvos
    • (to switch back to ios: sh scripts/switch_target.sh ios)
  • run command: flutter pub get
  • go to ios folder
  • install/get cocoa pods
    • run command: pod install
    • pods target is automatically corrected from ios to tvos in podfile post_install step
  • copy flutter framework to pods
    • run command: sh ../scripts/copy_framework.sh debug_sim <path to local flutter engine>/engine/src
    • copies debug simulator version. the correct version (debug, sim, release/archive) will be copied during app compilation
    • unfortunately this is a manual step, because the pods are compiled first as a dependency by xcode and there is no hook in the xcode build process before this to automatically copy the right frame work to be used based on the selected target
  • open in ios folder runner.xcworkspace
    • set path to local compiled flutter engine in flutter_local_engine (src folder)
    • e.g. flutter_local_engine = <your local path to flutter engine>/engine/src
    • alternatively run: sed -i '' "s#flutter_local_engine[[:space:]]=[[:space:]].*;#flutter_local_engine = "${flutter_local_engine}";#g" runner.xcodeproj/project.pbxproj
  • build app for device debug, simulator or archive (see switching target below)

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.