Flutter demo application for Apple TV (tvos) using custom Flutter engine

Overview

Flutter app on Apple TV

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 /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 = /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)

Common issues

  • If compilation fails because of this reason:
    Showing Recent Messages
    Ignoring file /Users/../tvos-demo/ios/Flutter/Flutter.framework/Flutter, building for tvOS Simulator-x86\_64 but attempting to link with file built for tvOS-arm64
    Undefined symbol: _OBJC_CLASS_$_FlutterError
    Undefined symbol: _OBJC_CLASS_$_FlutterMethodChannel
    Undefined symbol: _FlutterMethodNotImplemented
    • When switching between targetes (simulator <=> debug/release), then the correct framework must be copied / updated
    • This can be solved by copy the correct version of the framework to the flutter folder
      • sh scripts/copy_framework.sh
      • Targets: debug, debug_sim, release
  • Switching between targets: simulator(debug), debug (on Actual AppleTV device) & Release/archive
    • First "Clean build folder" in Xcode
    • Copy to be used framework (See above)
    • Build / Archive
  • Distribution / Validation in Organizer fails
    • Check if both ios_deployment_target & MinimumOSVersion in the engine and app match. Both must be 12.0!
      • The info.plist file is copied from the engine to the flutter.framework folder and contains 12.0

Contributors

Jürgen Wölke, Prikshit Chahar, Andrei Lesnitsky
v2.0.4: Aleksandr Denisov, Oleksandr Prokhorenko, Maksim Nazaruk, Andrei Kulbeda

You might also like...

A simple recipe showing application made using Flutter , using card Views MaterialPageRoute etc.

recipes A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Oct 31, 2021

Travel-Application-Ui-design - A Simple Travel Application Ui design For Flutter

Travel-Application-Ui-design - A Simple Travel Application Ui design For Flutter

Flutter Simple Travel Application UI Design A part of #flutter100daysofcode. Let

Jan 28, 2022

gceditor - a client/server application for creating a persistent data of an application

gceditor - a client/server application for creating a persistent data of an application

gceditor - a client/server application for creating a persistent data of an application

Dec 17, 2022

🚀 This is mobile application using Flutter for develop a pizza store

  🚀 This is mobile application using Flutter for develop a pizza store

Flutter Pizza Hut 🍕 Description: 🚀 This is mobile application using Flutter for develop a pizza store 🚀 Factory Method Create Enum product_type.dar

Dec 9, 2022

🚀 This is mobile application using Flutter for develop Tiktok

     🚀 This is mobile application using Flutter for develop Tiktok

Flutter Tiktok Clone Description: 🚀 This is mobile application using Flutter for develop Tiktok How I can run it? 🚀 Clone this repo 🚀 Run below cod

Feb 8, 2022

This is mobile application fortune telling using Flutter for development.

This is mobile application fortune telling using Flutter for development.

Flutter Tarot Card Description: This is mobile application fortune telling using Flutter for development. How I can run it? 🚀 Clone this repository ?

Sep 25, 2022

This is project using flutter and firebase for develop a mobile application about online school

This is project using flutter and firebase for develop a mobile application about online school

This is project using flutter and firebase for develop a mobile application about online school

May 17, 2021

It is the Tangram application that I created using flutter.

It is the Tangram application that I created using flutter.

Tangram App What is a TANGRAM? Tangram is a creative intelligence game on the basis of creating various forms by combining seven geometrically shaped

Oct 26, 2022

An application built using Flutter that is to conduct a quiz and provide the user with the result of the quiz.

An application built using Flutter that is to conduct a quiz and provide the user with the result of the quiz.

Quizzler Challenge Solution This is a companion project to The App Brewery's Complete Flutter Development Bootcamp, check out the full course at www.a

Sep 8, 2022
Comments
  • Can't upload archive to TestFlight

    Can't upload archive to TestFlight

    While porting an iOS app to the flutter-tvos-engine I've succesfully managed to run the app on a tv simulator with almost all original functions working, I had to strip the app functions in order to compile for TV. I can't deploy the app on any physical device through TestFlight because the following error message throws while uploading the archive trough XCode: No architectures in the binary. Lipo failed to detect any architectures in the bundle executable. With error code STATE_ERROR.VALIDATION_ERROR.90085. I'm guessing that the xcode_appletv.sh script should be updated, but I haven't managed to find a fix.

    My environment is flutter 2.10.3 with Dart 2.16.1, MacOs m1 12.5.1 and XCode 13.4.1.

    Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.10.3, on macOS 12.5.1 21G83 darwin-arm, locale en-RO) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] HTTP Host Availability

    Note I haven't tried to downgrade XCode yet. Does anyone has any idea what is happening here?

    opened by bypass112 1
Owner
LibertyGlobal
LibertyGlobal
A basic demo example for integrating between Appwrite & Flutter 💙

?? Quiz With Flutter A simple Quiz App built with Flutter and Appwrite ?? Getting Started ?? Install Appwrite Follow our simple Installation Guide to

Appwrite 35 Nov 22, 2022
Flutter app demo multiple call with WebRTC and SFUs Architecture

Video Call Flutter App (SFUs Architecture) ?? Description: This is sandbox video call application using Flutter and WebRTC. SFUs – Selective Forwardin

Dao Hong Vinh 15 Dec 5, 2022
Food App Demo for learning Flutter

foodapp_demo Food App Demo for learning Flutter Slicing UI SetState StateFull Widget LINK TUTORIAL https://www.youtube.com/watch?v=1Xd15C2k4OU&list=PL

Ronaldi 1 Mar 12, 2022
A demo built with Flutter and Appwrite backend for Hacktoberfest 2021.

Artistry: Appwrite - Flutter Demo ?? Artistry is a demo app built with flutter and Appwrite backend for Hacktoberfest 2021, that demonstrates how to p

Divyam joshi 23 Dec 16, 2022
A basic demo example for integrating between Appwrite & Flutter 💙

?? Todo With Flutter A simple todo app built with Flutter and Appwrite ?? Getting Started Appwrite is an end-to-end backend server for Web, Mobile, Na

Appwrite 27 Dec 15, 2022
Supabase flutter user management demo app.

Supabase Flutter User Management This example will set you up for a very common situation: users can sign up with a magic link and then update their a

Hieu Pham 24 Dec 3, 2022
App to showcase demo for how to have Clean Architecture in Flutter with Get_It for dependency injection

App to showcase demo for how to have Clean Architecture in Flutter with Get_It for dependency injection, BLoC for state maintainence and Hive for persisting data into database.

Rohan Kandwal 1 Mar 19, 2022
(Complete flutter application) Exam and training app as social media, prepared with Firebase backend services, Bloc State management, Singleton design pattern, Unit and widget tests, firebase mocking, Custom local libraries, etc.

(Complete flutter application) Exam and training app as social media, prepared with Firebase backend services, Bloc State management, Singleton design pattern, Unit and widget tests, firebase mocking, Custom local libraries, etc.

Ismael Shakverdiev 45 Jul 14, 2022
A minimalist Flutter framework for rapidly building custom designs.

Show some ❤️ and star the repo. VelocityX is a 100% free Flutter open-source minimalist UI Framework built with Flutter SDK to make Flutter developmen

Pawan Kumar 1.2k Jan 8, 2023
Attempt to implement better scrolling for Flutter Web and Desktop. Includes keyboard, MButton and custom mouse wheel scrolling.

An attempt to implement better scrolling for Flutter Web and Desktop. Includes keyboard, MButton and custom mouse wheel scrolling. Getting started Exa

Adrian Flutur 46 Jan 3, 2023