XCode 9.3升级后Playground故障咨询:响应卡顿等问题如何解决?
Hey there, I’ve dealt with exactly these Playground issues when Xcode 9.3 first rolled out, so I can walk you through the known problems and fixes that worked for me and other devs:
Known Issues
Xcode 9.3 introduced several performance regressions in Playgrounds, especially when working with UIKit elements, animations, and dynamic layouts. These were acknowledged by Apple and partially addressed in subsequent minor updates, but there are solid workarounds for the 9.3 release itself.
Fixes to Try
Disable Auto Run
The Auto Run feature in 9.3 overreacts to UIKit code changes, spamming the renderer with constant updates and causing massive lag. To fix this:- Click the dropdown next to the play button in the top-right of your Playground
- Uncheck "Auto Run"
Run your code manually with the play button instead—this cuts down on unnecessary resource usage dramatically.
Clear Playground Cache Files
Cached data from old Playgrounds often gets corrupted in 9.3, leading to layout glitches and slowdowns. Here's how to clear it:- Close Xcode completely
- Open Terminal and run this command:
rm -rf ~/Library/Developer/Xcode/DerivedData/Playground* - Restart Xcode and open your Playground again. Most layout issues should resolve after this.
Simplify Your Playground Code
9.3's Playground engine struggles with complex, multi-element UI and concurrent animations. Try these tweaks:- Split large code blocks into smaller, focused snippets (you can use separate Playground pages for different components)
- Add
import PlaygroundSupportand setPlaygroundPage.current.needsIndefiniteExecution = true—this stabilizes the runloop, which fixes most animation timing bugs - Delay animation triggers with
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5)instead of running them immediately; this gives the Playground renderer time to initialize properly.
Downgrade to Xcode 9.2 (Emergency Workaround)
If nothing else works, you can keep both Xcode 9.2 and 9.3 installed:- Download the Xcode 9.2 DMG from Apple's developer archives
- Rename your existing Xcode app (e.g., "Xcode 9.3") in the Applications folder
- Install Xcode 9.2 as "Xcode" (or rename it to "Xcode 9.2")
This lets you switch back to a stable Playground environment while still using 9.3 for other projects.
内容的提问来源于stack exchange,提问作者Marmelador

