Discuss the latest Apple technologies announced at WWDC23.

Posts under WWDC23 tag

39 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

10162: The SwiftUI cookbook for focus - does not work as expected with iOS 18
I try to create a sheet that shows a textfield and the textfield should gain the focus immediately after the sheet is presented. This use case is explained in Session 10162 at 11:21 and at 13:31 my desired behavior is shown. I could not get this to work in my own code and downloaded the sample code from here: https://developer.apple.com/documentation/swiftui/focus-cookbook-sample Then I opened the sample code and run it in the simulator. It does not focus when the sheet appears in a iOS 18 simulator using Xcode 16 installed via the AppStore. It does gain focus if I use the "add" Button. No changes made on the sample code. Just adjusted the Team setting to get a clean build. The behavior I get locally under iOS 18 is not what is shown in the session and I can't understand why. I tried the following Simulators (and platforms) iPhone 16, iPad Pro (M4, 11inch) and my Mac. On none of those the last item got focus just by presenting the sheet. Is it not possible to test this in a simulator? Could I have a configuration error? Given all the information I found yet, this seems like a Bug. It would be very helpful if someone could replicate my problem. Thank you for your help. Programm Versions: Xcode: Version 16.0 (16A242d) MacOS: 15.0 (24A335)
0
0
253
Sep ’24
**Debug Build Issue: App Crashes on Device Due to Manual Merge in Mergeable Libraries**
If I use the manual merge option with a mergeable library in debug mode, the app crashes on the device only. Here's what I found when debugging this issue. Problem situation 1 In the debug build, the linker does not find the type of the Meregeable Library. Explain the debugged result of Problem Situation 1 We have a type called UserAdDTO, which belongs to the B Framework. - In our project, B Framework and C Framework are mergeable libraries, and they are merged into A Framework. We are using Manual Merge in A Framework. When we build with the simulator, we link the UserAdDTO from CFramework.framework/CFramework in the app target. On the other hand, when I build with the device, I try to link it from AFramework.framework/AFramework, and I get the issue that UserAdDTO is not found. So, even if you output DYLD_PRINT_BINDINGS, the simulator build links to the C Framework to find the UserAdDTO, but the app links to the B Framework, causing a runtime crash. Problem situation 2 It is confirmed that only the device build does not copy the reexported binary. Detailed description of problem situation 2 If you compare the build messages from the device build with the build messages from the release build, both generate the reexported binaries of B and C Frameworks, but do not copy them to BFramework.framework and CFramework.framework. Instead, they copy the files in different paths. This appears to be a bug, and I'd like to ask you to confirm.
0
0
252
Sep ’24
Mergeable Library: Symbol Not Found Runtime Crash On Device
When I configured the mergeable library manual and ran a build on the device, I got a runtime crash. However, when I build on the simulator, I don't get a runtime crash. This only happens when I build on the device. I was wondering if this is a bug? The error message is shown in the attached picture. Build environment XCode 15.3 I built in debug mode. The CoreToolKit target is manually merged with the rest of the targets. The app target links to the CoreToolKit target. The app target is not linked to the targets that are merged into the CoreToolKit target.
0
1
342
Aug ’24
SwiftUI: detect the beginning of a View using scrollPosition in a V/HStack
Hello, I want to detect when a ScrollView is scrolled at the top of a specific View in a LazyVStack. Here is the code I use: struct ContentView: View { @State private var scrollID: Int? var body: some View { HStack { VStack { Text(scrollID?.formatted() ?? "Unknown") Button("Go") { withAnimation { scrollID = 7 } } Divider() ScrollView { LazyVStack(spacing: 300) { ForEach(0...100, id: \.self) { int in Text(int.formatted()) .frame(maxWidth: .infinity) .background(.red) } } .scrollTargetLayout() } .scrollPosition(id: $scrollID, anchor: .top) } } } } As I specify a top anchor, I was expecting to see the scrollID binding being updated when the red Text View is at the top of the ScrollView. But I noticed that scrollPosition updates the binding way before the red Text View is positioned at the top of the ScrollView, which is not what I want. In this image, you can see the binding is already at one even though there is a lot of space between the View and the top of the ScrollView. Maybe the Stack spacing is taken into account? And manually setting the binding scroll at the position I want, just above the red Text for 7, which makes me think the views IDs are correct. Is my understanding wrong about this modifier? How can I detect the top (beginning) of the View? (If this is a SwiftUI bug, I filed #FB13811349)
4
0
1.4k
Jun ’24
Why I need to press an interactive button two times in a Widget to trigger the AppIntention?
I have a basic Widget with a button to toggle the home lights, the buttons triggers the following AppIntention: import WidgetKit import AppIntents struct ConfigurationAppIntent: WidgetConfigurationIntent { static var title: LocalizedStringResource = "Bulb state" static var description = IntentDescription("This is an example widget.") } struct ToggleStateIntent: AppIntent { static var title: LocalizedStringResource = "Toggle light state" init(){ } func perform() async throws -> some IntentResult { await WizClient.shared.toggleState() return .result() } } The problem is that I must be running the app with xcode (in my phone, not simulator) to work fine, when I stop xcode the button must be pressed two times to trigger the AppIntention. The toggle function works well on the app with a toggle component. Here is the widget: import WidgetKit import SwiftUI struct Provider: AppIntentTimelineProvider { func placeholder(in context: Context) -> SimpleEntry { SimpleEntry(date: Date(), configuration: ConfigurationAppIntent()) } func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry { SimpleEntry(date: Date(), configuration: configuration) } func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline<SimpleEntry> { let timeline = Timeline(entries: [SimpleEntry(date: Date(), configuration: configuration)], policy: .atEnd) return timeline } } struct SimpleEntry: TimelineEntry { let date: Date let configuration: ConfigurationAppIntent } struct BulbActionsEntryView : View { var entry: Provider.Entry var body: some View { HStack { Button(intent: ToggleStateIntent()){ Text("Toggle") } } .padding(.vertical) } } struct BulbActions: Widget { let kind: String = "BulbActions" var body: some WidgetConfiguration { AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in BulbActionsEntryView(entry: entry) .containerBackground(.fill.tertiary, for: .widget) } } } extension ConfigurationAppIntent { fileprivate static var test: ConfigurationAppIntent { let intent = ConfigurationAppIntent() print("Intent -> \(intent)") return intent } } #Preview(as: .systemSmall) { BulbActions() } timeline: { SimpleEntry(date: .now, configuration: .test) }
0
0
586
May ’24
@Query macro vs Query struct
I have spent hours trying to get @Query macros to compile. Mostly they throw up meaningless errors for example the following produces 3 compiler errors: @Query var stylesheets: [StyleSheet] Here's the expansion. The compiler complains that 'private' can't be used here, and it can't find _stylesheets. I searched everywhere to find a resolution then I came across the Query struct. I used it as follows to replace the @Query: let query = Query(FetchDescriptor<StyleSheet>(), animation: .smooth) let styleSheets = query.wrappedValue This also solves another issue that was bugging me - how to get the context when the environment variable is often rejected. All I need to do now is write: let context = query.modelContext None of the WWDC23 SwiftData videos mentions the use of the struct, which is a shame. It feels much like the CoreData approach to fetching data. I hope this helps some of you.
1
0
575
May ’24
How to create AppEntity shortcut to be shown in Spotlight
I am exploring Appi-Intent and Appshortcut. We can create an action shortcut by using the following code. struct WatchListShortcut: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: WatchListAppIntent(), phrases: [ "Tell \(.applicationName) to open first item in watch list", ], shortTitle: "WatchList item", systemImageName: "systemimage" ) } } What I want to show an entity shortcut like shown in the below screenshot. linkText I am not sure how to create the shortcut like Assigned one in the above screen.
0
0
628
Apr ’24
.scrollPosition(id: $dataID) doesn't work at all
I have tried the codes in this page https://developer.apple.com/forums/thread/731271?answerId=755458022#755458022 .scrollPosition(id: $dataID) is supposed to keep the current ScrollView position. However, none of them work. I use Xcode 15.3. Tested on iOS 17.0.1 and iOS 17.4 simulators. The people in the page talk like it works for appending, not for prepending. But in my tests, none of them keeps the scroll position. The scroll view will scroll to other part, without changing the dataID. It will update the dataId to the current value only when I scroll manually.
0
1
593
Apr ’24
Mergeable Libraries: Missing Resources
It's not possible to merge a framework with resource into an iOS app target because the resource are not included in the app bundle. Steps to reproduce: Create an Xcode Project with iOS App Template Add a Framework Target (make sure to "Embed in Application") Add an Asset Catalog to Framework Target Add an Color Resource (or Image Set, or any other Resource) Reference the Resource in App Target (I have used a SwiftUI View) Run on Device (!) to make sure everything works as expected Change "Create Merged Binary (MERGED_BINARY_TYPE)" build setting of app target to "Automatic (automatic)" Change app target settings to link, but not embed framework target (e.g. change from "Embed and Sign" to "Do Not Embed" in "Frameworks, Libraries and Embedded Content" section in "General" tab) Run again (on Device!) and observe how the resources framework resource cannot be found anymore (using SwiftUI you will see a "No image/color named '...' in asset catalog for ..." error message in console logs) Note: Everything works fine in Simulator Same behavior for Release and Debug configuration Same behavior for manual and automatic merging Same behavior for resources which are not bundled in Asset Catalog When archiving the app, an "Assets.car" file is never present (even when creating archiving for Simulator target, when "Allow archiving for Simulator" is enabled) Reported as FB13716505 Test Project: https://github.com/iteracticman/MergeableResources/
8
1
1.5k
Oct ’24
Behavior when a non-empty response is returned for the DDM status report
I have a question. When the DDM status report is sent from a DDM device, normally an empty response is returned. However, if we return a non-empty response that includes an arbitrary string, the device sends us the declaration-items request. Is this behavior correct? device| --status reort--------&gt; |server device| &lt;------a non-empry----- |server device| --declaration-items---&gt; |server. Is this behavior correct?
1
0
611
Apr ’24
Declarative management AppManaged declaration with custom configuration
I am trying to find how to configure an application when using an AppManaged declaration. Using MDM, I would send the install command and include the settings in the 'Configuration' key of the command. I have checked the documentation and rewatched the 2023 WWDC video, but it is not mentioned at all. AppManagedAttributesObject has specific configuration options and doesn't appear to cater for adhoc app specific configurations. Anyone found a way to accomplish this? There are a number of apps (store and enterprise) that require this functionality in order to be configured remotely.
3
2
802
May ’24
Do App extensions require privacy manifests?
Near the bottom, Describing data use in privacy manifests, says: App extensions don’t include privacy information files. The operating system and App Store Connect use the privacy information file in the extension’s host app bundle, in combination with those from third-party SDKs your app links to. Yet the warnings email we see lists the app's extensions as missing manifests. Are we reading the documentation incorrectly? Getting this clarified helps us justify approvals for the additional work.
2
2
1.4k
May ’24
How do I check if a version of an sdk I am using in my app uses a privacy impacting sdk?
I am assuming that even if the app i am using is not listed in the ios list of privacy impacting sdks, if they use a privacy impacting sdk in their sdk, then my app will be required to get the privacy manifest for that privacy impacting sdk: the rule must (logically!) be transitive. So far apple has not sent any email about the app needing to provide that for any of our sdks. but i am worried that maybe apple has not done the check for us yet, and by the time they do , we will be near deadline to submit an app.
1
0
754
Mar ’24
Why SwiftData can not save the order of array elements?
It just a simple contact book app, and there are some model stored through SwiftData import Foundation import SwiftData protocol aData: Equatable, Identifiable { var label: String { get set } var value: String { get set } init(label: String, value: String) } @Model class aNumber: aData, Identifiable { var id = UUID() var label: String var value: String required init(label: String, value: String) { self.label = label self.value = value } } @Model class aEmail: aData, Identifiable {... // here are sample with aNumber} @Model class aURL: aData, Identifiable {...} @Model class anAddress: aData, Identifiable {...} @Model class Contact: Identifiable { var id = UUID() var _firstName: String = "" var _lastName: String = "" var firstName: String { get { return _firstName } set { _firstName = newValue updateNameForSort() } } var lastName: String { get { return _lastName } set { _lastName = newValue updateNameForSort() } } var fullName: String { return _lastName + _firstName } var pinyinName: String { return (...//some rules)} var nameForSort: String var company: String var numbers: [aNumber] var emails: [aEmail] var URls: [aURL] var dates: [Date] var remarks: String var tags: [String] init(firstName: String, lastName: String, company: String, numbers: [aNumber], emails: [aEmail], URls: [aURL], dates: [Date], remarks: String, tags: [String]) { ... } convenience init() { self.init(firstName: "", lastName: "", company: "", numbers: [], emails: [], URls: [], dates: [], remarks: "", tags: []) } func getFullName() -> String { return self._lastName+self._firstName } func updateNameForSort() { nameForSort = ...//some rules } } And the ListView import Foundation import SwiftUI import SwiftData struct BookView: View { @Environment(\.modelContext) private var context @Query(sort: \Contact.nameForSort) private var Contacts: [Contact] @State var isEditing = false var body: some View { let contactsDctionary = Dictionary(grouping: Contacts, by: {$0.nameForSort.prefix(1).uppercased()}) List { ForEach(contactsDctionary.sorted(by: { $0.key < $1.key }), id: \.key) { key, contacts in // group by initials Section(header: Text(key)) { ForEach(contacts, id: \.self) { Contact in { ...//some view NavigationLink(destination: ContactView(contact: Contact)) {} .opacity(0) } } } } } .listStyle(InsetListStyle()) .navigationBarTitle("All", displayMode: .large) .toolbar { Button(action: { isEditing.toggle() }) { Image(systemName: "plus") } } .sheet(isPresented: $isEditing) { NavigationView { ContactEditor(originalData: nil, isEditing: $isEditing) } } } } And the contactView from navigationLink: import Foundation import SwiftUI struct ContactView: View { var contact: Contact @State var isEditing = false var body: some View { List { Section { ForEach(contact.numbers) { aNumber in row(aData: aNumber) } } Section { ForEach(contact.emails) { aEmail in row(aData: aEmail) } } } .navigationTitle(contact.fullName) .toolbar { Button(action: { isEditing.toggle() }) { Text("编辑") } } .sheet(isPresented: $isEditing) { NavigationStack { ContactEditor(originalData: contact, isEditing: $isEditing) } } } } Now I had some contacts had stored, they store some [aData] like the numbers: [aNumber], when I view them in contactView, their elements, such a list of the "aNumber" are arranged in some order(this is random), then I completely close the app and open it next time, the order of the array elements displayed just now has been completely disrupted. So how to solve this problem? I just want to keep their order the same as when I append them in array. In addition, English is not my mother ******. I hope you can understand my expression. I would be very grateful if anyone can solve this problem!
0
1
799
Mar ’24
Privacy manifest files for SDKs
As the new requirement for Privacy manifests is coming this Spring 2024 (https://developer.apple.com/news/?id=r1henawx), Apple released a list of SDK's that need to comply with this requirement and provide a privacy manifest file: https://developer.apple.com/support/third-party-SDK-requirements/ I have a SDK project that does not fall under the mentioned requirements。 collects data uses of required reason API includes listed Third-party SDK I have some questions: Do I need to include a privacy manifest file in my SDK project? if so, is a blank privacy manifest file included in the SDK? if not, is it possible to publish an App that use my SDK, without a privacy manifest file?
0
1
788
Feb ’24