Xcode 9 / 10 resets project navigator state - xcode

Usually Xcode project navigator saves open/closed state of the project navigator folders, so when you open the project you always see the same state as before. However it's not the case in one of my projects in Xcode 9. Every time I open it Xcode project navigator opens some folders I don't need and closes the others. Is there any way to fix this annoying bug?

There is an easy workaround: exit Xcode and delete appropriate xcuserdata folder:
YourProjectName.xcodeproj/xcuserdata // no Cocoa Pods
YourProjectName.xcworkspace/xcuserdata // for Cocoa Pods
This effectively resets all user settings for the project, but Xcode would be able to start saving them again. More info on those folders.
Xcode 10 update: same bug, same workaround

Related

How to add storyboard back to xcode after accidentally deleted

I accidentally deleted my storyboard from the Xcode project. I followed this thread : Accidentally deleted Main.Storyboard and fortunately I found it in Base.lproj folder.
But I'm having trouble to add it back to Xcode project. Since I'm new to iOS and Xcode still I couldn't add it back to my project. I can open it separately.
Can someone point me out how can I add it back to my project? Any help would be appreciated.
drag and drop it to Xcode's project navigator
uncheck "Copy items if needed"

How do I recover a storyboard in xcode?

I have a little bit of a situation here. A few days ago, I accidentally deleted my storyboard, so immediately went into my trash and dragged the storyboard back into the project. Everything worked fine. But then I just emptied my trash and the storyboard no longer appears to be in my project; the storyboard file is showing up red and when I click on it, nothing loads. To my dismay, I thought all was lost so I started building a new storyboard and connecting the classes, outlets and actions.
I then went to build the project on the simulator, and it's building with the OLD storyboard. I thought it might just be loading it from memory so I deleted the app on the simulator and built the project again. Same thing again. So then I built it to my iPhone and somehow the old storyboard is still there even though I can't find it anywhere in my project.
What's going on here? Does this mean I'll be able to recover my storyboard?
Also, when I open the project inspector and go to Build Phases > Copy Bundle Resources, and right click on Storyboard.storyboard, and click show in finder, It shows my new storyboard.
1 - There is a place in Derived Data with following path:
/Users/<Your user name>/Library/Developer/Xcode/DerivedData/<Your App Name>/Build/Products/Debug-iphonesimulator/<app Name.app>
Browse to that location.
2 - On your .app file, right click -> Show Package Contents.
3 - In resulting directory list, browse the folder Base.lproj. Under that you are likely to find your old storyboard.
If you have done Delete Derived Data from XCode organizer, you are not likely to find anything up here. But fortunately, XCode doesn't delete it twice against your own wishes.
So try your luck.
I also faced same problem in Xcode 7.
But when I copy and paste it from Derived Data. I got
"Interface Builder cannot open compiled nibs"
So If you delete storyboard by reference. First, check your project folder (using the Finder). If it's there, you can drag it back into your project in Xcode, or you can use the “Add Files to …” menu option. that file is work perfectly.

XCode 4.3.1 crashes on opening specific project

