Swifty TVML template manager with or without client-server

Related tags

Apple TV swift tvos tvml
Overview

TVMLKitchen ๐Ÿ˜‹ ๐Ÿด GitHub license Carthage compatible CocoaPods CocoaPods Build Status

TVMLKitchen helps to manage your TVML with or without additional client-server.

Requirements

  • Swift3.0
  • tvOS 9.0+

Use 0.9.6 for Swift2.2.
Swift2.3 is not supported. Feel free to send PR.

What's TVML?

Please refer to Apple's Documentation. It's a markup language which can be used only on tvOS. TVML makes it easy to build awesome apps for tvOS.

Why ?

TVML is easy, but TVJS is not really. With TVMLKitchen, loading a TVML view is in this short.

Kitchen.serve(xmlFile: "Catalog.xml")

You don't have to write any JavaScript code at all!

Kitchen automatically looks for the xmlFile in your Main Bundle, parse it, then finally pushes it to navigationController. Please refer to the Documentation for more information.

Available Features

  • Load TVML from URL.
  • Load TVML from raw XML String.
  • XML syntax validation API
  • Multi UIWindow Support
  • TVML Recipe Protocol

Examples

Installation

Carthage

Put this to your Cartfile,

github "toshi0383/TVMLKitchen"

Follow the instruction in carthage's Getting Started section.

Cocoapods

Add the following to your Podfile

pod 'TVMLKitchen'

References

For implementation details, my slide is available.
TVML + Native = Hybrid

Contribution

Any contribution is welcomed ๐ŸŽ‰

