Scott
Scott

Reputation: 2676

XCode hangs while opening a specific project

When I try to open a specific project with XCode, it hangs. When it hangs, it shows the following screen: image

Other projects can open fine, although the project that hangs opens too, meaning I can't do anything. My CPU is running at full speed (the fan starts going), and I have to quit multiple processes named "Interface Builder Cocoa Touch Tool."

I've tried...

I can't open the XCode preferences - UROPv6 (the project that hangs) always opens, so all of those options are thrown out the window.

The app that hangs is an iOS project. I've looked at this blog post, but I am using *.storyboard, not *.xib.

Since none of the above methods worked, I think I have some file in my project that's causing this. How do I open the project?

For the full error log when XCode crashes, see this gist.

Upvotes: 5

Views: 3033

Answers (4)

Nati Lara-Diaz
Nati Lara-Diaz

Reputation: 2202

My case is super specific, but it might save some hours for somebody in the same situation.

I have Xcode 11.2.1 and I have Realm as my database, I also use Realm Browser for seeing/control the data.

Realm Browser creates some folder and hidden files after opening a Realm file: content.realm.management and content.realm.lock which for some reason if I leave them there Xcode is stuck. I solve the problem by deleting these files everytime Realm Browser creates them.

Upvotes: 0

User5910
User5910

Reputation: 485

I had a similar issue with Xcode 6.1.1. I tried all the solutions above plus a few more I found on the web to no avail. I finally resorted to a binary search and got things working again.

  1. Make a backup of your Xcode project.
  2. Open the Xcode project package (in Finder, right click and choose Show Package Contents).
  3. Open project.pbxproj in a text editor and examine the PBXFileReference section.
  4. Remove half of the items in the list taking care to also remove the corresponding items from the PBXGroup section below. Save the file and open the project in Xcode. Keep iterating until you find the offending item(s). For instance if Xcode still hangs, restore your backup and remove the other half of the items and try again.

In my case the problem was a symlinked folder.

Upvotes: 0

Gary W. Longsine
Gary W. Longsine

Reputation: 662

Scott, you might consider a more comprehensive .gitignore file. The xcuserdata folder can be (should be?) ignored by git under most circumstances.

Here's a sample .gitignore file you can start from, which will exclude most of the stuff that doesn't need to be in your archive, some of which can cause weird issues from time to time, or which merely takes up space in your archive without contributing any value. This sample includes lots of older control files from Xcode and its ancestors which you might not think you'll encounter, until one day when you import a class, library, or framework from a project with deep roots.

I put this together and shared it on a blog several years ago (A better sample .gitignore for Xcode iOS and OSX projects) based on the philosophy, "if it's a temp file of any kind, if it typically ought not be in an archive (e.g. a Sparkle private key), or if it simply isn't necessary (e.g. various intermediate build products), exclude it".

If you don't like this one, take a look around and find one you like. There are derivatives of this all over the web, now (including a cool one implemented as an Xcode script that creates the file in whatever directory you like), as well as others with different (minimalist) philosophical approaches, and some with more detailed comments.

You can put a .gitignore file at the top level of any git archive and check it in, to enforce the ignore for all team members. You can also put it on your system as a global ignore file for yourself, in case you create a project and forget to add the ignore file before the initial commit.

LINK: How to make a global .gitignore file

sample .gitignore file for Xcode iOS and OSX

# Mac OS X Finder and whatnot 
.DS_Store
.Trashes

# Sparkle distribution Private Key
dsa_priv.pem

# Xcode (and ancestors) per-user config 
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser

#  Whitelist the Xcode defaults
!default.mode1
!default.mode1v3
!default.mode2v3
!default.perspective
!default.perspectivev3
!default.pbxuser

# Xcode 4 - Deprecated classes
*.moved-aside

# Generated files
VersionX-revision.h

# build products 
xcuserdata/
DerivedData/
build/
*.[oa]

# Other source repository archive directories 
.hg
.svn
CVS

# automatic backup files
*~.nib
*.swp
*.lock
*~
*(Autosaved).rtfd/
Backup[ ]of[ ]*.pages/
Backup[ ]of[ ]*.key/
Backup[ ]of[ ]*.numbers/

Upvotes: 1

Scott
Scott

Reputation: 2676

rm -rf ~/Developer/XCode/UROPv6/Reconstruct.xcodeproj/project.xcworkspace/xcuserdata worked. When I tried to run git checkout 0ea13d, it said `error:

Your local changes to the following files would be overwritten by checkout:
Reconstruct.xcodeproj/project.xcworkspace/xcuserdata/scott.xcuserdatad/UserInterfaceState.xcuserstate
Please, commit your changes or stash them before you can switch branches.
Aborting`

So I deleted that folder, and now it works.

Upvotes: 7

Related Questions