Yesterday I updated my Xcode from 4.2.1 to 4.3.1 from Mac App Store. Everything was fine, but in the evening Xcode started to crash on opening one project, that I am currently working on. Here is the crash log here: http://pastebin.com/bxrMBeu7
I've also noticed that other projects are opening fine. Anyone knows the solution?
I've spent few hours to fix this. There is no need to reinstall xCode.
So, here is my solution:
Go to Organizer > Projects > Your project name. And delete Derived Data (not sure if this is necessary, but I did this few times before I've fixed)
Find you project (*.xcodeproj) in Finder and click 'Show Package Content'. Delete all user specific data from there (I did the same step removing folders with user specific data from svnX client Working Copy window).
Run the project.
Hope this will help.

XCode 4 Unable to Open Old Projects

I just upgraded to XCode 4 and am now unable to view a number of my previous XCode 3 projects. When I launch the projects XCode opens, but it looks like this:
Any way to tell what is going wrong? Any special logs I can look at? I don't get any warnings or errors appearing!
Had the same problem, resolved:
Right click your project's .xcodeproj file -> 'Show Package Contents' -> delete project.xcworkspace . The workspace file will be automatically recreated when you open the project again.
The alternative solution is to create a new workspace (File -> New -> Workspace) and add your project to it (File -> Add Files to "New Workspace"). Essentially the same thing.
Not sure why the workspace file gets out of sync as I didn't go through any Xcode version changes, but I suspect it was related to git commits. Didn't use .gitignore.
More info on xcworkspace:
project.xcworkspace saves your workspace settings (Navigator/Debug/Utilities panes,etc) and Editor states. It's automatically created when you create a new project.
From a forum - "When you open an xcworkspace file, it opens the associated Xcode project and restores the perspective. Therefore, Xcode workspace files (.xcworkspace) can be used as a wrapper or container for an Xcode project (.xcodeproj)."
The solution was to delete the local project files and re-clone from the GIT repository. Not sure what the issue is, but it may have been related to having opened the project in XCode 4 Developer Preview.
Just cleanup old preferences files from "your_project..xcodeproj" bundle.
In file exlorer right click on "your_project..xcodeproj" -> select Show Package Contents,
and remove all files but "project.pbxproj".
Best regards.
I had the same problem with the zxing ScanTest app. Upgrading to Xcode 4.3.2 solved the issue.

Xcode Crashing When Opening Project File

Xcode keeps crashing on me when I open my project file. I've been able to open it fine for weeks now. Not sure how to diagnose. It only crashes for a specific project.
Process: Xcode [1293]
Path: /Developer/Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.Xcode
Version: 3.2.5 (1760)
Build Info: DevToolsIDE-17600000~5
Code Type: X86-64 (Native)
Parent Process: launchd [189]
Date/Time: 2010-12-15 16:05:24.659 -0700
OS Version: Mac OS X 10.6.5 (10H574)
Report Version: 6
Interval Since Last Report: 201 sec
Crashes Since Last Report: 4
Per-App Interval Since Last Report: 80 sec
Per-App Crashes Since Last Report: 4
Anonymous UUID: 2B7F7CFC-45EA-450C-8467-6BF1E356B6F6
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000025940
Crashed Thread: 10 Dispatch queue: com.apple.Xcode.index-access
Application Specific Information:
objc[1293]: garbage collection is ON
The crash is generally a sign the project file has been corrupted. Here's a list of possible things you can do to try to fix it.
1. Fix a corrupted *.pbxproj file
Caused by a merge conflict
If you are using version control, it might be caused by a merge conflict that has not yet been resolved.
Using Finder, open the directory that holds your project.
Right click the project file YOUR_PROJECT_NAME.xcodeproj and Open With your preferred text editing tool such as Sublime Text.
Look for merge conflicts which are usually marked using a series of ========= bars.
Resolve the merge conflicts manually or remove the changes of one side.
Caused by unreadable XML
If that fails go into the file and quickly scroll through to see if anything seems out of place - it should generally be readable XML. You could even try an XML validator against it to see if anything amiss was found.
2. Reset your workspace
Using Finder, open the directory that holds yor project.
Right click the project file MyProject.xcodeproj and choose Show Package Contents.
Delete the xcuserdata folder, which should contain a folder with your username on it.
Repeats step 2 and 3 for your workspace file MyProject.workspace
As elaborated by KennyWinker and Paul R on the answers below.
3. Recreate your Xcode project
Note that this should be your last resort as it is quite tedious to do for large projects.
Lastly you could simply re-create it. That might seem like a big pain, but basically you could just create a new project and drag everything under the "Classes" folder into Xcode to start using it (don't forget to also add the frameworks you need).
Just wanted to elucidate on #Paul R's comment.
I had a situation where Xcode was crashing every time I opened a project file. It seemed to be connect to the IB window that was opening. In the end it was deleting the contents of MyProject.xcodeproj/project.xcworkspace/xcuserdata/ that solved this. It did this by resetting the workspace (open files, window scaling, etc.)
Hope this is helpful.
What worked for me?
The only solution that worked for me was deleting the derived data folders of the hanging project, i.e the derived data folders in above directory: ~/Library/Developer/Xcode/DerivedData/. Hope it helps someone.
What didn't?
As mentioned at other places, deleting MyProject.xcodeproj/project.xcworkspace/xcuserdata/ or MyProject.xcodeproj/xcuserdata/ didn't work for me.
Just wanted add some extra content to #Kenny Winker answer...
To delete your xcode user data go,
Find your Xcode project file ex: MyProject.xcodeproj or MyProject.xcworkspace
Right click on it and choose Show Package Contents
Finally, just delete everything inside the folder xcuserdata
Done! :)
Hopefully, this adds a bit more context to people who doesn't know where to find their project user data.
I had similar problem with Xcode 8.1. The reason maybe the project file contains merge conflict data.
You can remove this by opening Xcode project file in TextEdit.
However, in my case there was no merge conflict. Simply deleting content of DerivedData worked for me.
Steps :
Open finder window then select Go Tab -> Go to Folder… (or press Cmd + shift + G)
Enter ~/Library and press Go. This opens Library folder which is hidden by default.
Go to Developer -> Xcode -> DerivedData folder. Delete all the content of this folder.
The DerivedData is like cache i.e. create every time you build/run your app.
Now open the project. It should work with no issues.
Copying Answer of #Sean D which worked for me.
After seeing a suggestion here, I solved this issue by deleting Xcode's preferences. The most reliable way to do that is the following terminal command, issued after quitting Xcode:
defaults delete com.apple.dt.Xcode
ETA: Other suggestions have involved changing or removing certain individual preference settings, but after trying a few of those, none worked for me. There seem to be multiple incompatibilities in the preferences between 6 and 7b3, so trashing the prefs entirely should work around them all.
I did every solution on the thread. But nothing helped me. Don't know why.
Instead of opening the project through Xcode, I opened the project through the terminal using open Project.xcworkspace, it magically works.
Same thing happened to me, and it was some sort of versioning issue that I couldn't fix, so I reverted back to a prior version and it worked. Feels like there are a few bugs in XCode 4 that still need to be worked out.
Inside your project folder find projectName.xcodeproj or projectName.xcworkspace if you have installed pods right click on it and click on (Show package contents) and finally delete everything inside xcuserdata folder
Launch your project it will work fine
I had XCode crashing every time I opened Images.xcassets. The solution was to delete a corrupt PDF file I had just added.
Computer restart
worked for me. While
xcuserdata deletion
and
defaults delete com.apple.dt.Xcode
didn't work for me.
I even was not able to open xcode alone or any of my projects or single .m file.
I was also facing same issue, I did every things like below but didn't work for me!
Deleting the derived data:
~/Library/Developer/Xcode/DerivedData/
Delete everything inside the folder xcuserdata:
MyProject.xcodeproj/project.xcworkspace/xcuserdata/
and
MyProject.xcodeproj/xcuserdata/
What worked for me?
In my case I have reinstalled Additional Component(Additional downloads) from below link then solved this issue.
https://developer.apple.com/xcode/resources/
If you have any open swift file in a new window (for example when you double click on a .swift file in xCode and it opens in a new window) when xCode opens this might be an issue. I think I had this window opened when closing xCode, then when opening xCode this window opens up again and for some reason crashes xCode. Try to close that open window quickly before it crashes. Strange, but that worked for me.
i tested a lot of ways but after of all i just and only change the directory of my project location every thing fixed and my Xcode works properly and I'm glad now....
I experienced XCode crashing when trying to edit a specific original.m file. None of the above solutions worked, but this did:
Create a new .m file as new.m for example.
Using a text editor open up original.m outside XCode, copy contents and paste into new.m inside XCode. Go back to working in XCode.
Delete and move to trash the original.m
Rename new.m to original.m
Now I can edit original.m without XCode crashing.
In my case there were two windows, one on the internal screen of my MacBook and one on an external each with several tabs opened before Xcode crashed and kept crashing on trying to open the xcworkspace file. The above mentioned solutions did not work. After disconnecting the external display, Xcode started without crashing and both windows were placed on the MacBook's screen. Reattached the display and everything worked as before.
I you use Cocoapods try pod deintegrate, delete the workspace, then pod install. This cured it here (Talking of Xcode 11.2.1 after upgrading the Mac to Catalina and the following crashing Xcode)
Towards a cocoa pods included project, I resolved this issue by renaming workspace file and running "pod install" on terminal again.
I was also facing same issue, everytime xcode was crashing. i restarted mac, cleared derived data/xcuserdata but nothing worked.
I had one more repo so i copied 'project.xcodeproj' file from there and paste it in current repo, this trick resolved my problem.
Go to project -> right click on .xcodeproj -> show package contents -> delete all files in xcuserdata.
Quit the xcode -> reopen
Delete the
Open project in previous version of Xcode and then close it and reopen it on Xcode version that you are using for project,
suppose you are using Xcode 11.1 and it is getting crashed while opening projects, then open it in Xcode 10.0 or 10.1.
Fix a corrupted *.pbxproj file
Reset your workspace
defaults delete com.apple.dt.Xcode
do 1~3 and
git clone ~~~.git newGitProject
copy MyProject.xcodeproj, MyProject.xcworkspace
go to GitProject
paste MyProject.xcodeproj, MyProject.xcworkspace
worked for me.
if you have git repository , try it ;)

Resources