Xcode 9.2中旧项目Storyboard的ViewController加载异常求助
Hey there, let's work through this annoying Storyboard problem together—those tiny blue squares showing up instead of your actual ViewControllers are such a headache, especially with an older 3-year-old project in Xcode 9.2. Here are some practical, tested fixes to get your Storyboard rendering normally again:
Clean project cache & Derived Data
Start with the basics, as corrupted build artifacts often cause these glitches:- Go to Xcode's top menu >
Product>Clean(or use the shortcutCmd+Shift+K). - Delete your project's Derived Data: Open Xcode >
Preferences>Locations, click the arrow next to the Derived Data path to open the folder. Find your project's folder, delete it, then restart Xcode.
- Go to Xcode's top menu >
Verify Storyboard document settings
Select your Storyboard file, then check the right-hand Inspector panel:- In the Interface Builder Document section, make sure
Builds foris set to a version compatible with Xcode 9.2 (like your original project's target iOS version, e.g., iOS 8.0+). Avoid newer iOS versions that Xcode 9.2 doesn't fully support. - Double-check the
View asdropdown—sometimes selecting an unsupported device or size class can cause ViewControllers to render incorrectly as small squares.
- In the Interface Builder Document section, make sure
Inspect & repair the Storyboard's source code
Corrupted XML in the Storyboard file is a common culprit:- Right-click your Storyboard >
Open As>Source Code. - Look for red error markers, missing tags (like
<viewController>), or malformed XML. If you have a backup of your working project, compare the source code and replace any damaged sections. - If you can't pinpoint the issue, delete the problematic ViewController node from the source code, save the file, then re-open it as a Storyboard. You can then drag a new ViewController into the canvas and re-link your code and outlets.
- Right-click your Storyboard >
Reset Xcode's interface preferences
Sometimes Xcode's cached UI layout causes display bugs. Close Xcode completely, then open Terminal and run this command:defaults delete com.apple.dt.XcodeRestart Xcode afterward. Note: This resets all Xcode preferences (theme, shortcuts, etc.), so back up custom settings if needed.
Check dependencies & class associations
If your ViewController uses custom classes or third-party frameworks:- Go to your project's
Build Phases>Linked Frameworks and Libraries—make sure there are no red missing items. Re-add any missing frameworks if needed. - Confirm that the class name in your ViewController file matches exactly what's set in the Storyboard's Identity Inspector (Xcode 9.2 is case-sensitive, so even a capitalization mismatch can break rendering).
- Go to your project's
Give these steps a try in order—most of the time, cleaning Derived Data or fixing the Storyboard source code resolves this issue. If all else fails, try creating a new empty project in Xcode 9.2, then import your Storyboard and ViewController files to rule out project-wide configuration problems.
内容的提问来源于stack exchange,提问作者Shekhu

