我已经从 Apple 下载了 TVMLCatalog 应用程序。代码分为两部分。
- 客户端- 这包含 TVML 和 TVJS 文件
- TVMLCatalog 项目- 这是设置 TVML/TVJS 的基本 Xcode 项目
我正在尝试将客户端TVJS 文件托管在与TVMLCatalog Project相同的捆绑包中。
我已将 AppDelegate didFinishLaunching 更改如下:
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
}
这是演示我如何导入客户端的屏幕截图: Xcode Screenshot
当我运行项目(仅在模拟器上测试)时,AppleTV 模拟器屏幕上显示以下消息:
启动应用程序时出错 - 操作无法完成。(TVMLKitErrorDomain 错误 3。)
我可以像这样从本地的 TVJS 文件加载吗?