Creating an Xcode data formatter bundle for custom Obj-C objects

前端 未结 2 1110
一个人的身影
一个人的身影 2020-12-24 04:17

To help simplify debugging of some custom Objective-C objects in the Xcode debugger window, I\'ve created a set of data formatter strings for each of the objects, using the

相关标签:
2条回答
  • 2020-12-24 04:36

    I've recently been able to come back to this, and I believe I've found the answer.

    I already knew that a data formatter bundle must include the property list file internally, named "Contents/Resources/*.plist". However, for the bundle to actually work, it must also include an executable with the same name as the bundle in the Contents/MacOS/ directory. As far as I can tell, even a completely empty foo.c file is sufficient as long as you compile and link a binary. I didn't even have to touch the Info.plist for a stock CFPlugin Bundle project in Xcode, just include the CustomDataViews.plist in the target resources.

    Since I don't need to define C functions to display any of the objects and structs I'm dealing with, the far easier approach is to just put the plist file (any name will do — mine is CHDataStructures.plist) into one of two locations:

    • ~/Library/Application Support/Developer/Shared/Xcode/CustomDataViews/
    • /Library/Application Support/Developer/Shared/Xcode/CustomDataViews/

    Simple plist files are smaller, trivial to create, and easier to modify. Also, unlike when using bundles, I didn't have to relaunch Xcode when I added, removed, or modified the plist; just starting a new debugging session was sufficient to cause new the data formatters to be updated. I think I was only creating a bundle because that's what the sample code showed, but I can't determine any advantages for my scenario, so I'm sticking with the plist.

    0 讨论(0)
  • 2020-12-24 04:36

    As of Xcode 2.5 and 3.0, the locations for such things have changed to support multiple versions of Xcode coexisting on one system. You should put your custom data formatters into the directory "Library/Application Support/Developer/Shared/CustomDataViews" in either the local (/) or user (~) domain; then they should be available the next time you launch Xcode.

    The Shared in the path above can be a version number such as 3.0 or 3.1 if you're creating something specific to a particular Xcode version.

    0 讨论(0)
提交回复
热议问题