MacOS Documentation for Structures in Security.h

I am trying to use the macOS framework Security.h

via Java and JNA. This means that I need to rebuild certain structures as Java classes.

The problem is that when I look at the docs for a structure ( this one , for example), all I see is a short description of the structure without mentioning its fields. Where can I get a complete description of the structure in the Apple documentation?

+3


source to share


1 answer


For a quick look, you can find the titles on Apple's open source site , but it's difficult to navigate, especially if the titles are in different places depending on the OS version you want to check. In all cases, I found it defined in SecBase.h

. For example , for the latest macOS .

And you get this:

typedef struct CF_BRIDGED_TYPE(id) SECTYPE(SecKeychainItem) *SecKeychainItemRef;

      

As such, you probably need other headers to keep track of the exact fields of the structure. The best way to do this is to install Xcode with frameworks for the required OS and you will get the headers on your local system. For example:

$ ls /Applications/Xcode.app/Contents/Developer/Platforms/*.platform/Developer/SDKs/*.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator9.2.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS2.2.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator2.2.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h

      

I don't have a good solution with online docs.

Another way, from memory, it would have been more useful for the task of recreating a structure in Java for JNA, would be to create a minimal C program (but I'm not sure how to do this on macOS, linking to security, perhaps you can) and pass gdb to print the structure of the structure with ptype

:



(gdb) whatis v
type = struct complex
(gdb) ptype v
type = struct complex {
    double real;
    double imag;
}

      

But, as noted in the comments, if we try it here, we get this:

(gdb) ptype SecKeychainItemRef
type = struct OpaqueSecKeychainItemRef {
  <incomplete type>
}

      

I'm afraid this symbol has voluntarily become opaque ... Confirmed by Brendan in the comments:

every macOS type I can think of ends in Ref

is an opaque type (really a pointer), only for functions

Here is a debug session with Xcode: Xcode screenshot

+3


source







All Articles