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

前端 未结 2 1109
一个人的身影
一个人的身影 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.

提交回复
热议问题