Storyboard file suddenly missing in Xcode - xcode

Somehow my storyboard file won't load in my Xcode project. I see the storyboard in the app project from finder, but when I open the Xcode project it's missing and it's red. I tried dragging the file in but it wouldn't show up in Xcode. What's wrong?

Sounds like your directory structure changed without updating the pbxproj file so the filepath is broken. Click on each affect file, open the Utilities pane to the File Inspector, click on the folder icon and select the file in the Finder window that comes up to restore the path.

Related

Xcode 10 does not show file in Navigation Pane

When I click on a folder in the Navigation pane, and open it in Finder, the file is there, but it's not shown in Xcode and build fails complaining the file doesn't exist. Is there a way to "Refresh" the file structure (the way you would in IntelliJ) or can I only do a drag*drop to fix it?
When I click on a folder in the Navigation pane, and open it in Finder, the file is there, but it's not shown in Xcode and build fails complaining the file doesn't exist.
The project navigator doesn't show you the file system, it shows you the files included in the project. If you need to include a file in the project, then you'll need to add it. You can do that by dragging it into the project, or with the File->Add Files To "..." menu command.

Xcode 10.1 opening wrong file

Just downloaded Xcode 10.1. I have Preferences->Navigation->Double Click Navigation set to 'Uses Seperate Window' as I usually do. However double clicking any file in the project opens a window but the contents of that window is the wrong file. Whichever file I double click on, the same incorrect file opens. If I change double clicking to open in a tab, the correct file is opened...
The problem appears to be just one project.
Have tried a 'Clean Build Folder' to no avail
It was working fine in 10.0
I open the project using the xxxx.xcworkspace (as I have pods in the project).
If I open a new window and view a specific file there then go back to my window with the list of files and double click that file, the correct window is brought to the front with the correct file visible.
Same here. For me it's the Readme.md file that is added at the top level of the project (not inside a group). Removing the reference from the project or putting the top level file(s) in a group (folder) fixed the issue.

How to make Xcode open a project with a selected file in the editor?

Xcode wants to open my current project with the editor on the Main.storyboard file. But that file is corrupted in such a way that Xcode essentially freezes and becomes unusable. Is there a way to make Xcode open the project with the editor on a different file? (The "current file" must be stored somewhere but I can't find where.)

Xcode rearange Files in Finder

I tried to rearrange my source code files in finder and now xcode shows them as deleted. Is there a way to tell xcode the new location of the file?
Click on the Missing file (turns Red) and go to file inspector. Click on the folder button in file inspector and provide the correct path of the file.
For missing files like this in red.
set correct path as shown below.
Select the file in the left (navigator) panel. In Xcode open the right (Utilities) panel if it's not already open. Now click the "File Inspector" tab. You should see a part that says "Location" with a button that looks like a folder. Click that button and then navigate to the folder where you moved the files to. Bam! Xcode should now see it's there!

How to add files to a .bundle file in xcode

I am working on an iOS application that I did not create and I would like to add some audio and image assets to the project. Right now these are all located in a .bundle file and accessed like this:
[[NSBundle mainBundle] pathForResource:#"MyBundle.bundle/some_audio" ofType:#"m4a"]
My question is, how do I add new assets to MyBundle.bundle? I have located MyBundle.bundle in the project navigator and on the filesystem but I can't figure out how to add files.
I figured it out:
Locate the .bundle in Finder (in XCode you can right click and select "Show in Finder")
Right click the .bundle and choose "Show Package Contents"
Drag files into the new finder window that opens

Resources