Comments
  • Can it play videos?

    Can it play videos?

    Hello,

    I use SampleRecipe in my Swift tvOS app. It can load TVML file from raw XML String, however it can't play videos?

    Anyone knows how to solve it? Thanks!

    btw, happy new year!

    opened by Wei-Xia 10
  • Nothing Displays

    Nothing Displays

    This must be something to do with my setup but when I call Kitchen serve nothing gets displayed.

    Here is what I get in the console:

    App[13589:5955308] ITML <Error>: Unable to create elements for document <alertTemplate itmlID="id_2"><title>test</title><description>DESCRIPTION</description></alertTemplate>
    App[13589:5955091] #T:[Main] #Notice #SYSTEM : Template element: (null) 
    2016-06-15 21:11:17.498 
    

    Here is the code from the AppDelegate.

     func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        let cookbook = Cookbook(launchOptions: launchOptions)
        Kitchen.prepare(cookbook)
        Kitchen.serve(xmlFile: "alert.xml", type: .Modal)
        return true
      }
    

    I'm using a slimmed down template with pretty much nothing in it. But even the built in recipes do the same thing.

    question 
    opened by russ 10
  • Add Modal Support

    Add Modal Support

    Hello!

    I've just started using TVMLKitchen on a new project and noticed that modal support hasn't fully been implemented. I wanted to open this PR as a conversation starter into how best to implement it. This PR add the following method:

    Kitchen.serveModal(recipe: recipe)

    I've yet to implement this to the other methods as I'm not sure this is the best approach. Alternatives could be:

    1. Kitchen.serve(recipe: recipe, present: .Modal)
    2. Force the recipe to define the presentation style. In the case of descriptive alert this makes a lot of sense.
    opened by steve228uk 10
  • UIViewController into a UITabBar

    UIViewController into a UITabBar

    Maybe I'm overlooking something but i've gone through the framework and can't seem to find anything that would allow me to add UIViewController to a UITabBar. Is this currently not possible?

    question 
    opened by anthonycastelli 9
  • Add tab bar support

    Add tab bar support

    Hello again!

    This pull request adds tab bar support to TVMLKitchen. It's not quite finished but I wanted to get your opinion before I tidy it up.

    I've created a shared instance of a new object called KitchenTabBar. This tab bar has an items property that accepts a number of TabItem instances. Each TabItem features a title and a handler with the handler being called every time the tab changes.

    Here's how you would setup a TVMLKitchen app to use a tab bar:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    
        Kitchen.prepare(launchOptions, evaluateAppJavaScriptInContext: nil, actionIDHandler: actionIDHandler, playActionIDHandler: playActionIDHandler)
    
        KitchenTabBar.sharedBar.items = [
            HomeTab(),
            SettingsTab()
        ]
    
        return true
    }
    

    And here is what your HomeTab struct would look like:

    struct HomeTab: TabItem {
    
        let title = "Home"
    
        func handler() {
            print("Called whenever the tab changes")
            Kitchen.serve(urlString: "https://raw.githubusercontent.com/toshi0383/TVMLKitchen/master/SampleRecipe/Catalog.xml.js", type: .Tab)
        }
    
    }
    

    The new .Tab presentation type is only to be used whenever a user wishes to keep a view within a tab. It uses a new JS presenter that has been adapted from some of Apple's sample code.

    function menuBarItemPresenter(xml) {
        var feature = currentTab.parentNode.getFeature("MenuBarDocument");
        if (feature) {
            var currentDoc = feature.getDocument(currentTab);
            if (!currentDoc) {
                feature.setDocument(xml, currentTab);
            }
        }
    }
    

    simulator screen shot 15 mar 2016 22 08 42

    opened by steve228uk 9
  • How to load local files embedded in Template?

    How to load local files embedded in Template?

    How may I add local files (from the main bundle) to a xml template?

    For example, I'd like to provide a static menu, the user can choose an item by using the stackTemplate. For each menu Item I want to show a logo, served locally and stored in the main bundle.

    For each entry I got a code similar to this:

    <lockup>
        <img src="wordpress.png" width="548" height="274" />
            <title>WordPress</title>
    </lockup>
    

    And the image wordpress.png is stored in the main bundle - but as you can see on the following screenshot it isn't displayed:

    simulator screen shot 14 05 2016 17 44 13

    question 
    opened by marbetschar 7
  • Tab Reloading

    Tab Reloading

    It's me again! Another feature request if it doesn't already exist haha.

    Is there currently a way to reload a view in a tab? What Im after is either being able to tell a tab to reload its data or when the tab is loaded each time fetch the data it needs. Does something like this exist that I can use? If not what would be the best route to implement something like this?

    opened by anthonycastelli 7
  • Add Alert Recipe

    Add Alert Recipe

    Hello!

    This pull request adds an alert recipe as well as the ability to dismiss modals. Buttons are entirely optional.

    let buttons = [
        AlertButton(title: "OK", actionID: "alertAction"),
        AlertButton(title: "Cancel"),
    ]
    let recipe = AlertRecipe(title: "Alert View", description: "A short description of what the alert does can go here.", buttons: buttons)
    Kitchen.serve(recipe: recipe)
    
    Kitchen.dismissModal()
    

    simulator screen shot 15 mar 2016 09 38 59

    opened by steve228uk 7
  • How does Kitchen's default presentationType behave ?

    How does Kitchen's default presentationType behave ?

    There are two push methods to present a TVML view, replaceDocument and pushDocument. https://developer.apple.com/library/tvos/documentation/TVMLJS/Reference/TVJSNavigationDocument_Ref/index.html

    The defaultPresenter in kitchen.js pushes document. If loadingIndicator exists, it replaces document.

    question 
    opened by toshi0383 6
  • v1.0.0 cocoapod is not being recognized as Swift 3.0

    v1.0.0 cocoapod is not being recognized as Swift 3.0

    I've updated my pod to v1.0.0 to get the Swift 3.0 version. The framework will not compile with my Swift 3.0 project, as Xcode still recognizes TVMLKitchen v1.0.0 as Swift 2.2.

    As a note, I've taken the source from the Swift 3.0 branch and included it directly in my project, and everything works fine. This seems to be an issue with the cocoapod itself.

    opened by AlexanderTheOkay 5
  • Modal presented TVML should be dismissed when it opens other TVML using template attribute

    Modal presented TVML should be dismissed when it opens other TVML using template attribute

    TVML should be dismissed when presented modally, and opening other TVML.

    Current Behavior

    I can present a TVML modally like this. (Thanks a lot @steve228uk !)

    Kitchen.serve(jsFile: "Sample.xml.js", type: .Modal)

    Sample.xml.js has a button like this.

    <button class="button" template="https://raw.githubusercontent.com/toshi0383/TVMLKitchen/master/SampleRecipe/Catalog.xml.js">
    

    If this is clicked, kitchen.js presents the Catalog.xml.js behind the Sample.xml.js .

    bug 
    opened by toshi0383 5
  • Swift 4

    Swift 4

    Hey there. I would really like to use TVMLKitchen in conjunction with my swift code but there is no support for swift 4. If possible, can you update your code for swift 4. I'd be more than happy to pilot your code.

    opened by g30r93g 1
  • dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib

    dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib

    Environment

    macOS Sierra 10.12.4 (16E195) Xcode 8.3 (8E162) (Confirmed repro on Xcode8.2.1 too) Carthage 0.20.1

    Reproduce Step

    • carthage update --platform tvOS
    • Add carthage copy-frameworks build phase
    • Open App.xcodeproj and Cmd + R, this runs with no problems.
    • Close xcodeproj and Create a new xcworkspace including the App and TVMLKitchen xcodeprojs.
    • Open the xcworkspace and Cmd + R, the error occurs.
    tvmlkitchen-142

    Log

    dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib
      Referenced from: /Users/toshi0383/Library/Developer/Xcode/DerivedData/HelloKitchen-ejgwzgjuarttagdecndevauvhuqx/Build/Products/Debug-appletvsimulator/Himotoki.framework/TVMLKitchen
      Reason: image not found
    

    Solution

    Add ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES to buildSettings which is currently NO.

    bug 
    opened by toshi0383 0
  • Showing Description Issue

    Showing Description Issue

    Hello @toshi0383, I'm not sure if you have noticed.

    In MoviePlaybackSample or other sample, the app can't open the long description in a separate screen. As the picture below shows,

    1

    Ideally, it should show like this way.

    2

    I realized there is a still open issue#27 talking about this problem, which is #27 .

    I think there is a missing actionIDHandler to deal with opening a long description. I will try to solve this issue following steve228uk and your thoughts in #27.

    If you have any further ideas about this issue, could you please leave here? I gonna follow up, and submit an PR after completing. Thank you! ๐Ÿ˜€

    opened by Wei-Xia 1
  • Any movie playback feature ?

    Any movie playback feature ?

    Personally I've never done any movie playbacks in TVML. I have questions like below.

    • Is FairPlay Streaming Supported ?
    • Is FairPlay Streaming available in inline playback (tvOS10+) ?
    • Is any other DRM (Widevine, PlayReady...) supports possible ?
    • How could I interact with video UI using TVInterfaceCreating (tvOS10+) ?

    Will investigate on these later...

    help wanted question 
    opened by toshi0383 0
