I have a custom Xcode instrument that I (re)use all the time when profiling apps. My standard workflow is to:
- open the instrument’s project and run it (which fires up a Instruments debugging session); and then
- profile my target project, and see my custom instrument in action.
OK, that is fine.
But it is a hassle to do step 1 every time I want to profile an app. So, I saved it for future use with “File” » “Save As Template...” in Instruments.
But when try to use that template (while not running that separate Instrument project), I get an error. For macOS profiling sessions says:
[Instrument name] does not support the macOS platform.
Likewise, for iOS profiling sessions, it says:
[Instrument name] does not support the iOS platform.
Why is this? What do I need to do to specify on which platforms the custom instrument can be used?
I am using Xcode 13.0 (13A233) on Big Sur 11.6.
CodePudding user response:
It turns out that this error message, “does not support the [macOS/iOS] platform”, is misleading. In this case, the problem is not that it does not support the platform, but rather that the Instrument has not been properly installed at all.
To install a custom instrument so that it can be re-used at will, one should open the instrument’s project and perform “Product” » “Archive”, tap on “Distribute Content”, and then choose “Built Products”:
That builds an .instrdst
package. You can then double-click on that from the macOS Finder to install it:
Once it is installed, then you can again use templates to manage a collection of instruments that can be used during a profiling session, if you want. E.g., here is a profiling session using the installed custom instrument package, (in this example, illustrating how reader-writer pattern works):
But the key is that now that the custom instrument package has been installed, you can use it without needing to manually run the instrument in Xcode before profiling your app.
Please note that this solution for the “does not support the [macOS/iOS] platform” issue is unique to custom instruments. It should not be confused with instruments that might bear a legitimate limitations
as to which platforms it may be used. There are instruments that are only supported on particular platforms. But in the above scenario, the issue is that a custom instrument was not properly installed and the error message is simply misleading.