NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

problems crashing Xcode

Forums > 100 Days of SwiftUI

Hi,

Maybe this is not the right place, but since I'm trying to follow the 100 days of SwiftUI, I'm hoping others maybe recently run into the same problem.

Without any problems I was able to do stuff in Xcode and Playground. Now at day 16 when trying to do a preview, Xcode keeps on crashing, it get stuck and my macbook Air (macOS Monterey, up to date, 4GB memory) reboots over it all the time.
I did some searching and it sounds like more people run in to this(?). Xcode is downloaded from the App-Store. Removed it, tried a beta version but same problem. Since I also read that the problem was the App-Store version, downloaded the current version from Apple website, but same problem. Downloaded a older version. Again same problem.

I really like the 100daysofSwiftUI so far but now I can't do anything anymore and I don't know what to do anymore. I don't have any large code file. It already crashes on the default page when making a new project. Hope somebody knows what to do.

   

Sounds weird. I never faced this kind of issue. I'm using the app store version, latest 13.4.1 (no beta!) and nothing fancy, on an M1 MBP. Preview crashes regularly and sometimes it's hard to tell why (only giving you feedback that it took longer than 5 seconds but diagnostic report doesn't reveal anything). This is usually due to some missing setup in the preview environment, like missing managed object context or so, which you can't figure out with a clean build, because it's not relying on preview. If Xcode preview gets really stuck, sometimes closing and restart Xcode helps.

However I never had the issue of being stuck i a reboot loop.

Does it only happen on this repo? Which hardware do you use? Intel or M1?

You probably have to perform some diagnostics. Does macOS offer you to create a diagnose report after reboot?

You could push the code that crashes to github and some people (incl. myself) could take a look.

   

About my macbook: Macbookair from early 2015 Processor 1,6 GHz Dual-Core Intel Core i5 Memory 4GB 1600 MHz DDR3 Graphics Intel HD Graphics 6000 1536MB

I'm trying different thinks all day now with Activity Monitor open to (force) quit Xcode before my laptops reboots again.

It already crashes with the default template page when creating a new project. So the basic "Hello, world" page. It also gets stuck on sending the error reports. But did try to send several between yesterday and today.

Edit: I'm going to remove Xcode again. Search everywhere where there can still be files, like in de Developer folder. Delete all those files aswel. And then go and do an reinstall again.

   

Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Hi,

Even I found the same problem with my Macbook Pro late 2013. I know it is outdated still, I'd like the issue to be solved. Currently I'm tracking all the issues with my Macbook and I'm reporting to apple.

   

@Bnerd  

Is your preview crashing ? or it can mompile and run just fine? If it is the preview that causes the crash, try to add your view in a Zstack in the preview Struct, I saw it once in one forum and it made the preview crashing stop..Don't use it every time, just see if it will work.

   

@ioannisfa can you please Explain more on what mean with adding it to a Zstack? It is the preview that is causing the trouble yes. When trying to run I see "Preparing iPhone Simulator for Previews".. First it looks like it is loading. Where I see that line it looks like it is trying to load, it doesn't say anything about precentage but I see that circle going completly round. Like it is loaded(?). Then when it needs to run I guess the circle starts spinning faster, and that is the moment de Memory usage goes up and my laptop sounds like an airplane ready for take off. If I don't (force) quit Xcode my laptop will get stuck and will reboot it self. For now, since I really want to continu the course, I'm ussing my old Iphone to run the code on.

   

@satish748 my laptop crashes even on the error reports :(

   

@Bnerd  

Try the below:

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ZStack{
            ContentView()
        }
    }
}

let us know how it went :)

   

@ioannisfa Doesn't make any difference :(.

   

@Bnerd  

Does it happen with all the apps your tried to make? Try to make a new project and slowly copy paste the code until it doesn't run anymore. Try to clean your build folder(cmd+shif+K), in the one that is currently crashing..

   

@ioannisfa If i start a new project (so nothing writen by me, just the default page Xcode creates) and I click on the resume button. To start the Canvas (If I name it correctly) it already happens.

   

@Bnerd  

My last recommendation would be remove and re-install Xcode..

   

Already did that couple times over the weekend. Did an install from the appstore, downloaded from the apple website. Used a older version, newer beta version. But nothing seems to work. I now use my old iPhone to run the code. That works.

   

You said you used Activity Monitor to force-quit Xcode. At the risk of stating the obvious, I assume you looked at the Memory tab to confirm that the Memory Pressure graph is not turning red. Sorting by memory usage, are there any processes using a lot of memory that you can quit? 4 GB memory is pretty minimal. For example, on my Mac, Activity Monitor reports 3 GB of "wired" memory for system processes that cannot be swapped out, so that if I only had 4 GB RAM, only 1 GB would be available for swapping all the other processes.

Perhaps MacOS is corrupted or infected by malware. Some trustworthy malware scanning tools:   (1) EtreCheck (free version suffices): https://www.etrecheck.com   (2) BlockBlock, RansomWhere & Dylib Hijack Scanner from Objective-See: https://objective-see.org/tools.html

Do you have an external SSD on which you can install a fresh copy of MacOS? Of course, do not use Migration Assistant to copy anything over from your existing system to the fresh system.

   

About the activity monitor, yes. The problem is really when trying to start simulator. Xcode and the other processes that Xcode start to show the simulator seem to causing the problems. I don't see see strange processes running. and aslong I don't start simulator Xcode works fine.

For example I saw: Memory used 3,49 GB Cached files 509,2 MB Swap usage 929,5 MB

App Memory 850,6MB Wired memory 1,25GB Compressed 1,41GB

I did a virus scanning but it was all fine.

I now use an old iphone to run the code on. That works for now

   

Thanks for recomending https://objective-see.org/tools.html

   

Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.