Posts

Post marked as solved
2 Replies
Hi @simonroetzer , This is very doable! I'll add some code below. First, create your main ContentView WindowGroup as well as your DetailView WindowGroup, and mark the DetailView one with handlesExternalEvents @main struct DragAndDropNewWindowApp: App { @State private var text: String = "Drag me!" var body: some Scene { WindowGroup { ContentView(text: $text) } WindowGroup(id: "detailView") { DetailView(text: $text) } .handlesExternalEvents(matching: ["detailView"]) } } As you were doing, create a userActivity and return an NSItemProvider with that object in your ContentView var body: some View { Rectangle() .fill(.green) .frame(width: 200, height: 200) .overlay { Text(text) } .onDrag { let userActivity = NSUserActivity(activityType: "drag") userActivity.title = text userActivity.targetContentIdentifier = "detailView" userActivity.userInfo = ["first": text as String] return NSItemProvider(object: userActivity) } } Then, in your DetailView you can use .onContinueUserActivity to handle any other things you want do to, like this: .onContinueUserActivity("drag") { activity in let _ = print(activity.title ?? "") } One thing, test this on-device if you can. I've noticed that sometimes the simulator doesn't show the dragging (not always, but sometimes). Letting you know this in case you come across this behavior; this isn't your code, it's the simulator.
Post not yet marked as solved
1 Replies
Hi @bbjay , There is no documented limit. Please only add domains as necessary, but don't be concerned about a hard limit on the number.
Post not yet marked as solved
2 Replies
Have you taken a look at https://developer.apple.com/documentation/technotes/tn3155-debugging-universal-links? If you're still stuck, can you provide me with either your domain name, app name, or App ID if you're comfortable doing so? I've seen issues with Flutter's deep linking in the past, but I can at least look into the Apple side.
Post not yet marked as solved
1 Replies
Hi @ffan0811 , If you're comfortable, can you either send me your domain name, app name, or AppID so I can look into this?
Post not yet marked as solved
1 Replies
Hi @thedeveloper4 , This is shown here: https://developer.apple.com/videos/play/wwdc2021/10018/?time=1031 where Matt adds .commands { ImportFromDevicesCommands() } To the WindowGroup and then demonstrates how this works. I also recommend trying out the code shown in this thread: https://forums.developer.apple.com/forums/thread/695137?answerId=770127022#770127022 This will show you how to add the command, show it in the menu bar under File and import it into your app.
Post not yet marked as solved
1 Replies
Some docs on HealthKit and donating Shortcuts. There's some callouts to Journal in there. If your app donates activities or interactions to SiriKit or HealthKit, the item donated may be shown in any app that utilizes Journaling Suggestions. You can't necessarily directly choose to feature/donate a specific thing, only important events will be aggregated into a Journaling Suggestion. Take a look at this doc on permissions and sharing for 3rd party apps: https://www.apple.com/legal/privacy/data/en/journaling-suggestions/
Post not yet marked as solved
2 Replies
Adding a response here for anyone that comes looking for this later. Universal links do not support custom ports, which is why these weren't working. Those links are now out of date.
Post marked as solved
4 Replies
Hi @KittyCat , I tried to replicate your issue using your above code and substituting in some things like Int for Product and was unable to reproduce this issue. I recommend going through your app and seeing if there's any other place that numberOfProducts gets set, since it must be getting set back to 0 at some point. One idea is printing the value in a few places in your app to see where it may be getting reset. For instance, you could use .onChange to print a message when it gets set to 0 and see where that may be happening.
Post not yet marked as solved
1 Replies
Hi @Trand , if you're still having this problem, please respond here with your App ID so I can look further into your issue!
Post not yet marked as solved
1 Replies
Hi @okayest_dev , It seems like you're asking if you can hide the tabs and show a toolbar item in its place, correct? If so, there's no way to hide the tabs since that hinders the user's ability to navigate. You can choose the placement as I see you've done with .bottomBar, but that's the best you can do. The reason your screen turns black when you hide the TabView is because that's the entire view being shown on your screen. What you're trying to do is actually hide the tabItem, but again, make sure the user always has the option to navigate within the app. See the best practices here: https://developer.apple.com/design/human-interface-guidelines/tab-bars#Best-practices
Post not yet marked as solved
1 Replies
Hi @vojta.bohm , I tried to recreate your problem in a simple test app that switched between a NavigationView and a TabView and had no problems. First, if you're targeting iOS 16 and later, please use NavigationStack Can you please tell me what iOS you're running this on? It seems like there's something else causing this issue here. I recommend trying to reproduce this by slowly removing functionality that could be creating this behavior and until the error no longer shows. You can also try starting with a clean project and slowly adding the same behaviors as your app until you get the error again. Feel free to come back here with any questions or more code and I can try to help further. Lastly, to reference this: it seems it is an issue when you embed TabView inside NavigationView or vice versa? But here it's not the case, they are standalone and I switch between them You should not put a TabView inside a NavigationView or NavigationStack, but you can put a NavigationStack inside of each tab of a TabView .
Post not yet marked as solved
1 Replies
Hi @albraa_3adil , If I'm understanding what you're trying to do correctly, I think you're looking for Section, not nested Lists. What I'm seeing is that you're using nested Lists so that you can add the task name as the label of the second list. Instead, you can use Section like this to get the same behavior without nesting. struct TaskView: View { @Binding var task: Task var body: some View { Section(task.name) { ForEach(task.subtasks.indices, id: \.self) { index in ... Also, if you're targeting iOS 16 and later, please use NavigationStack instead of NavigationView!
Post marked as Apple Recommended
As an update to @eskimo 's response, There's a few cases here: Case #1: Building for the simulator. Case #2: Building for a real device, but running on a device where the framework isn't present (eg: iPad, Mac) Case #3: Building for an iOS version before iOS 17.2 where the framework isn't available For case #1: use #if canImport(JournalingSuggestions) like this: #if canImport(JournalingSuggestions) import JournalingSuggestions #endif Then, in your code where you use JournalingSuggestionsPicker, check if you can import it first. This way, if you're not building for a real device, the framework will not be imported. For case #2: Since you're building for a real device, the framework can be imported. Since it's not an iPhone, your app will crash when run. Protect against this by first checking if you can import UIKit, then setting isJournalingSuggestionsAvailable to be true if you're on an iPhone. If you're on Mac, where UIKit can't be imported, isJournalingSuggestionsAvailable will be false anyways. For example: #if canImport(UIKit) import UIKit let isJournalingSuggestionsAvailable = UIDevice.current.userInterfaceIdiom == .phone #else let isJournalingSuggestionsAvailable = false #endif In your code, where you use JournalingSuggestionsPicker, first check if you can import it with the info in case #1 above, then check if isJournalingSuggestionsAvailable is true. For case #3: To handle the older iOS case, you need if #available(iOS 17.2, *) Altogether, it looks like this in code: #if canImport(JournalingSuggestions) if isJournalingSuggestionsAvailable { if #available(iOS 17.2, *) { JournalingSuggestionsPicker { Text("Choose a suggestion") } onCompletion: { suggestion in print("suggestion:", suggestion) } } else { Text("Requires iOS 17.2.") } } else { Text("Dynamically not available on this platform.") } #else Text("Statically not available on this platform.") #endif } Important - iPad weak linking To ensure your app can run on iPad without crashing, you must weak link to the framework. The normal way to do this is via the Status column in the Link Binary With Libraries build phase. That doesn’t work here because the framework isn’t available on the iOS Simulator platform, so the simulator build fails, as @bryan1anderson pointed out. The workaround is to pass in -Xlinker -weak_framework -Xlinker JournalingSuggestions via the Other Linker Flags build setting.
Post not yet marked as solved
1 Replies
Hi @dav_es , This is a known bug. Please file a bug report at https://feedbackassistant.apple.com if you'd like to include your sample project in a bug report to keep track of this!
Post marked as solved
4 Replies
Hi @Dev_Pro , this is not possible in iOS, please file a feedback report at https://feedbackassistant.apple.com -> Developer Technologies and SDKs -> iOS -> SwiftUI