I am encountering an issue when making an API call using URLSession with DispatchQueue.global(qos: .background).async on a real device running tvOS 18. The code works as expected on tvOS 17 and in the simulator for tvOS 18, but when I remove the debug mode, After the API call it takes few mintues or 5 to 10 min to load the data on the real device.
Code: Here’s the code I am using for the API call:
appconfig.getFeedURLData(feedUrl: feedUrl, timeOut: kRequestTimeOut, apiMethod: ApiMethod.POST.rawValue) { (result) in
self.EpisodeItems = Utilities.sharedInstance.getEpisodeArray(data: result)
}
func getFeedURLData(feedUrl: String, timeOut: Int, apiMethod: String, completion: @escaping (_ result: Data?) -> ()) {
guard let validUrl = URL(string: feedUrl) else { return }
var request = URLRequest(url: validUrl, cachePolicy: .useProtocolCachePolicy, timeoutInterval: TimeInterval(timeOut))
let userPasswordString = "\(KappSecret):\(KappPassword)"
let userPasswordData = userPasswordString.data(using: .utf8)
let base64EncodedCredential = userPasswordData!.base64EncodedString(options: .lineLength64Characters)
let authString = "Basic \(base64EncodedCredential)"
let headers = [
"authorization": authString,
"cache-control": "no-cache",
"user-agent": "TN-CTV-\(kPlateForm)-\(kAppVersion)"
]
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = apiMethod
request.allHTTPHeaderFields = headers
let response = URLSession.requestSynchronousData(request as URLRequest)
if response.1 != nil {
do {
guard let parsedData = try JSONSerialization.jsonObject(with: response.1!, options: .mutableContainers) as? AnyObject else {
print("Error parsing data")
completion(nil)
return
}
print(parsedData)
completion(response.1)
return
} catch let error {
print("Error: \(error.localizedDescription)")
completion(response.1)
return
}
}
completion(response.1)
}
import Foundation
public extension URLSession {
public static func requestSynchronousData(_ request: URLRequest) -> (URLResponse?, Data?) {
var data: Data? = nil
var responseData: URLResponse? = nil
let semaphore = DispatchSemaphore(value: 0)
let task = URLSession.shared.dataTask(with: request) { taskData, response, error in
data = taskData
responseData = response
if data == nil, let error = error {
print(error)
}
semaphore.signal()
}
task.resume()
_ = semaphore.wait(timeout: .distantFuture)
return (responseData, data)
}
public static func requestSynchronousDataWithURLString(_ requestString: String) -> (URLResponse?, Data?) {
guard let url = URL(string: requestString.checkValidUrl()) else { return (nil, nil) }
let request = URLRequest(url: url)
return URLSession.requestSynchronousData(request)
}
}
Issue Description: Working scenario: The API call works fine on tvOS 17 and in the simulator for tvOS 18. Problem: When running on a real device with tvOS 18, the API call takes time[enter image description here] when debug mode is disabled, but works fine when debug mode is enabled, Data is loading after few minutes.
Error message: Error Domain=WKErrorDomain Code=11 "Timed out while loading attributed string content" UserInfo={NSLocalizedDescription=Timed out while loading attributed string content} NSURLConnection finished with error - code -1001 nw_read_request_report [C4] Receive failed with error "Socket is not connected" Snapshot request 0x30089b3c0 complete with error: <NSError: 0x3009373f0; domain: BSActionErrorDomain; code: 1 ("response-not-possible")> tcp_input [C7.1.1.1:3] flags=[R] seq=817957096, ack=0, win=0 state=CLOSE_WAIT rcv_nxt=817957096, snd_una=275546887
Environment: Xcode version: 16.1 Real device: Model A1625 (32GB) tvOS version: 18.1
Debugging steps I’ve taken: I’ve verified that the issue does not occur in debug mode. I’ve confirmed that the API call works fine on tvOS 17 and in the simulator (tvOS 18). The error suggests a network timeout (-1001) and a socket connection issue ("Socket is not connected").
Questions:
Is this a known issue with tvOS 18 on real devices? Are there any specific settings or configurations in tvOS 18 that could be causing the timeout error in non-debug mode? Could this be related to how URLSession or networking behaves differently in release mode? I would appreciate any help or insights into this issue!
Posts under Apple TV tag
20 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
When the native info panel (which displays the title, subtitle, description, and custom buttons) opens, the focus immediately shifts to the first button. As a result, VoiceOver skips the description, which is crucial for users relying on accessibility features.
I haven’t found a way to detect when it opens. Knowing this would allow me to trigger custom VoiceOver announcements or adjust the focus order dynamically.
Are any other people experiencing this issue, and how do we solve it?
When adding more than 7 items, the Tab bar wiggles or may not reappear when switching back to it. Is this a bug? or could this be a problem with focus management? or any other cause?
Tried sample code https://developer.apple.com/documentation/swiftui/enhancing-your-app-content-with-tab-navigation
On testing my app with tvOS 18, I have noticed the Siri Remote back button no longer provides system-provided behavior when interacting with tab bar controller pages. Instead of moving focus back to the tab bar when pressed, the back button will close the app, as if the Home button was pressed. This occurs both on device and in the Simulator.
Create tvOS project with a tab bar controller.
Create pages/tabs which contain focusable items (ie. buttons)
Scroll down to any focusable item (ie. a button or UICollectionView cell)
Hit the Siri Remote back button. See expect behavior below:
Expected behavior: System-provided behavior should move focus back to the tab bar at the top of the screen.
Actual results: App is closed and user is taken back to the Home Screen.
Has anyone else noticed this behavior?
Model: Apple TV 4K (3rd generation) Wi-Fi & Ethernet 128GB
I am an Apple Systems Admin for a school district. A contractor working on new buildings/upgrades for us purchased Apple TVs outside of our Apple account.
When attempting to add these Apple TVs to Apple School Manager and enroll them into our MDM (via Apple Configurator 2 version 2.17), i'm running into a few problems.
When inputting the Pair Code:
-Says “Pairing Failed (-402653161)”--this error code only takes me to Apple Forums that end up answerless
-But device still shows up under Paired Devices and in Configurator
On Step 3 of 4 when “Preparing Apple TV—Activating TVOS”
-An unexpected error has occurred with “Apple TV”.
The device is not connected. [ConfigurationUtilityKit.error – 0x25B (603)]--this error code also only points me to Apple Forums for Configurator problems regarding iPads
-only option is “Stop”
-Appears that Configurator is still working in the background
Click Stop (as it is my only option), then Apple TV then disappears from Configurator.
Devices appear to be wiping OS/reinstalling OS and then going back to factory default settings. They are not being added to our ASM account.
Any ideas?
I'm creating a Netflix like app on tvOS, here is my compositional layout that I use with my collectionView.
private func createLayout() -> UICollectionViewCompositionalLayout {
return UICollectionViewCompositionalLayout { (section, _) -> NSCollectionLayoutSection? in
// item
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1),
heightDimension: .fractionalHeight(1.0))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10)
// group
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/5),
heightDimension: .estimated(350))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
// section
let section = NSCollectionLayoutSection(group: group)
section.orthogonalScrollingBehavior = .groupPaging
let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .estimated(UIFont(name: "MyFont", size: 36)!.lineHeight))
let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem(
layoutSize: headerSize,
elementKind: "SectionHeader",
alignment: .top)
section.boundarySupplementaryItems = [sectionHeader]
section.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 20, bottom: 30, trailing: 0)
return section
}
}
So:
My collection view is composed by several row (that are the sections).
Each section is composed by groups containing 1 item each.
Each section can be scrolled horizontally.
And you can scroll vertically to move from a section to an other.
I'm expecting to have the following behavior when scrolling: Horizontal scrolling:
Before focus shifts
--------------------------
| vA vB vC vD vE |
| [v1] v2 v3 v4 v5 |
| vU vW vX vY vZ |
--------------------------
After focus shifts
--------------------------
| vA vB vC vD vE |
| [v2] v3 v4 v5 v6 |
| vU vW vX vY vZ |
--------------------------
Vertical scroll:
Before focus shifts
--------------------------
| [vA] vB vC vD vE |
| v1 v2 v3 v4 v5 |
| vU vW vX vY vZ |
--------------------------
After focus shifts
--------------------------
| [v1] v2 v3 v4 v5 |
| vU vW vX vY vZ |
| vF vG vH vI vJ |
--------------------------
Thanks to section.orthogonalScrollingBehavior = .groupPaging the horizontal scrolling is working as expected. (I've put 1 item per group to achieve this)
But I'm going crazy with the vertical scroll, I'm not able to achieve it as expected, the focused section still centered verticaly on the screen ! What I'm getting:
Before focus shifts
--------------------------
| [vA] vB vC vD vE |
| v1 v2 v3 v4 v5 |
| vU vW vX vY vZ |
--------------------------
After focus shifts
--------------------------
| vA vB vC vD vE |
| [v1] v2 v3 v4 v5 |
| vU vW vX vY vZ |
--------------------------
After an other focus shifts
--------------------------
| v1 v2 v3 v4 v5 |
| [vU] vW vX vY vZ |
| vF vG vH vI vJ |
--------------------------
I've tried to play with the didUpdateFocusIn function without success
func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context: UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
if let nextFocusedItemIndexPath = context.nextFocusedIndexPath {
let section = nextFocusedItemIndexPath.section
let sectionIndexPath = IndexPath(item: 0, section: section)
collectionView.scrollToItem(at: sectionIndexPath, at: .top, animated: true)
}
}
The collectionview is behaving strangely when using the didUpdateFocusIn function and I feel it's not the good way to perform what I'm expecting...
I've also try to play with the scrollViewWillEndDragging function without success
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset:
}
Everything that I tried looks like a hack and I can't believe Apple has not plan something for this use case, which is in my sense a common use case....
Hi,
I'm having a small App in the AppleTV-Simulator which is supposed to use the Siri-Remotes Swipe-Gesture.
It works perfect on the real device but on the simulator the Swipe-Gesture is not recognized in the App but it works on the Start-Screen of the Simulator using the simulated Siri-Remote app.
Here is the code which sets up the xAxis ans yAxis value change handlers:
#if targetEnvironment(simulator)
// Simulator
let siriRemote = GCController.controllers().filter { controller in
if controller.vendorName == "Gamepad" {
return true
} else {
return false
}
}
let sController = siriRemote.first!
let inputProfile = sController.physicalInputProfile
let dPad = inputProfile.dpads["Direction Pad"]
self.dPad = dPad
self.dPad!.xAxis.valueChangedHandler = self.directionPadXAxisValueChangeHandler
self.dPad!.yAxis.valueChangedHandler = self.directionPadYAxisValueChangeHandler
}
#else
// Device
if let _ = ( notification.object as? GCController)?.microGamepad {
let microProfileController = notification.object as! GCController
self.microGamePad = microProfileController.microGamepad
self.dPad = self.microGamePad!.dpad
self.dPad!.xAxis.valueChangedHandler = self.directionPadXAxisValueChangeHandler
self.dPad!.yAxis.valueChangedHandler = self.directionPadYAxisValueChangeHandler
}
#endif
Any help is greatly appreciated.
Cheers,
Frank
Hi Team,
I'm using AVPlayer on Apple TV 2nd generation which has that siri click pad with four buttons around and we need to detect where the user clicked on the Siri remote fast forward/backward. I have tested many different approaches to do it, but nothing is working for me.
Does anyone have any idea how to resolve it in Swift?
I'm developing an Apple TV OS app using SwiftUI. I'm encountering an issue with the color of the tab item. I want the color of the tab item to turn green when focused; for instance, when the tab item is selected, its background color should be green. Below is my current code, but it's not working. I've tried several other approaches, but none have worked.
struct ContentView: View {
@State private var selectedTab = 0
var body: some View {
ZStack(alignment: .topLeading){
TabView(selection: $selectedTab) {
HomeView()
.tabItem {
AppColors.gradientColor1
Label("Home", image: "home-dash")
}
.tag(0)
ProductsView()
.tabItem {
Label("Products", image: "open box-search")
}
.tag(1)
SearchView()
.tabItem {
Label("Search", image: "search")
}
.tag(2)
}
.accentColor(Color.green)
.background(.black)
Image("amazontabbarlogo")
}
}
}
I have internet inside but 5G outside. The Apple TV device responds to INTERNET only, not 56. So why not have an autodetect?
I would like a feature on the remote app which visualizes the TV screen in the remote app on the phone.
Scenario is to navigate the Apple TV while I’m not in front of the TV screen (e.g. start a show on Apple tv) Today I need to stand in front of the TV to see where I’m navigating to.
Invalid Image Asset. The image stack 'App Icon' in 'Payload/VBIC.app/Assets.car' has a background layer image that does not match the canvas dimensions '800x480'. (ID: 9984fc86-f4b8-4968-9640-c368bd988a9b)
PLATFORM AND VERSION
tvOS
Xcode Version 15.3 (15E204a)
We verified several times and recreated all images.
Error persists and is repeatable.
We have built the game on Unreal engine 4 and we have optimised the game to run on tvOS devices newer than 2017 (viz. Apple TV 4k and above). We could not bring it down to support Apple TV HD (2015) due to its visual and memory requirements. Is there a way to exclude Apple TV HD from support list. We couldnt find any required device capability to add to info.plist (eg: iphone-ipad-minimum-performance-a12, we tried it but this does not work for tvOS build).
Hi, Some of my customer Apple TV device always show connected,disconneted notification message. but the VPN status show connected witch find with network preference. Is there a way to manually disable notification message?
Hello, my company ordered Apple TV 4K HDMI + WIFI only.. The device has no ethernet or USB-C port. Only has HDMI and power port. I read on Apple's website to connect to Apple configurator I have to do it via WIFI.
I followed the steps from the Apple website (https://support.apple.com/en-ca/guide/apple-configurator-2/cada1ba9dab1/mac) but once I'm paired to the Apple TV and I try to "Prepare" in Apple configurator to get the device setup on MDM it tells me the AppleTV device is already prepared and asks to "Erase" which I do then the Apple TV is back to the beginning setup screen and no longer connected to WIFI... Once I run through the setup again and get back on WIFI and goto pair screen it says the same thing when I try to prepare again.. Just going in circles and not getting anywhere.. Anyone have a solution?
Prepare Apple TV HD or Apple TV 4K using Wi-Fi or Ethernet
Make sure your Apple TV is connected to the same network your Mac is connected to.
Make sure the Apple TV is at the first screen of the Setup Assistant that says Pair Your Remote.
Launch Apple Configurator 2 .
From the Apple Configurator 2 menu, choose Paired Devices.
Select your Apple TV in the Paired Devices list, then click Pair.
Enter the six-digit personal identification number (PIN) that appears on the screen of your Apple TV.
Select your Apple TV in the device window of the Apple Configurator 2.
Click Prepare and follow the onscreen instructions to set up your Apple TV.
Topic : Attaching debugger via lldb to remote process on tv device
Current status
I launch an app on a remote tv device that is paired to a macbook using the command
xcrun devicectl device process launch --start-stopped -d XXXX-XXXXXX, com.metasample.SampleApp -j launch.json
App is launched in stopped state and waiting for debugger to be attached to continue execution
Using the XCode->Debug->Attach to Process, I am able to select the process and connect to the process and execute the app through the debugger.
Expectation
I would want to replace step 3 and use a command line instead to attach the debugger to the remote process instead of doing it via XCode.(the reason is to automate the execution without any manual intervention)
I know the process id of the app on the remote tv device when i inspect the launch.json file that is created when the launch the app. eg pid 312
I also know the ip address of the device eg ip 192.168.178.29
However I do not know how to establish the debug session using lldb from command line.
I launch lldb in the command line and execute these commands
platform select remote-tvos
target create /Users/works/apps/SampleApp-Payload/SampleApp.app/SampleApp
gdb-remote 192.168.178.29: "what is the port?" - I do not know what port to connect to?
Many Thanks for your suggestions and inputs on how to connect to the remote app via command line lldb.
I’m developing this tvOS app, and it builds and runs fine locally in Simulator.
However, when I do Product > Archive (so I can upload it to app store later), it fails with error in the screenshot.
Looks like Xcode is trying to sign the app with a certificate, but could not find a valid profile to do so.
Since I don't have a physical Apple TV device, I'm unable to add an Apple TV to the Devices list on developer.apple.com, thus unable to create a profile.
Is the any way around this issue to archive my tvOS app?
<array>
<string>dns-settings</string>
<string>packet-tunnel-provider</string>
</array>
<key>com.apple.security.application-groups</key>
<array/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)</string>
</array>
⚠️ Could not save VPN Configuration: Missing protocol or protocol has invalid type
vpn connection error started with error : Missing protocol or protocol has invalid type
Apple TV A2843 Dolby Vision Pink Distorted Picture at 23.9Hz and 29.9Hz Pioneer SC-LX904 Sony XR-90J
Hello friends, my Apple TV A2843 is connected to a Pioneer SC-LX904 AVR that passes the signal to a Sony XR-90J TV. The TV is set to Enhanced Dolby Vision and the AVR HDMI is set to Enhanced too.
The Format on my Apple TV is 4K Dolby Vision at 60HZ.
Auto Frame and Dynamic Range match are on.
The Color is set to RGB 24 bit automatically when the DV 60HZ format is selected and I cannot switch the Color from RGB back to YUV 4.4.4, 4.2.2 or 4.2.0.
4K Dolby Vision works perfectly at 60HZ and 50HZ.
4K Dolby Vision is not working (pink distorted Picture) at 23.9HZ and 29.9HZ
When I swap the Apple TV A2843 with a Apple TV A1842 everything works perfectly.
When I connect the Apple TV A2843 directly to the tv's HDMI 2.1 everything works perfectly.
Months ago on March 2023 the problem was fixed with the 16.4 Beta (16.4 20L5474e) and it came back with the 16.4 RC and 16.4 Public. I haven't seen a fix since then. I have an older Apple TV A1842 that works fine all the time.
Thank You
Hello. I have a need to be able to open a Keynote presentation, where the presentation is continuously edited by several users, but where it is desirable to have this keynote opened on an associated appleTV at a given time every day. Are there any tips here.