I've downloaded the TVMLCatalog application from Apple. The code is split up into 2 parts.
- client - this holds the TVML and TVJS files
- TVMLCatalog Project - this is the basic Xcode project that sets up the TVML/TVJS
I'm attempting to host the client TVJS files in the same bundle as the TVMLCatalog Project.
I've changed the AppDelegate didFinishLaunching as follows:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
/*
Create the TVApplicationControllerContext for this application
and set the properties that will be passed to the `App.onLaunch` function
in JavaScript.
*/
let appControllerContext = TVApplicationControllerContext()
/*
The JavaScript URL is used to create the JavaScript context for your
TVMLKit application. Although it is possible to separate your JavaScript
into separate files, to help reduce the launch time of your application
we recommend creating minified and compressed version of this resource.
This will allow for the resource to be retrieved and UI presented to
the user quickly.
*/
TVBootURL = NSBundle.mainBundle().pathForResource("application", ofType: "js")!
TVBaseURL = TVBootURL.stringByReplacingOccurrencesOfString("application.js", withString: "")
if let javaScriptURL = NSURL(string: TVBootURL) {
appControllerContext.javaScriptApplicationURL = javaScriptURL
}
appControllerContext.launchOptions["BASEURL"] = TVBaseURL
if let launchOptions = launchOptions as? [String: AnyObject] {
for (kind, value) in launchOptions {
appControllerContext.launchOptions[kind] = value
}
}
appController = TVApplicationController(context: appControllerContext, window: window, delegate: self)
return true
}
Here is a screenshot that demonstrates how I've imported the client: Xcode Screenshot
When I run the project (only tested on simulator) I get the following message displayed on the AppleTV simulator screen:
Error launching Application - The operation couldn't be completed. (TVMLKitErrorDomain error 3.)
Can I load from TVJS files locally like this?