In order to stay under the 30 MB memory limit for widgets I'd like to profile the widget in the Simulator in Instruments. However, Instruments doesn’t start the profiling session with the error message: Unable to install app with path: …
All I did in Xcode: I created a fresh scheme for the widget target and selected "Profile".
Is this supposed to work?
Update:
As suggested by @lll in the comments, I tried to profile the host app, then attach Instruments to the Widget process. However, this fails as well, see screenshot. It might be because the Widget process only runs for a very short time.
Keep the Widget Alive Longer (Debug Build Trick)
In the widget’s code (under a #if DEBUG
check), add a small delay so Instruments has time to attach:
#if DEBUG _ = DispatchSemaphore(value: 0).wait(timeout: .now() + 30) #endif
Remove this workaround before shipping.