Stop Xcode 14 beta from draining your battery
There's a bug in Xcode 14 betas 4-6 that causes your CPU to go crazy and drain your battery. Here's a workaround.
Update: This also seems to resolve an issue where you could not test lock screen widgets on iOS 16 iPhone simulators.
Update 2: @NSBiscuit discovered a solution (see below) that doesn't require downloading an old simulator! 🙏🙏🙏
Update 3: The Xcode 14 RC is now out, and finally seems to have fixed this issue. There shouldn't be any reason to use the below technique anymore. Hurray! 🤩
There's a bug in Xcode 14 betas 4-6 that causes a crash loop in the PosterBoard process when you run an iOS 16 iPhone simulator, making your computer's CPU usage go sky high and battery to drain very quickly. Here's a workaround until Apple resolves the issue.
New Solution
Simply run the command:
/usr/libexec/PlistBuddy /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Library/Wallpaper/Collections/Collections.plist -c "add order array" -c "add order: string 23EC2CF1-0188-49FC-B214-EC1AB37FE5C4"
That's it! This will create a plist file in the iOS simulator runtime that will cause the simulator to detect the correct wallpaper, and fix the issue. All credit to @NSBiscuit for finding this solution! 🤩
Original Solution
- Download the iOS 15.5 simulator from Xcode by going to Xcode Preferences, selecting Platforms, tapping the + icon in the bottom left, and selecting iOS 15.5 Simulator.
2. Once downloaded, run the following command which will copy the Wallpaper
folder from the iOS 15.5 simulator into the iOS 16.0 simulator, and move the original aside:
mv /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Library/Wallpaper /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Library/Wallpaper-original && cp -r /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 15.5.simruntime/Contents/Resources/RuntimeRoot/Library/Wallpaper /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Library
3. That's it! As far as I can tell, you don't even need to restart the simulator. You should see your simulator's background turn from black to the iOS 15 default background, and your CPU usage go back down to normal within about a minute.
If you're still seeing high CPU usage, some people have said rebooting their Mac fixed the issue.
For those curious, I figured out this workround using a few tools.
- First I looked at Console.app for errors related to PosterBoard, as close to the crash as possible. I found an error message that referred to the above folder.
- I then ran
sudo fs_usage -w | grep PosterBoard
which will print out all the filesystem interactions related to PosterBoard. I found that the very last filesystem activity before the crash was also in that folder. - I looked at the PosterBoard crash reports in the "Crash Reports" section in Console.app, and found the crash was in
[[WKWallpaperRepresentingCollectionsManager _loadSystemWallpaperCollections]
. System wallpaper collections seems to be what was stored in the above folder.
So, all signs pointed to something being wrong with the contents of that folder. I tried a few things, including creating a Wallpapers~iphone.plist
file, which is conspicuously absent. But nothing seemed to work. So I tried simply copying the Wallpaper folder entirely from a previous iOS release, and voila! Problem solved. 😁