Owner
Toshihiro Suzuki
iOS/Android dev
Toshihiro Suzuki
Ethereum Wallet Toolkit for iOS - You can implement an Ethereum wallet without a server and blockchain knowledge.

Introduction EtherWalletKit is an Ethereum Wallet Toolkit for iOS. I hope cryptocurrency and decentralized token economy become more widely adapted. H

Sung Woo Chang 136 Dec 25, 2022
Ethereum Wallet Toolkit for iOS - You can implement an Ethereum wallet without a server and blockchain knowledge.

Introduction EtherWalletKit is an Ethereum Wallet Toolkit for iOS. I hope cryptocurrency and decentralized token economy become more widely adapted. H

Sung Woo Chang 136 Dec 25, 2022
This projects shows how we can server-side add/update "ANY" custom font in a live iOS App without needing to update the app.

Server-side-Dynamic-Fonts This projects shows how we can server-side add/update "ANY" custom font in a live iOS App without needing to update the app.

null 2 Mar 26, 2022
Server-driven SwiftUI - Maintain iOS apps without making app releases.

ServerDrivenSwiftUI Maintain ios apps without making app releases. Deploy changes to the server and users will receive changes within minutes. This pa

null 9 Dec 29, 2022
Task-Manager - Task Manager App With Swift

Task-Manager It's typical task manager where user can assign the importance, def

