Client-server TVML App Sample Code crashes

Hi there,

I just downloaded the Sample Code provided by de developer documentation in order to run a simple Client-Server app with TVML Kit for tvOS. https://developer.apple.com/documentation/tvmljs/creating_a_client-server_tvml_app

I'm following the docs step by step and after running the server in the terminal. I would go and open the project in Xcode and hit the build button. It would lauch the simulator but I get the following error in the simulator:

This operation couldn't be completed (TVMLKitErrorDomain error 3.)

And in my console I would get this:

Code Block
CreateTVMLApp[82816:2094742] [Image] _TVAssetGroup failed to purge cache path: Shared Asset Group, Error Domain=NSCocoaErrorDomain Code=4 "“SharedImageCache” couldn’t be removed." UserInfo={NSUserStringVariant=(
  Remove
), NSFilePath=/Users/aeum3893/Library/Developer/CoreSimulator/Devices/A976E6FD-6B0D-4C24-BB4C-DDA1F31B0F01/data/Containers/Data/Application/9AC60995-C9EB-4051-803B-334E1A06F9DC/Library/Caches/com.example.apple-samplecode.creating-a-basic-tvml-app/SharedImageCache, NSUnderlyingError=0x6000004168e0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2021-02-01 09:01:42.238202-0500 CreateTVMLApp[82816:2094742] [Image] _TVAssetGroup failed to purge cache path: LSM Asset Group, Error Domain=NSCocoaErrorDomain Code=4 "“LSMImageCache” couldn’t be removed." UserInfo={NSUserStringVariant=(
  Remove
), NSFilePath=/Users/aeum3893/Library/Developer/CoreSimulator/Devices/A976E6FD-6B0D-4C24-BB4C-DDA1F31B0F01/data/Containers/Data/Application/9AC60995-C9EB-4051-803B-334E1A06F9DC/Library/Caches/com.example.apple-samplecode.creating-a-basic-tvml-app/LSMImageCache, NSUnderlyingError=0x60000042c870 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2021-02-01 09:01:42.238767-0500 CreateTVMLApp[82816:2094742] [Image] _TVAssetGroup failed to purge cache path: Trick Play Asset Group, Error Domain=NSCocoaErrorDomain Code=4 "“TrickPlay” couldn’t be removed." UserInfo={NSUserStringVariant=(
  Remove
), NSFilePath=/Users/aeum3893/Library/Developer/CoreSimulator/Devices/A976E6FD-6B0D-4C24-BB4C-DDA1F31B0F01/data/Containers/Data/Application/9AC60995-C9EB-4051-803B-334E1A06F9DC/Library/Caches/com.example.apple-samplecode.creating-a-basic-tvml-app/TrickPlay, NSUnderlyingError=0x600000447450 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2021-02-01 09:01:42.239321-0500 CreateTVMLApp[82816:2094742] [Image] _TVAssetGroup failed to purge cache path: Photo Stream Asset Group, Error Domain=NSCocoaErrorDomain Code=4 "“PhotostreamImages” couldn’t be removed." UserInfo={NSUserStringVariant=(
  Remove
), NSFilePath=/Users/aeum3893/Library/Developer/CoreSimulator/Devices/A976E6FD-6B0D-4C24-BB4C-DDA1F31B0F01/data/Containers/Data/Application/9AC60995-C9EB-4051-803B-334E1A06F9DC/Library/Caches/com.example.apple-samplecode.creating-a-basic-tvml-app/PhotostreamImages, NSUnderlyingError=0x60000042ca20 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2021-02-01 09:01:42.264212-0500 CreateTVMLApp[82816:2094742] [Image] _TVAssetGroup failed to purge cache path: AR Asset Group, Error Domain=NSCocoaErrorDomain Code=4 "“ARFileCache” couldn’t be removed." UserInfo={NSUserStringVariant=(
  Remove
), NSFilePath=/Users/aeum3893/Library/Developer/CoreSimulator/Devices/A976E6FD-6B0D-4C24-BB4C-DDA1F31B0F01/data/Containers/Data/Application/9AC60995-C9EB-4051-803B-334E1A06F9DC/Library/Caches/com.example.apple-samplecode.creating-a-basic-tvml-app/ARFileCache, NSUnderlyingError=0x60000042cc00 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2021-02-01 09:01:42.383110-0500 CreateTVMLApp[82816:2094742] screen parameters are unexpected: MGScreenClass1920x1080x1x40 SCREEN_TYPE(1920,1080,1, 40)
2021-02-01 09:01:42.415012-0500 CreateTVMLApp[82816:2095237] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
2021-02-01 09:01:42.498897-0500 CreateTVMLApp[82816:2095248] [System] <IKAppContext (0): 0x60000337f100> Unable to start script (http://localhost:9001//application.js) because of SyntaxError: Unexpected token '<': {
  line = 1;
  sourceURL = "http://localhost:9001//application.js";
}
2021-02-01 09:01:42.499296-0500 CreateTVMLApp[82816:2094742] [System] App Context Failed with Error: Error Domain=ITMLKitErrorDomain Code=101 "(null)" UserInfo={line=1, sourceURL=http://localhost:9001//application.js}
appController(_:didFail:) invoked with error: Error Domain=TVMLKitErrorDomain Code=3 "(null)"


Apparently, it cannot find the application.js file, but not sure why and how to go about this
In your info.plist file do you have an App Transport Security Settings entry with an Allow Arbitrary Loads key set to YES within it?

I had encountered an error like this and had to update my info.plist file to get the app to run successfully.

Had this exact problem and it took a minute to figure it out.

Make sure you're running ruby -run -ehttpd . -p9001 from the correct location. You should be in {path_to_folder}/CreatingAClientServerTVMLApp/CreateTVMLApp/CreateTVMLApp. Note that there’s a second CreateTVMLApp in the path. Starting the server from the wrong location results in the useless “unexpected token” error when you run the app.

Also—this won’t break it but it’s probably not good to have—remove the trailing slash in the base URL in line 20 of AppDelegate. Otherwise it's looking for http://localhost:9001//application.js —two slashes between host:port and application.js.

(This is old, but answering anyway in case someone else lands here on a Google search.)

Client-server TVML App Sample Code crashes
 
 
Q