The title says it all, I'm using SwiftUI for multiplatform app, and I'm using ScrollView in it.
My app has player bar which tracks the AVPlayer's current time. I made it using .offset(y:).
The problem here is that whenever I change offset, the scroll gesture suddenly doesn't work on macOS.
Video link: https://streamable.com/euzuwk
But weirdly, it works on Mac Catalyst version.
Video link: https://streamable.com/oq01mt
The source code is on GitHub.
I tried using Animation, but it made the player bar and music out of sync.
So right now I made a publisher based on AVPlayer's addPeriodicTimeObserver and receiving the time from AVPlayer but now the scroll doesn't work as expected.
Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.
Post
Replies
Boosts
Views
Activity
It's working well on iOS 17 simulator and device. but crashes on iOS 18 beta. It looks like it crashes on a UIviewcontroller page with a UIcollectionView.
In my SwiftData @Model I have an attribute attachments: [String]? and I'm getting an error when trying to save it:
CoreData: fault: Could not materialize Objective-C class named "Array" from declared attribute value type "Array<String>" of attribute named attachments.
Getting this error periodically on iOS 18 Beta 7 on iPhone, but the same code works on iPadOS 18 b7 and on macOS Sonoma (14.6.1)
Anyone seen this?
In my app I added an AppIcon in the Assets.xcassets folder. I added a any/dark/tinted version of the app icon, in 1024x1024 resolution as a HEIC file, specifying a "single size" iOS option.
When I build and run the app in xcode16 beta on iOS18 the icon works as expected, but when I run the same app on iOS17 the icon just shows up as a black rectangle.
How do I get the app icon to work correctly on both iOS18 and iOS17?
One of my blind users reached out to me after they updated to iPadOS 18. I have a button that is used to mark/unmark a favorite location.
He said that he could still tell the favorite status via the label and hint, but VoiceOver was always saying that the switch button is off.
I'm able to recreate this on my iPad as well. The documentation for .isToggle is completely blank.
Basically with iPadOS 17 adding the .isToggle trait makes VoiceOver state that my button is a toggle.
With iPadOS 18 adding the .isToggle trait makes VoiceOver state that my button is a toggle AND try to state its current value. I don't know if this is intentional or a bug.
Button {
showFavActions()
} label: {
Image(systemName: SFSymbolShortcut.star.rawValue)
.symbolVariant(weatherData.currentlyFavIndex == nil ? .none : .fill)
}
.buttonStyle(.plain)
.accessibilityLabel(Text(weatherData.currentlyFavIndex == nil ? "Not a favorite location." : "Favorite location."))
.accessibilityHint(Text(weatherData.currentlyFavIndex == nil ? "Add to favorites." : "Remove from favorites."))
.accessibilityInputLabels(["Favorite"])
.accessibilityAddTraits(.isToggle) // iOS 17
I have a UIViewController that presents a UIPrintInteractionController when a user selects the print button on the UI. The problem is starting in iOS 18 (currently using beta 7) when the print controller is presented the UIViewController's viewWillAppear() is being called. This did not happen in earlier iOS releases and is causing unwanted behavior in the app. Is this a bug or will this be the behavior going forward?
I'm trying to build a custom designed sidebar for iPad that requires there to be no gray divider to separated the navigation and the detail view.
I'm surprised at how unsuccessful I have been given how simple this is but have still found no luck.
My current code:
struct ContentView: View {
var body: some View {
NavigationSplitView {
VStack {
//code...
}
.background(.white)
.navigationSplitViewColumnWidth(70)
.navigationBarHidden(true)
.edgesIgnoringSafeArea(.vertical)
} detail: {
//code...
}
}
}
I've attempted to add an overlay of a white rectangle to cover the divider but it just goes behind the existing border. I like to think there is a simpler solution anyways.
This code can open app, but the deep link is not send to the app.
It doesn't seem to call the UIApplicationDelegate's "application(_:open:options:)" method, so I can't read the link string that was passed in
func perform() async throws -> some IntentResult & OpensIntent {
guard let url = URL(string: "myapp://myappintent") else {
// throw an error of your choice here
}
return .result(opensIntent: OpenURLIntent(deepLink))
}
`struct OpenMainAppIntent: AppIntent {
static let title: LocalizedStringResource = "OpenMainAppIntent"
static var openAppWhenRun: Bool = true
init() {}
@MainActor
func perform() async throws -> some IntentResult & OpensIntent {
guard let url = URL(string: "myapp://open") else {
throw OpenURLError.invalidURL
}
return .result(opensIntent: OpenURLIntent(url))
}
}
`
This is an action in my custom control widget, and i want to use this deeplink open my application and get the link's info, but it won't perform onOpenURL
`@main
struct TestControlWidgetApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
print("url: \(url)")
}
}
}
}`
As the title says, when a ScrollView is near a UIViewControllerRepresentable, then the ScrollView's content no longer accurately recognizes taps. In particular, taps along the leading edge (10 points-ish) are ignored.
Here's a working example:
struct ContentView: View {
var body: some View {
HStack(spacing: 0) {
MyRepresentable()
// .allowsHitTesting(false)
ScrollView {
LazyVStack {
ForEach(0..<10, id: \.self) { index in
HStack(spacing: 0) {
Button {
print("tapped \(index)")
} label: {
Color.red
}
.frame(width: 50)
Color.blue
}
.frame(height: 50)
}
}
}
}
}
}
Here's the representable and a placeholder controller:
struct MyRepresentable: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> MyViewController {
MyViewController()
}
func updateUIViewController(_ uiViewController: MyViewController, context: Context) {}
}
final class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .gray
}
}
When you tap along the leading edge of the red buttons, the taps are ignored for about the first 10 points. But if you prevent hit testing on the representable (by un-commenting the .allowsHitTesting modifier), then the red buttons behave as expected. Also if you just remove the representable entirely, then all the buttons behave as expected.
It's as if the hit targets of the buttons are getting "pushed" over by the representable. Or is the representable simply intercepting these touches?
I've confirmed this incorrect behavior on iPad via touch and mouse. However, Apple Pencil (1st gen) and Apple Pencil Pro behave correctly - even in the presence of that UIViewControllerRepresentable. Perhaps the Pencil follows a different hit-test codepath?
Is this expected behavior? If so, then how do I use UIViewControllerRepresentable and ScrollView side-by-side?
Hello,
When I turn on tinted mode on iOS 18, I noticed that the emojis in the widgets are not rendered properly. The widget in the following screenshot is the template project created by Xcode 16.
Hello!
The WidgetBundleBuilder always crash on iOS 17 if there is a #available(iOS 18.0, *) check in the WidgetBundle body.
I remember there was a compiler bug (something related to type hoisting) in the past, but that was fixed. This time the bug seems to be in the implementation of the result build itself.
Hello. I'm encountering a strange behavior in iOS 18 and wanted to ask about it.
When I run the following code on iOS 18, quotation marks appear in the navigation title.
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.title = " "
self.view.backgroundColor = .systemBlue
}
}
In versions prior to iOS 18, the title is displayed as intended, with nothing showing up. Could this be an intentional change in iOS 18, or is it a bug?
Hi,
In my widgets, I use minimumScaleFactor to ensure that my text is readable.
In iOS 18.0 beta 6 and iOS18.0 beta 7, my texts suddenly became very small.
It seems that minimumScaleFactor acts like if it was applying the given scale value to the text.
minimumScaleFactor(0.1) seems to display the text 90% smaller than the text without calling minimumScaleFactor.
minimumScaleFactor(0.5) seems to display the text 50% smaller than the text without calling minimumScaleFactor.
Is this a bug, of is there an unexpected change in the API ?
Edit : I have created FB14890220, in case this message remains unseen.
If I use the example code I find in the Quick help for LIST (Creating hierarchical lists) in MAC OS 15.1, I get an error, but not in IOS 18.1. The error happens when I try to Compact any Item I had expanded. If I use a table instead I also get an error, But If I use outline group without list there is not error
struct ContentView: View {
struct FileItem: Hashable, Identifiable, CustomStringConvertible {
var id: Self { self }
var name: String
var children: [FileItem]? = nil
var description: String {
switch children {
case nil:
return "📄 \(name)"
case .some(let children):
return children.isEmpty ? "📂 \(name)" : "📁 \(name)"
}
}
}
let fileHierarchyData: [FileItem] = [
FileItem(name: "users", children:
[FileItem(name: "user1234", children:
[FileItem(name: "Photos", children:
[FileItem(name: "photo001.jpg"),
FileItem(name: "photo002.jpg")]),
FileItem(name: "Movies", children:
[FileItem(name: "movie001.mp4")]),
FileItem(name: "Documents", children: [])
]),
FileItem(name: "newuser", children:
[FileItem(name: "Documents", children: [])
])
]),
FileItem(name: "private", children: nil)
]
var body: some View {
List(fileHierarchyData, children: \.children) { item in
Text(item.description)
}
}
}
Hello,
I am trying to create a custom control with the new WidgetKit control widget APIs.
In my custom control, I want to display a custom image, in fact a custom symbol. The custom symbol is not displayed with latest iOS 18 Seed 7 (22A5346a). Only system symbols are displayed. I don't find any information about it in the WidgetKit Apple Developer Documentation.
ControlWidgetButton(action: MyIntent()){
Label(title: {
Text("My Custom Control")
}, icon: {
Image("mycustomsymbol") //NOT DISPLAYED
// Image(systemName: "rectangle.portrait.inset.filled") IS DISPLAYED
})
}
There was no issue with custom symbols in beta 4. Now since beta 5, custom symbols are not displayed.
I wonder if this is a bug or this is intended.
Can you help me ?
I filed a feedback FB14888220
Thank you
For a few reasons, we as a team decided to transition away from the SwiftUI.App launch cycle. We need more control and customisation, and managing the scenes directly ourselves was the best way forward.
We're now trying to run the app entirely from our own App and Scene delegates, however we've run into a problem: When we update the app on a device from a version that uses SwiftUI.App to a version that uses App and Scene delegates, the first initial launch fails with a black screen.
The reason for this is that FrontBoardServices attempts to use the existing UISceneSession after the update, with the SwiftUI.AppSceneDelegate class, instead of calling application(configurationForConnecting:options:). Since SwiftUI.AppSceneDelegate still exists in the scope, the internal property _configurationNeedsReevaluation on UISceneSession returns false and the app attempts to launch from SwiftUI.AppSceneDelegate.
As far as I can tell, there doesn't seem to be a way to fix this that doesn't involve invoking the private method -[UISceneSession _updateConfiguration:] to force the configuration to use the correct Scene delegate.
if let sceneSession = application.openSessions.first(
where: { $0.configuration.delegateClass.map(NSStringFromClass) == "SwiftUI.AppSceneDelegate" }
) {
let newConfig = UISceneConfiguration(name: nil, sessionRole: .windowApplication)
newConfig.delegateClass = SceneDelegate.self
sceneSession.perform(Selector(("_updateConfiguration:")), with: newConfig)
}
Could you maybe advise on a way forwards?
when I push a UIViewController, the bottom view controller was pushed out of navigationController.
For an array only the last row is inserted where print shows the loop is processed
for index in 0..<model.dataTable!.rows.count {
let row = model.dataTable!.rows[index]
catagory.name = row["Catagory"] as! String
context.insert(catagory)
print(catagory.name)
}
tried a forced try?save() which didn't help
Thanks
Joel
Hello!
I wanted to bring up an issue I've encountered with .popover(isPresented:). It does not show up above a TabView on iOS 18. This issue occurs on an iPad or on an iPhone when using the .popover compact adaptation modifier.
(Xcode 16 beta 6 + iOS 18 beta 7)