I've been happily building and deploying my app to my iPhone and Watch S8, and the app was ready to submit to App Store Connect last night. However, when archiving it I got an error saying that my DynamicEventSelectionIntent was in multiple extensions. It was, kind of. When I started working on the complications I copied the Widgets intents into the complications, and left the name the same, but they were not in multiple targets.
It looks like the info plist only had one item in the IntentsSupported (because they're the same name), so I decided to rename them so I had a widget one and a complications one.
The problem I have now is that I can't deploy to my iPhone and Watch anymore because I'm getting this error:
This app contains a WatchKit app with one or more Siri Intents app extensions that declare IntentsSupported that are not declared in any of the companion app's Siri Intents app extensions. WatchKit Siri Intents extensions' IntentsSupported values must be a subset of the companion app's Siri Intents extensions' IntentsSupported values.
All I've done is rename one intent, and locate every instance of it in the info plist files, and add the appropriate new one into the right places.
Here's what I've got. Main App contains Widget and WidgetIntentHandler, plus Watch App, which contains Complications and ComplicationsIntentHandler.
Target: Main app: (I've removed everything that has no bearing on extensions.)
Target: Widget:
Target: WidgetIntentHandler:
Target: Watch App:
Target: Complications:
Target: ComplicationsIntentHandler:
Please, can someone tell me what should and should not be in the various parts, as I've tried for 12 hours now and I cannot get this to deploy to my iPhone anymore :( Thanks.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
A few days ago I installed beta 1 of macOS 26 Tahoe on a spare MacBook Pro 14-inch M4. Everything went well, and it looks okay (well, I don't like it at all, but hey-ho), and I shut it down.
I started it up today, and it rejects my login password every time, then locks my account. When I click the link to "Restart and show password reset options" I'm asked for my Apple ID details, so I enter the correct email and password, then the MBP reboots and I'm back on the login screen with no indication that anything has changed.
Guess I'm stuck now... FB18364657
Topic:
Community
SubTopic:
Apple Developers
In iOS 18 the following code works to set a state variable when you hold your finger on the Text() field (well, the ScrollView()), but it doesn't work in iOS 26:
@State private var pressed: Bool = false
...
ScrollView {
VStack {
Text("Some text goes here")
}.frame(maxWidth: .infinity)
}
.onTapGesture {} // This is required to allow the long press gesture to be recognised
.gesture(
DragGesture(minimumDistance: 0)
.onChanged({ _ in
pressed = true
})
.onEnded({ _ in
pressed = false
})
)
.background(pressed ? .black.opacity(0.4) : .clear)
I've tried changing this to:
var dragGesture: some Gesture {
DragGesture(minimumDistance: 0)
.onChanged({ _ in self.pressed = true })
.onEnded({ _ in self.pressed = false })
}
...
ScrollView {
VStack {
Text("Some text goes here")
}.frame(maxWidth: .infinity)
}
.gesture(dragGesture)
.background(pressed ? .black.opacity(0.4) : .clear)
And this:
var longPress: some Gesture {
LongPressGesture(minimumDuration: 0.25)
.onChanged({ _ in self.pressed = true })
.onEnded({ _ in self.pressed = false })
}
...
ScrollView {
VStack {
Text("Some text goes here")
}.frame(maxWidth: .infinity)
}
.gesture(longPress)
.background(pressed ? .black.opacity(0.4) : .clear)
Neither works.
Any ideas? Thanks.
I have a List containing ItemRow views based on an ItemDetails object. The content is provided by a model which pulls it from Core Data.
When I scroll through the list one or two of the rows will disappear and reappear when I scroll back up. I have a feeling it's because the state is being lost?
Here's some relevant info (only necessary parts of the files are provided):
-- ModelData.swift:
@Observable
class ModelData {
var allItems: [ItemDetails] = coreData.getAllItems()
...
}
-- ItemDetails.swift:
struct ItemDetails: Identifiable, Hashable, Equatable {
public let id: UUID = UUID()
public var itemId: String // Also unique, but used for a different reason
...
}
-- MainApp.swift:
let modelData: ModelData = ModelData() // Created as a global
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// Methods in here (and in lots of other places) use `modelData`, which is why it's a global
}
@main
struct MainApp: App {
var body: some Scene {
WindowGroup {
MainView()
}
}
...
}
-- MainView.swift:
struct MainView: View {
var body: some View {
List {
ForEach(modelData.allItems, id: \.id) { item in
ItemRow(item)
}
}
}
}
struct ItemRow: View, Equatable {
var item: ItemDetails
var body: some View {
...
}
static func == (lhs: Self, rhs: Self) -> Bool {
lhs.item == rhs.item
}
}
There's obviously more code in the app than that, but it's not relevant to the issue.
I've tried:
ItemRow(item).equatable()
Wrapping ItemRow in an EquatableView
Giving the List a unique id
Using class ModelData: ObservableObject and @StateObject for modelData
None made any difference.
I'm using iOS/iPadOS 26.0.1, and I see it on my physical iPhone 17 Pro Max and iPad Pro 11-inch M4, but I don't see it in the equivalent simulators on those versions. The Simulator also doesn't exhibit this for versions 17.5 and 18.5, and I have no physical devices on 17.5/18.5 to check.
Should I be doing as I currently am, where I create modelData as a global let so I can access it everywhere, or should I pass it through the view hierarchy as an Environment variable, like @Environment(ModelData.self) var modelData: ModelData? Bear in mind that some functions are outside of the view hierarchy and cannot access modelData if I do this. Various things like controllers that need access to values in modelData cannot get to it.
Any ideas? Thanks.
Following on from this thread: https://developer.apple.com/forums/thread/805037 my list of items is now correctly maintaining state (no more disappearing rows), but I'm now hitting a really annoying issue: Every time something changes - even just changing the dark mode of the device - the entire list of items is refreshed, and the list jumps back to the top.
A simple representation:
// modelData.filteredItems is either all items or some items, depending on whether the user is searching
List {
ForEach(modelData.filteredItems) { item in
ItemRow(item: item)
}
}
When the user isn't searching, filteredItems has everything in it. When they turn on search, I filter and sort the data in place:
// Called when the user turns on search, or when the searchString or searchType changes
func sortAndFilterItemsInModelData() {
modelData.filteredItems.removeAll() // Remove all items from the filtered array
modelData.filteredItems.append(contentsOf: modelData.allItems) // Add all items back in
let searchString: String = modelData.searchString.lowercased()
switch(modelData.searchType) {
case 1:
// Remove all items from the filtered array that don't match the search string
modelData.filteredItems.removeAll(where: { !$0.name.lowercased().contains(searchString) })
...
}
// Sorting
switch(modelData.sortKey) {
case sortKeyDate:
modelData.sortAscending ? modelData.filteredItems.sort { $0.date < $1.date } : modelData.filteredItems.sort { $0.date > $1.date } // Sorts in place
...
}
}
The method doesn't return anything because all the actions are done in place on the data, and the view should display the contents of modelData.filteredItems.
If you're searching and there are, say 10 items in the list and you're at the bottom of the list, then you change the search so there are now 11 items, it jumps back to the top rather than just adding the extra ItemRow to the bottom. Yes, the data is different, but it hasn't been replaced; it has been altered in place.
The biggest issue here is that you can simply change the device to/from Dark Mode - which can happen automatically at a certain time of day - and you're thrown back to the top of the list. The array of data hasn't changed, but SwiftUI treats it as though it has.
There's also a section in the List that can be expanded and contracted. It shows or hides items of a certain type. When I expand it, I expect the list to stay in the same place and just show the extra rows, but again, it jumps to the top. It's a really poor user experience.
Am I doing something wrong (probably, yes), or is there some other way to retain the scroll position in a List? The internet suggests switching to a LazyVStack, but I lose left/right swipe buttons and the platform-specific styling.
Thanks.
This is another issue found after changing to use a @StateObject for my data model when populating a List.
Previous issue is here: https://developer.apple.com/forums/thread/805202 - the entire List was being redrawn when one value changed, and it jumped to the top.
Here's some code:
struct ItemListView: View {
@State private var showAlert: Bool = false
...
fileprivate func drawItemRow(_ item: ItemDetails) -> some View {
return ItemRow(item: item)
.id(item.id)
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
RightSwipeButtons(showAlert: $showAlert, item: item)
}
}
...
List {
ForEach(modelData.filteredItems.filter { !$0.archived }) { item in
drawItemRow(item)
}
}
...
.alert("Delete Item"), isPresented: $showAlert) {
Button("Yes, delete", role: .destructive) {
deleteItem(item.id) // Not important how this item.id is gained
}
Button("Cancel", role: .cancel) { }
} message: {
Text("Are you sure you want to delete this item? You cannot undo this.")
}
}
struct RightSwipeButtons: View {
@Binding var showAlert: Bool
var body: some View {
Button { showAlert = true } label: { Label("", systemImage: "trash") }
}
}
The issue I have now is that when you swipe from the right to show the Delete button, and tap it, the alert is displayed but the list has jumped back to the top again. At this point you haven't pressed the delete button on the alert.
Using let _ = Self._printChanges() on both the ItemsListView and the individual ItemRows shows this:
ItemsListView: _showAlert changed.
ItemRow: @self, @identity, _accessibilityDifferentiateWithoutColor changed.
So yeah, that's correct, showAlert did change in ItemsListView, but why does the entire view get redrawn again, and fire me back to the top of the list?
You'll notice that it also says _accessibilityDifferentiateWithoutColor changed on the ItemRows, so I commented out their use to see if they were causing the issue, and... no.
Any ideas?
(Or can someone provide a working example of how to ditch SwiftUI's List and go back to a UITableView...?)
I honestly thought I was getting somewhere with this, but alas, no. Every time I do anything in my List of ItemRows it jumps back to the top.
Here's the setup:
DataService.swift:
final class DataService {
static let shared = DataService()
private init() {}
let coreData: CoreData = CoreData()
let modelData: ModelData = ModelData()
}
ModelData.swift:
@Observable
class ModelData: ObservableObject {
var allItems: [ItemDetails]
var standardItems: [ItemDetails]
var archivedItems: [ItemDetails]
init() {
allItems = []
standardItems = []
archivedItems = []
}
func getInitialData() {
// Get all items, then split them into archived and non-archived sets, because you can't use `.filter` in a view...
allItems = dataService.coreData.getAllItems()
standardItems.append(contentsOf: allItems.filter { !$0.archived })
archivedItems.append(contentsOf: allItems.filter { $0.archived })
}
}
MainApp.swift:
// Get access to the data; this singleton is a global as non-view-based functions, including the `Scene`, need to access the model data
let dataService: DataService = DataService.shared
@main
struct MainApp: App {
// Should this be @ObservedObject or @StateObject?
@ObservedObject private var modelData: ModelData = dataService.modelData
// I would use @StateObject if the line was...
//@StateObject private var modelData: ModelData = ModelData() // right?
// But then I couldn't use modelData outside of the view hierarchy
var body: some Scene {
WindowGroup {
ZStack {
MainView()
.environment(modelData)
}
}
.onAppear {
modelData.getInitialData()
}
}
}
MainView.swift:
struct MainView: View {
@Environment(ModelData.self) private var modelData: ModelData
var body: some View {
...
ForEach(modelData.standardItems) { item in
ItemRow(item)
}
ForEach(modelData.archivedItems) { item in
ItemRow(item)
}
}
}
ItemRow.swift:
struct ItemRow: View {
@Environment(\.accessibilityDifferentiateWithoutColor) private var accessibilityDifferentiateWithoutColor
var item: ItemDetails
@State private var showDeleteConfirmation: Bool = false
var body: some View {
// Construct the row view
// `accessibilityDifferentiateWithoutColor` is used within the row to change colours if DWC is enabled, e.g. use different symbols instead of different colours for button images.
// Add the .leftSwipeButtons, .rightSwipeButtons, and .contextMenu
// Add the .confirmationDialog for when I want to ask for confirmation before deleting an item
}
}
Now, the problems:
Swipe an item row, tap one of the buttons, e.g. edit, and the list refreshes and jumps back to the top. In the console I see: ItemRow: @self, @identity, _accessibilityDifferentiateWithoutColor changed. Why did accessibilityDifferentiateWithoutColor change? The setting in Settings > Accessibility > Display & Text Size has not been changed, so why does the row's view think it changed?
With a .confirmationDialog attached to the end of the ItemRow (as seen in the code above), if I swipe and tap the delete button the list refreshes and jumps back to the top again. In the console I see: ItemRow: @self, @identity, _accessibilityDifferentiateWithoutColor, _showDeleteConfirmation changed. Right, it changed for the one row that I tapped the button for. Why does every row get redrawn?
I already had to shift from using the colorScheme environment variable to add new asset colours with light and dark variants to cover this, but you can't do that with DWC.
Honestly, managing state in SwiftUI is a nightmare. I had zero problems until iOS 26 started removing one or two rows when I scrolled, and the fix for that - using @Statebject/@ObservedObject - has introduced multiple further annoying, mind-bending problems, and necessitated massive daily refactorings. And, of course, plenty of my time islost trying to figure out where a problem is in the code because "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions"...
I use the following bit of code to snapshot a View as a UIImage, but it's causing a memory leak:
extension View {
@ViewBuilder func snapshot(trigger: Bool, onComplete: @escaping (UIImage) -> ()) -> some View {
self.modifier(SnapshotModifier(trigger: trigger, onComplete: onComplete))
}
}
fileprivate struct SnapshotModifier: ViewModifier {
var trigger: Bool
var onComplete: (UIImage) -> ()
@State private var view: UIView = .init(frame: .zero)
func body(content: Content) -> some View {
content
.background(ViewExtractor(view: view))
.compositingGroup()
.onChange(of: trigger) {
generateSnapshot()
}
}
private func generateSnapshot() {
if let superView = view.superview?.superview {
let render = UIGraphicsImageRenderer(size: superView.bounds.size)
let image = render.image { _ in
superView.drawHierarchy(in: superView.bounds, afterScreenUpdates: true)
}
onComplete(image)
}
}
}
fileprivate struct ViewExtractor: UIViewRepresentable {
var view: UIView
func makeUIView(context: Context) -> UIView {
view.backgroundColor = .clear
return view
}
func updateUIView(_ uiView: UIView, context: Context) {
// No process
}
}
Taking the snapshot is triggered like this:
struct ContentView: View {
@State private var triggerSnapshot: Bool = false
var body: some View {
Button("Press to snapshot") {
triggerSnapshot = true
}
TheViewIWantToSnapshot()
.snapshot(trigger: triggerSnapshot) { image in
// Save the image; you don't have to do anything here to get the leak.
}
}
}
I'm not the best at Instruments, and this is what the Leaks template produces. There are no method names, just memory addresses:
Is this leak in an internal iOS library, is there something wrong with Instruments, or am I missing something obvious in my code?
Thanks.