8 Replies
      Latest reply on Nov 16, 2019 9:20 AM by johnvsc.
      dbradley645 Level 1 Level 1 (0 points)

        I have been working throught the SwiftUI demo code tasks from this website and up until now have not had an issue. On the most recent step (https://developer.apple.com/tutorials/swiftui/handling-user-input Section 2 Part 2), I attempted to run the application using the new Canvas feature, only for the canvas preview to start consistently crashing (even with the code added in that section commented out), but when you ask for the Diagnostics the error code is mainly: "Landmarks.app: no underlying error". There is though sometimes the error: "Landmarks.app: Error Domain=render service Code=12 "Rendering service was interrupted" UserInfo={NSLocalizedDescription=Rendering service was interrupted}", which I can't locate online anywhere other than one chinese language website. Has anyone any idea wether this is something to do with the code I've been writing or is this a bug in SwiftUI in XCode 11 Beta? Or any suggestions on a fix? Thanks in advance! (NOTE: Xcode 11 beta  (11M336w) and the first release of MacOS 10.15 Beta are both being used on this)

        • Re: Error (but no error) with Canvas when trying to run SwiftUI Landmark
          mikesand Level 1 Level 1 (0 points)

          Had the same issue. Are you by any chance doing the tutorial on a MacBookPro?


          The Swift UI tutorials experience of right panel code example changing and highlighting changes as you scroll the instructions on the left is innovative and generally works, but has some drawbacks. One is that if the code example on the right is too big to fit in the window, there's no way to know that. Following convention since 10.7 Lion, the scrollviews are hidden until you start to scroll.


          So when you get to "Handling User Input" Section 5 Step 5, there's no good way to know that if on a MacBookPro 15" Safari at default resolution and size, apparantly, you need to scroll down and see additional changes that you need to make to the "PreviewProvider" in order for the preview to work.


          That the error message blames your app -- your app "may have crashed" is just user-hostile. The app builds and runs, it's the preview that has crashed, and astonishing they can't surface that information in the UI or crash reports but defualt to text blaiming the app.  I only found it by running the tutorial that was crashing and the "complete" project provided through diff tool FileMerge.

          But that no one did the tutorials on a MacBookPro 15" to see this problem is just come on.

            • Re: Error (but no error) with Canvas when trying to run SwiftUI Landmark
              mikesand Level 1 Level 1 (0 points)

              After looking again, a few points.


              First, If the EnivronmentObject is not provided, the code has crashed, so in that sense the warning is accurate.

              However, it's misleading to say "YourApp.app" may have crashed, since the preview does not go through the app's normal control flow. It starts at the PreviewProvider. Since the PreviewProvider is a concrete type, it would be better to say `LandmarkList_Previews has crashed` or just otherwise name-check the specific PreviewProvider (instead of "Cannot preview in this file" so that we can know to start looking in the preview.


              Really, best case would be the missing EnivronmentObject should be detectable at compile time, though I don't know how that would work.  Notably, the crash happens even if the EnvironmentObject is not used anywhere in the body. Also, when running the actual app target, if the EnivronmentObject is not set on the rootView of the UIHostingController that is the window's rootViewController, then the crash happens on makeKeyAndVisible; anywhere else, the crash just goes to UIApplicationMain. Regardless, a missing EnvironmentObject object at runtime should be able to determe that and trap with that message, not fail on an error with StoreBox.

            • Re: Error (but no error) with Canvas when trying to run SwiftUI Landmark
              amir0320 Level 1 Level 1 (0 points)

              Hi, I'm on the Handling User Input tutorial, and I always fail section 5(https://developer.apple.com/tutorials/swiftui/handling-user-input). I followed each step meticulously and after I did section 5 step 1, Xcode popped up an error "Use of undeclared type 'UserData'". I tried to ignore and followed through. However, my LandmarkList, LandmarkDetail, SceneDelegate files warned me of the same error. I even checked the completed version of the project that I downloaded from the tutorial page. They looked exactly the same except the parts that I haven't done. Do everyone here have similar experience as mine or can kindly offer some suggestions? Thank you!

              • Re: Error (but no error) with Canvas when trying to run SwiftUI Landmark
                AdrianBinDC Level 1 Level 1 (0 points)

                Adding this line to Landmark_ListPreviews got it working for me:






                • Re: Error (but no error) with Canvas when trying to run SwiftUI Landmark
                  FXK0 Level 1 Level 1 (0 points)

                  I am facing the same issue too, and here is my solution


                  If you use the code from "Building Lists and Navigation" tutorial, you need to modified landmarkData.json and Landmark.swift file to solve the problem


                  In landmarkData.json file, you need to add "isFavorite":true or "isFavorite":false property to every data, and then add variable "isFavorite : Bool" in Landmark.swift.

                  • Re: Error (but no error) with Canvas when trying to run SwiftUI Landmark
                    johnvsc. Level 1 Level 1 (0 points)

                    Hey everyone - Had the same thing as above ... but this solution worked for me: Cleaning the DerivedData out ... essentially clearing the compiled cache of xCode build temps : https://stackoverflow.com/questions/46468220/how-can-i-delete-derived-data-in-xcode-9/46468462#46468462


                    This solution seemed so valuable that I aliased the DerivedData directory from my ~/Developer


                    I found this solution from https://forums.developer.apple.com/thread/120960 

                    Hope this helps