Andrey Buchevskiy 1 Jan 10, 2022
The template for Delta Client plugins.

Delta Plugin Template This repository is a template for Delta Client plugins. To create a plugin, create a repo from this template repo and then repla

null 1 Jan 12, 2022
iOS Project Manager Client

08-iOS-Project-Manager-Client ํ”„๋กœ์ ํŠธ ๋งค๋‹ˆ์ € STEP 1 ํ”„๋กœ์ ํŠธ ํ• ์ผ ๋ฆฌ์ŠคํŠธ ๊ธฐ๋Šฅ๊ตฌํ˜„ UI๊ตฌํ˜„๋ฐฉ์‹ : ์ฝ”๋“œ ์•„ํ‚คํ…์ณ : ProjectManagerViewController : NavigationViewController์œ„์— StackView(

Kioding87 1 Nov 19, 2021
Swifty and modern UserDefaults

Defaults Swifty and modern UserDefaults Store key-value pairs persistently across launches of your app. It uses NSUserDefaults underneath but exposes

Sindre Sorhus 1.3k Jan 6, 2023
The most swifty way to deal with XML data in swift 5.

SwiftyXML SwiftyXML use most swifty way to deal with XML data. Features Infinity subscript dynamicMemberLookup Support (use $ started string to subscr

Kevin 99 Sep 6, 2022
A sweet and swifty YAML parser built on LibYAML.

Yams A sweet and swifty YAML parser built on LibYAML. Installation Building Yams requires Xcode 11.x or a Swift 5.1+ toolchain with the Swift Package

JP Simard 930 Jan 4, 2023
Swifty Date & Time API inspired from Java 8 DateTime API.

AnyDate Swifty Date & Time API inspired from Java 8 DateTime API. Background I think that date & time API should be easy and accurate. Previous dates,

Jungwon An 182 Dec 1, 2022
A Swifty API for attributed strings

SwiftyAttributes A Swifty API for attributed strings. With SwiftyAttributes, you can create attributed strings like so: let fancyString = "Hello World

Eddie Kaiger 1.5k Jan 5, 2023
Fashion is your helper to share and reuse UI styles in a Swifty way.

Fashion is your helper to share and reuse UI styles in a Swifty way. The main goal is not to style your native apps in CSS, but use a set

Vadym Markov 124 Nov 20, 2022
Swifty, modern UIAlertController wrapper.

Alertift Alertift.alert(title: "Alertift", message: "Alertift is swifty, modern, and awesome UIAlertController wrapper.") .action(.default("โค๏ธ"))

Suguru Kishimoto 287 Jan 7, 2023
๐Ÿž Loaf is a Swifty Framework for Easy iOS Toasts

Loaf ?? Inspired by Android's Toast, Loaf is a Swifty Framework for Easy iOS Toasts Usage From any view controller, a Loaf can be presented by calling

Mat Schmid 995 Dec 28, 2022
Swifty closures for UIKit and Foundation

Closures is an iOS Framework that adds closure handlers to many of the popular UIKit and Foundation classes. Although this framework is a substitute f

Vinnie Hesener 1.7k Dec 21, 2022
A swifty iOS framework that allows developers to create beautiful onboarding experiences.

SwiftyOnboard is being sponsored by the following tool; please help to support us by taking a look and signing up to a free trial SwiftyOnboard A simp

Juan Pablo Fernandez 1.2k Jan 2, 2023
Swifty regular expressions

Regex Swifty regular expressions This is a wrapper for NSRegularExpression that makes it more convenient and type-safe to use regular expressions in S

Sindre Sorhus 311 Nov 22, 2022
Swifty API for NSTimer

SwiftyTimer Modern Swifty API for NSTimer SwiftyTimer allows you to instantly schedule delays and repeating timers using convenient closure syntax. It

Radek Pietruszewski 1.2k Dec 29, 2022
Swifty and modern UserDefaults

Defaults Swifty and modern UserDefaults Store key-value pairs persistently across launches of your app. It uses NSUserDefaults underneath but exposes

Sindre Sorhus 1.3k Dec 31, 2022