Xcode 8报错找不到InstructionBViewController.swift文件求助
Let’s work through this stubborn Xcode issue together—you’ve already knocked out the basic fixes, so we’ll dive into the sneaky places where Xcode might be hanging onto stale file references.
1. Audit your Compile Sources list
Xcode’s Build Phases often keeps dead file references even after you’ve removed them from the project navigator:
- Select your project root in Xcode, switch to the Build Phases tab.
- Expand the Compile Sources section, then search for
InstructionBViewController.swift.- If you spot duplicate entries (one might be grayed out or point to a missing path), delete the problematic one.
- If the file is missing from this list but you’ve added it back manually, click the
+button to add the new file to the compilation queue.
2. Clean up the raw project metadata file
Xcode stores project details in the .xcodeproj package, and old references can linger here even after visual cleanup:
- Right-click your
.xcodeprojfile in Finder, choose Show Package Contents. - Open
project.pbxprojwith a text editor (like TextEdit or VS Code). - Search for every instance of
InstructionBViewController.swift. Delete any duplicate entries or ones pointing to the old/missing file path. Pro tip: Back up this file before editing—it’s critical to your project’s structure!
3. Don’t overlook test targets
It’s easy to forget that Unit Test or UI Test targets might still reference the old file:
- Repeat step 1, but this time select your test target from the dropdown menu at the top of the Build Phases tab. Check its Compile Sources list for stale references to the file and remove them.
4. Do a deep cache wipe
Beyond deleting Derived Data, try these more thorough cache clears:
- In Xcode, press
Shift+Command+Kto clean the project, thenOption+Shift+Command+Kto wipe the entire build folder. - Close Xcode, then delete the cache folder at
~/Library/Caches/com.apple.dt.Xcode(access this by pressingShift+Command+Gin Finder and pasting the path).
5. Check for hidden filesystem duplicates
macOS’s case-insensitive filesystem can sometimes create hidden duplicate files, or references to files you can’t see in Finder:
- Open Terminal, navigate to your project directory with
cd /path/to/your/project. - Run
ls -lato show all files (including hidden ones) and search forInstructionBViewController.swift. If you see duplicate files (even with tiny case differences), delete the extra ones.
内容的提问来源于stack exchange,提问作者alfonso claros

