objc-diff icon indicating copy to clipboard operation
objc-diff copied to clipboard

Improve support for comparing system SDKs

Open mattstevens opened this issue 11 years ago • 2 comments

There's interest in using the tool to diff SDK versions, this currently requires some hoop jumping as the frameworks to diff must be located outside of the SDK sysroot since declarations in system headers are automatically excluded. Provide a way to compare SDK versions in-place.

mattstevens avatar Jul 24 '14 19:07 mattstevens

If you want to do this immediately, here's how:

Copy the frameworks to a location outside of the SDK:

mkdir /tmp/{b3,b4}
cp -R /Applications/Xcode6-Beta3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/Frameworks/UIKit.framework /tmp/b3/
cp -R /Applications/Xcode6-Beta4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/Frameworks/UIKit.framework /tmp/b4/

Then specify the sysroot when comparing:

objc-diff \
--old /tmp/b3/UIKit.framework \
--new /tmp/b4/UIKit.framework \
--oldargs \
 -isysroot /Applications/Xcode6-Beta3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk \
--newargs \
 -isysroot /Applications/Xcode6-Beta4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk

mattstevens avatar Jul 24 '14 21:07 mattstevens

Version 0.3 supports the ability to diff platform SDKs in-place. Individual frameworks can be compared, as well as the entire SDK. The tool recognizes when a path is within an SDK and automatically uses the SDK as the sysroot if one is not explicitly specified via compiler arguments. For example, to compare two Mac SDKs only the following is needed:

objc-diff \
--old /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \
--new /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

There are a few limitations with the current implementation. The contents of /usr/include and Kernel.framework are excluded as these contain multiple modules, some of which require headers to be included in a specific order. A potential solution to this is to import module definitions rather than headers and extract the API that way. This would be a better solution for the tool in general if it works out.

The tool also does not detect relocations of symbols across frameworks, which happens fairly often in the platform SDKs as new frameworks are created or existing frameworks move between being sub-frameworks and regular frameworks. This should be possible to address by enhancing OCDAPIComparator to support an API made up of multiple translation units.

mattstevens avatar Jun 14 '17 06:06 mattstevens