Xcode automatically opening non-existent file and crashing - xcode

Please note: This is a pure Xcode question at heart, the fact that I mention ARKit, SceneKit and DAE files is only incidental. Anyone who knows how to deal with Xcode crashing should be able to answer this, regardless of their level of knowledge of ARKit/SceneKit/DAE files!
I'm playing around with ARKit and SceneKit and used Blender to export a 3D model to Collada/DAE format. I then opened my Augmented Reality project in Xcode 9, and dragged-n-dropped the folder containing my DAE file under the Resources/Models.scnassets folder in my project. Hence the contents of my project's Resources/Models.scnassets folder were now:
Resources/
Models.scnassets/
dog/
cat/
myblenderdaemodel/
myblenderdaemodel.dae
Where myblenderdaemodel/myblenderdaemodel.dae is the folder + file I just dragged and dropped into my project.
I then attempted to open the myblenderdaemodel.dae file by clicking it, and Xcode immediately crashed.
I re-opened Xcode and it automatically opened my project and then automatically tried opening my DAE file (since that was the last file that was opened before the crash), and it crashed again.
So I tried opening a different project in Xcode, which I am able to do. But anytime I attempt to open my "unhealthy project" in Xcode it attempts to first open my DAE file and crashes.
I open Xcode by opening an .xcodeproj file of another project
I then close that other project and attempt to open my sick/unhealthy project that is crashing
It attempts to open/load my DAE file in the DAE editor (since it was the last file opened)
It immediately crashes
Although I am interested in understanding why my DAE file is crashing Xcode, I don't really care about this file, I just wanted to play around wth it. I do care about my project however!
So on the terminal I removed the myblenderdaemodel folder from its Resources/Models.scnassets parent directory, and also used grep to confirm there weren't any other references to the phrase myblenderdaemodel inside my project folder. I am convinced it has been completely removed, as well as any references to it have been removed...
But I am still unable to open Xcode...the 4 steps above keep happening, Xcode is convinced there is still a file in my project called myblenderdaemodel.dae and it is attempting to open it.
My theory is that perhaps Xcode stores project information inside its own directory somewhere, and when you load that project, it pulls data from this cache and loads the project with that data, and perhaps that data still contains references to my (now deleted) DAE file.
Either way, what's the fix here? How do I open Xcode in such a way

Related

Some files not visible in xcode. But they are visible in finder

I am writing test cases for IOS. For that I created a new target for "IOS UI Testing" bundle and some files for writing test cases.
It created a folder "UITests" with some test files in it.
The problem is they are not visible in the xcode after xcode is restarted.
I am able to find the code in the finder and they are also recognized by the git. But not able to find them in the xcode
What might be the reason for this unpredictable behaviour?
Here's a screenshot of my xcode project, after I add the files manually.
Now, I can see the files, but I am unable to run my tests as it gives me error "Cannot load underlying module for XCTest".
I got the answer. Thanks to #HunaidHassan.
whenever you do add a new target or a file. It gets referenced in the .pbxproj file. It saves the references of all the project files and its hierarchy.
I was discarding the changes done to pbxproj file, therby removing the references of newly created targets and files, which caused the files to disappear from the xcode

Changing the name of main folder in Xcode project

This is not the first time I've had trouble with this and I suspect not the last time either. Despite having learned many frameworks inside out I still find the organizational structure of a simple xcode project elusive. I simply wanted to retitle a project from CATouchSynth to ABTouchSynth. A while ago I discovered that if you click on the Project folder in project navigator and than change the name in the Identity and Type section it will rename many of the relevant files and directories to the new name. However, there is one main folder inside the folder on your computer that doesn't change and still has the old name. I could see no way to change this folder name through Xcode and so I renamed it manually from finder. This turned all of my source files and assets red so I manually "relinked" them in xcode and they are now non-red and seemingly linked with the newly named folder. However I am getting several compile-time errors talking about the old folder name but I have no clue what Xcode is referring too. The errors look like this
It seemed as if derived data was an issue so I deleted the derived data folder from Xcode and I still get these errors. Has anyone experienced this before and what can I do to ressurrect my project?
Note: Before doing any changes do backup your project folder. This is seriously recommended.
Follow the steps below to rename the source folder of your project –
Close XCode.
Rename the Source Folder.
Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor (Xcode).
This step should be done with extreme caution. Search and replace any occurrence of the original folder name with the new folder name.
Save and Close the file.
Open XCode project.
The error is happening at build time during the compile phase, so you will have to go into the app target's Compile Sources build phase, remove all those .m files, and add them again.

Storyboard file in Xcode now showing up as an empty folder

I opened my Xcode project this morning and found that the .storyboard file in my project now shows up as a folder named MainStoryboard.storyboard instead of an actual storyboard file.
It seems to be the same when I open it in finder and any Time Machine backups, which I find strange because I've had it opened in Xcode more recently than some of the backups.
Is there any way to recover the file or is all hope lost?
This is what I see in the Project Navigator:
Turns out someone had opened the project file in a Developer Preview of Xcode. I had to go way back in Time Machine to find a version of the file that would open.

.xib files not showing up in MonoTouch

Right after building for the simulator I got an error message saying MonoTouch stopped unexpectedly and it shut down. So I closed Xcode and reloaded both. Now, I can't see my .xib files inside the MonoTouch file tree. I can open the .xib files directly in Xcode, but none of the resources need for the files are visible (for instance, images stored in the Resource folder).
How can I get these .xib files associated correctly again?
I fixed this. Had to go back and add each of my existing .xib files back into the project by right clicking on the appropriate folder and then finding the .xib file in the project folder. Once I added them all back, everything worked as expected

xcode copying project to another computer

I'm having problems copying a project over from one mac to another. The project compiles and runs fine after being copied, however xcode seems to have some duplicate of the same classes which seem to be invisible on the project browser on the left.
For example if I jump to definition on a variable I get 2 suggestions pop up. The top file when I look at its properties is relative to xcode folder (this is also the one that shows up in the class browser to the left). The second file which cant be seen on the browser has absolute path type in the properties.
Is there any way to get rid of this behaviour so its just looking at one file only like it originally was doing on the other mac? Its a bit problematic as I am never sure which one I am editing and they don't seem to update each other even though they appear to be the same file.
On a side note if I copy the copied project to another location then I get 3 etc files pop up in the jump to definition.
It's usually a good idea to either not copy the "build" folder (or delete it after you've copied everything over - only do this when Xcode is not running though).
Ok so what you need to do is this:
1.Duplicate your project.
2.Open the copy w/the original ,but only the folder.
3.open the Projects files(not the tests the main files)
4.then Drag and drop the files into the xcode area.
5.Zip the folder and its done
its like that because it just removes the references but not the files they are all still there though so just add the references back into the file.

Resources