iPad attempting to import Journaling Suggestions

Apple Recommended

Replies

You need to weak link to the framework. To do this:

  1. In your app’s target editor, switch to the General tab and add the Journaling Suggestions framework to the Frameworks, Libraries, and Embedded Content list.

  2. Switch to the Build Phases tab and, in the Link Binary with Libraries phase, switch the Status popup to Optional.

This shouldn’t be this painful, and we have a bug on file about that (r. 121326851).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Thank you! This fixed the crash. My last issue is that because JournalingSuggestions is technically importable on both platforms, I still need to differentiate iPhone vs iPad to hide UI. Is the recommended approach for that still to use the idiom enum from UIDevice? (I'm revisiting Apple platform development after a significant break so shaking off the rust).

    Also, would it be helpful to add these details to a new radar or would that just be unnecessary duplication?

Add a Comment

(I had some weird UI issue in the forums when adding this before, so I might be duplicating this reply).

Thank you, Quinn! That fixed my crash. Lastly, I will still need to somehow differentiate between iPhone and iPad to hide UI. Is the UIDevice idiom still the recommended approach for that? (I'm shaking off the rust after several years of not developing for Apple platforms).

Also, would it be helpful to add any of these details to new radar or would that be unnecessarily duplicating the one you posted?

Appreciate your help.

This did not fix it for me. I did all of this. Now I can't even build on simulator.

This did not fix it @sha921 @eskimo

#if canImport(JournalingSuggestions) just does not work. The code inside of it always runs. It doesn't matter if I mark the framework as optional in build phases. I doesn't matter if I provide the manual linker flag.

Anything inside #if canImport(JournalingSuggestions) still executes on iPads.

This is BEYOND problematic because it doesn't MATTER if I use the device idiom to check if it's on an iPad or a phone. Because SwiftUI runs that code no matter what. The binary will always crash because #if canImport(JournalingSuggestions) does not block execution.

And besides, the linker flags solution DID NOT fix the simulator issue. Same exact issue. This is a massive problem.

#if canImport(JournalingSuggestions)

                                if true == false {
                                    //OBVIOUSLY this case will never "run" but SwiftUI still checks it, and therefore crashes the app
                                    //THIS STILL CAUSES A CRASH ON IPAD, if I want it to run i need to comment out.
                                    JournalingSuggestionsPicker {
                                                   Text("Choose a suggestion")
                                               } onCompletion: { suggestion in
                                                   print("suggestion:", suggestion)
                                               }
                                } else {
                                    //Only getting here if I comment out JournalingSuggestions code cause CRASH
                                    Text("Would see this on iPad if I used the device idiom check instead of true == false")
                                }
#else
        Text("Only see this on simulator, when I don't link weakly, otherwise i cannot build to simulator no matter what")
#endif

This did not fix it

You have to conditionalise the Other Linker Flags build setting based on whether you’re building for the simulator or not. Here’s what that looks like in Xcode:


#if canImport(JournalingSuggestions) just does not work.

You need all three checks here:

  • #if canImport(JournalingSuggestions)

  • if isJournalingSuggestionsAvailable

  • if #available(iOS 17.2, *)

Try using the code that sha921 posted.


This is a massive problem.

You’ll get no argument from me on that front! As I mentioned earlier, we have a bug on file requesting improvements in this space (r. 121326851).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

same with me, all provided solutions do not work