I'd like to customise text fields in my application, but I don't see any options for it. When I click text field, new window opens. And there is no title or description.
But there must be something that allows me to customize it, right? Apple applications contain customised text fields.
This is apple's text field (after clicking on it)
This is my text field (after clicking on it)
Here is my code:
Form {
//...
TextField("", text: $address)
//...
}
And there is one more problem. After filling this TextField I click enter and it immediately opens the next TextField. I don't want this behaviour.
Posts under tvOS tag
96 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Context menu on tvOS LazyVGrid selecting wrong item.
It works fine if selecting items on last row.
Testing on code from https://developer.apple.com/videos/play/wwdc2024/10207/
I just added contextMenu
LazyVGrid(columns: columns, spacing: 40) {
ForEach(sortedMatchingAssets) { asset in
Button {} label: {
asset.landscapeImage
.resizable()
.aspectRatio(16 / 9, contentMode: .fit)
.contextMenu {
Button("Test") {}
}
Text(asset.title)
}
.buttonStyle(.borderless)
}
}
Attached video with the bug - https://www.icloud.com/iclouddrive/020zq2PxZ_E_1Pr0vE86-8aww#Screen_Recording_2024-06-13_at_9.26.15%E2%80%AFPM
Target
tvOS 17.4
macOS Version
14.5
Xcode Version
15.4 (15F31d)
I am working on integrating SwiftData (not migrating from CoreData) into an app in active development for tvOS, and I cannot get the project to compile whenever the @Model macro is introduced.
I've traced every error back to the code generated by the @Model, and commenting it out removes the errors. I am able to use @Model on a fresh project, but any attempt to import SwiftData results in the build failing with the following errors:
/var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModel0D0fMe_.swift:1:1 Type 'DeviceModel' does not conform to protocol 'Observable'
/var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModelC2id18_PersistedPropertyfMa_.swift:4:9 Member 'setValue' cannot be used on value of type 'any BackingData<DeviceModel>'; consider using a generic constraint instead
/var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModel0D0fMe_.swift:4:36 'Observable' is not a member type of struct 'AeolusKit.Observation'
/var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModelC2id18_PersistedPropertyfMa_.swift:4:50 Cannot convert value of type 'String' to expected argument type 'PersistentIdentifier'
/var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModelC2id18_PersistedPropertyfMa_.swift:8:54 Cannot infer key path type from context; consider explicitly specifying a root type
/var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModelC2id18_PersistedPropertyfMa_.swift:12:64 Cannot infer key path type from context; consider explicitly specifying a root type
/var/folders/t5/c9qp7_4j19x9s3p3z26kn6v80000gn/T/swift-generated-sources/@__swiftmacro_9AeolusKit11DeviceModel0D0fMm_.swift:25:50 Type 'Observation' has no member 'ObservationRegistrar'
the code in question causing the error:
import Foundation
import SwiftData
@Model
public final class DeviceModel {
@Attribute(.unique) public var id: String
init(id: String) {
self.id = id
}
}
I've already done the following:
clean the project
erase the contents of the derived directory
restart xcode
restart my mac.
I want to emphasize, I do not believe it is my code causing this issue, as commenting out the @Model result's in a perfectly normal build with no warnings or errors
Any help is appreciated
I'm trying to create a simple app for tvOS. But I immediately encountered difficulties. At the top I have a tab selection, and at the bottom there is item management.
The problem is that all buttons in HStack are connected into one big button.
So I solved it by adding .plain style to the buttons.
But now I have a new problem - I can't focus on my buttons for tab selection.
Here is the code:
struct ContentView: View {
var body: some View {
VStack {
HStack (alignment: .center) {
Button("tab1"){}
Button("tab2"){}
}
.frame(width: 500) // works when remove
List {
HStack {
Text("Item 1")
Spacer()
Button("Button1"){}
.buttonStyle(.plain) // added
Button("Button2"){}
.buttonStyle(.plain) // added
}
HStack {
Text("Item 2")
Spacer()
Button("Button1"){}
.buttonStyle(.plain) // added
Button("Button2"){}
.buttonStyle(.plain) // added
}
}
}
}
}
I would appreciate any help. Unfortunately, there is very little information on the Internet about designing applications for tvOS, which confuses me.
Hey,
I have an app that presents a UIWindow on top of an existing window. I've made all the needed calls to makeKeyAndVisible() and I can clearly see the new window with the subviews on the screen.
I've made the subview receive focus by implementing them as custom views that have canBecomeFocused as true
also the window implements preferredFocusEnvironments and returns these subviews
The issue the focus engine doesn't want to move to the bottom view, it seems the first one does get focus.
The error I'm seeing when printing using UIFocusDebugger.checkFocusability():
<UIFocusUpdateContext: 0x600003318000: previouslyFocusedItem=<FV: 0x102a17f30>, nextFocusedItem=(null), focusHeading=Down>
The following issues were found that would prevent this item from being focusable:
- ISSUE: This item is not visible onscreen.
I can't find any reference online about this error, so it seems something really wild is going on and I can't find the reason.
Did anyone encounter this before or knows when this error is being printed?
What causes the focus engine to think the view is not visible when it's all there?
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 am guessing this is a NavigationSplitView and the menu is in the sidebar closure. But I'm not quite sure how to reproduce this style of menu. Along with the collapsing breadcrumb for back button. I would have thought this would be out of the box?
I have a two-view app where the main view is a procedural animation and a secondary view controls settings for the animation. I want to use Play/Pause to toggle between the views, but can't figure out how to do this.
Ideally the main view does not have any visible control and the whole screen can be dedicated to the animation view. Attaching onPlayPauseCommand to the main view does not work. I've also tried managing focus using onFocus without success.
I'm open to other ways to toggle between the main and settings views, it's just that Play/Pause seems the most intuitive.
Conformed with a couple buddies who also made the mistake of "upgrading" - audio but no video with the 16.x TV emus, no play with the 17.x emus.
When is the fix?
Hello,
on tvOS/Apple TV using Swift or Objective-C, is-it possible to get the key pressed by the HDMI-CEC remote controller of the TV (not the Siri remote controller) ?
Thanks
My app is currently on the app store for IOS, iPadOS and MacOS. I have created a version for Apple TV but cannot get it to save to iCloud. Is there anyone who can help me get my app to save to iCloud for the Apple TV?
I'm attempting to integrate DRM into the app. I've developed a prototype, but the delegate method shouldWaitForLoadingOfRequestedResource isn't being triggered on certain devices, although it functions correctly on others. Notably, it's invoked on Apple TV 4K (3rd generation) Wi-Fi (A2737) but not on Apple TV HD (A1625). Are there any specific configurations needed to ensure this method is invoked?
let url = URL(string: RESOURCE_URL)!
// Create the asset instance and the resource loader because we will be asked
// for the license to playback DRM protected asset.
let asset = AVURLAsset(url: url)
let queue = DispatchQueue(label: CUSTOM_SERIAL_QUEUE_LABEL)
asset.resourceLoader.setDelegate(self, queue: queue)
// Create the player item and the player to play it back in.
let playerItem = AVPlayerItem(asset: asset)
let player = AVPlayer(playerItem: playerItem)
// Create a new AVPlayerViewController and pass it a reference to the player.
let controller = AVPlayerViewController()
controller.player = player
// Modally present the player and call the player's play() method when complete.
present(controller, animated: true) {
player.play()
}
}
//Please note if your delegate method is not being called then you need to run on a REAL DEVICE
func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool {
// Getting data for KSM server. Get the URL from tha manifest, we wil need it later as it
// contains the assetId required for the license request.
guard let url = loadingRequest.request.url else {
print(#function, "Unable to read URL from loadingRequest")
loadingRequest.finishLoading(with: NSError(domain: "", code: -1, userInfo: nil))
return false
}
// Link to your certificate on BuyDRM's side.
// Use the commented section if you want to refer the certificate from your bundle i.e. Store Locally
/*
guard let certificateURL = Bundle.main.url(forResource: "certificate", withExtension: "der"), let certificateData = try? Data(contentsOf: certificateURL) else {
print("failed...", #function, "Unable to read the certificate data.")
loadingRequest.finishLoading(with: NSError(domain: "com.domain.error", code: -2, userInfo: nil))
return false
}
*/
guard let certificateData = try? Data(contentsOf: URL(string: CERTIFICATE_URL)!) else {
print(#function, "Unable to read the certificate data.")
loadingRequest.finishLoading(with: NSError(domain: "", code: -2, userInfo: nil))
return false
}
// The assetId from the main/variant manifest - skd://***, the *** part. Get the SPC based on the
// already collected data i.e. certificate and the assetId
guard let contentId = url.host, let contentIdData = contentId.data(using: String.Encoding.utf8) else {
loadingRequest.finishLoading(with: NSError(domain: "", code: -3, userInfo: nil))
print(#function, "Unable to read the SPC data.")
return false
}
guard
let spcData = try? loadingRequest.streamingContentKeyRequestData(forApp: certificateData, contentIdentifier: contentIdData, options: nil) else {
loadingRequest.finishLoading(with: NSError(domain: "", code: -3, userInfo: nil))
print(#function, "Unable to read the SPC data.")
return false
}
// Prepare to get the license i.e. CKC.
let requestUrl = CKC_URL
let stringBody = "spc=\(spcData.base64EncodedString())&assetId=\(contentId)"
let postData = NSData(data: stringBody.data(using: String.Encoding.utf8)!)
// Make the POST request with customdata set to the authentication XML.
var request = URLRequest(url: URL(string: requestUrl)!)
request.httpMethod = "POST"
request.httpBody = postData as Data
request.allHTTPHeaderFields = ["customdata" : ACCESS_TOKEN]
let configuration = URLSessionConfiguration.default
let session = URLSession(configuration: configuration)
let task = session.dataTask(with: request) { data, response, error in
if let data = data {
// The response from the KeyOS MultiKey License server may be an error inside JSON.
do {
let parsedData = try JSONSerialization.jsonObject(with: data) as! [String:Any]
let errorId = parsedData["errorid"] as! String
let errorMsg = parsedData["errormsg"] as! String
print(#function, "License request failed with an error: \(errorMsg) [\(errorId)]")
} catch let error as NSError {
print(#function, "The response may be a license. Moving on.", error)
}
// The response from the KeyOS MultiKey License server is Base64 encoded.
let dataRequest = loadingRequest.dataRequest!
// This command sends the CKC to the player.
dataRequest.respond(with: Data(base64Encoded: data)!)
loadingRequest.finishLoading()
} else {
print(#function, error?.localizedDescription ?? "Error during CKC request.")
}
}
task.resume()
// Tell the AVPlayer instance to wait. We are working on getting what it wants.
return true
}
Hello,
I am new to Apple TV Development. I am researching if it would be possible to develop a tvOS App for IPTV that consumes content entirely from an API in the local network (I have domain such as sampleserver.com that points to a local network IP such as 192.168.1.10 ) and also plays back m3u8 HLS sources (live and VOD) produced in that local network server. No content comes from the cloud. Here are my questions:
Would Apple approve this kind of app in the App Store? Or will Apple ask me to instead deploy this as a "Custom App" with Apple Business Manager and an MDM server?
Is there an App Builder technology that fits better for this use case, such as TVML?
If this app is published in the App Store and a user that is not in that local network, is there a guideline from Apple that I should follow to let the user know that he does not have access to the local content?
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).
I'm trying to do something so seemingly basic, yet I can't get it to work and I'm flummoxed.
In a basic, vanilla SwiftUI app for tvOS, embed a single Text element with a very long string (hundreds of lines) in it:
struct ContentView: View {
var body: some View {
ScrollView(.vertical) {
Text(veryLargeString)
.focusable()
}
}
}
Then fire up the app on tvOS, and it will not scroll. No matter what I do. Pressing arrow keys, swiping fast with my thumb, and nothing. It will not move. Ironically, in the Xcode SwiftUI Preview window—it does scroll, so that's always a fun tease.
What I do know is that the focus engine is throwing a few errors, so it's leading me to believe the issue is with how I have the focusable element attached. I'm using a combination of -UIFocusLoggingEnabled YES as well as listening for UIFocusSystem.movementDidFailNotification.
Unfortunately since this is SwiftUI, the notification failure and debugging logs aren't really all that actionable. Help appreciated!
I know that this is not a coding question and I have posted on the regular Apple Forum and have been working with the 800 Tech Support folk for 4 months.
I am in a world of hurt.
Have ATV + Samsung TV + external soundbar.
All software versions are current
NO Cable box (direct input). 4 months ago I had Cable box = zero problems.
With Samsung on and ATV off, stereo = Dolby 5.1 sounds great.
With ATV also on, no stereo.
I can use Siri remote to activate stereo until I change to a new movie. ATV then reverts to mono = PCM
One Tech Support lady said to just not watch multiple movie.
?$@!*+^?
I have spoken with engineers at Samsung and Sonos (soundbar). Both say my cabling is correct = 1 cable from soundbar to HDMI Arc on TV + 1 cable from ATV to another HDMI port on TV.
Another Tech Support folk said to connect ATV to soundbar. Soundbars don’t have gobs of HDMI ports, the TV does.
?!$@*^+%#
I have spoken with Apple Tech Support with zero help for 3-4 months.
I think I have been a good soldier. But it is time for real results.
Please help
I am trying to Execute Universal Link of Netflix show from My App in tvOS 17.2
When I Call the open(_:options:completionHandler:) to execute the Link it does open the Netflix App but open the landing page of Title. I have tried different alternative links but all has same behaviour.
The same Link works in iOS ans iPad OS. Here the links that I have tried and the code that handles the universal Link.
http://www.netflix.com/title/81731618
nflx://www.netflix.com/title/81731618
// Handle remote notification here
// For example, extract deep link and perform appropriate action
if let deepLink = userInfo["deep_link_key"] as? String {
// Handle the deep link here
print("Received Deep Link: \(deepLink)")
if let url = URL(string: deepLink) {
UIApplication.shared.open(url)
}
}
}
How to implement Player in SwiftUI with support for parental controls?
Sample Code:
Working with Overlays and Parental Controls in tvOS
I use AVPlayerViewController in SwiftUI. On cancel, rejecting the request, the screen is black. On change the channel, on move command up or down direction, I am replacing the current player item with new. Status is ready to play, status of the request is successful upon replacement and I set player to play. The screen is still black.
I am trying to write to a characteristic and I know that it needs to be paired via a pin/passcode in order to initiate transfer of data. But it only pairs with 'just works' method and does not allow for transfer for data.
Is connecting possible with pin/passcode via BLE on TVOS? Seems like it's not.