Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would you trace back the source of an imported framework?

With Xcode 4 and the iOS 6 SDK in order to make use of the classes in QuartzCore.framework you had to link against the QuartzCore.framework and #import <QuartzCore/QuartzCore.h>. This was fine and it made sense. I was happy with my view of the world :)

In Xcode 5 with the iOS 7 SDK the QuartzCore headers seem to be getting imported automatically. Using CA classes raises no warnings or linker errors.

My question is this:

Given that these headers are obviously being imported from somewhere and the library is being linked, how do I trace the source of the import and the linked framework? This is more just for my curiosity and to understand more about this process than to solve a specific problem.

Additional Information:

  • Modules are switched on (by default in Xcode 5) but @import is not being used in any of the code. However, switching Enable Modules (C and Objective-C) and Link Frameworks Automatically both to be "No" does not seem to require the #import of QuartzCore to compile.
  • Once modules are switched off, viewing Product | Perform Action | Preprocess shows the QuartzCore header in the preprocessed output. This explains why the code compiles, but not where it came from.
  • otool shows nothing of the QuartzCore framework in its output:

    $ otool -L Test 
    Test:
        /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics (compatibility version 64.0.0, current version 600.0.0)
        /System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 2903.2.0)
        /System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1047.20.0)
        /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
        /usr/lib/libSystem.dylib (compatibility version 1.0.0, current version 111.0.0)
    

Edited with a partial solution

  • I figured out the source of the #import at least. Checking through the iOS 7 UIKit headers, UISlider now includes an import of <QuartzCore/QuartzCore.h> which was not there in iOS 6. Mystery one solved, but the lack of linker errors is still curious.
like image 626
Dave Verwer Avatar asked Oct 15 '13 10:10

Dave Verwer


1 Answers

Looks like it is being linked by UIKit, possibly with LC_REEXPORT_DYLIB.

More information on this Twitter thread: https://twitter.com/daveverwer/status/390060215221354496

Running otool on UIKit.framework shows that it is linked.

$ otool -L UIKit 
UIKit:
    /System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 2380.17.0)
    /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/CoreVideo.framework/CoreVideo (compatibility version 1.2.0, current version 1.8.0)
    /System/Library/Frameworks/VideoToolbox.framework/VideoToolbox (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/PrivateFrameworks/MobileAsset.framework/MobileAsset (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/PrivateFrameworks/TelephonyUtilities.framework/TelephonyUtilities (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/PrivateFrameworks/WebBookmarks.framework/WebBookmarks (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/PrivateFrameworks/BackBoardServices.framework/BackBoardServices (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/PrivateFrameworks/XPCObjects.framework/XPCObjects (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 49.1.0)
    /System/Library/Frameworks/CoreImage.framework/CoreImage (compatibility version 1.0.0, current version 2.0.0)
    /System/Library/Frameworks/Security.framework/Security (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/PrivateFrameworks/DictionaryServices.framework/DictionaryServices (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 993.0.0)
    /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices (compatibility version 1.0.0, current version 14.0.0)
    /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics (compatibility version 64.0.0, current version 600.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation (compatibility version 150.0.0, current version 793.0.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
    /System/Library/Frameworks/ImageIO.framework/ImageIO (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/QuartzCore.framework/QuartzCore (compatibility version 1.2.0, current version 1.8.0)
    /System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/PrivateFrameworks/AppSupport.framework/AppSupport (compatibility version 1.0.0, current version 29.0.0)
    /System/Library/Frameworks/CoreText.framework/CoreText (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices (compatibility version 1.0.0, current version 40.0.0)
    /usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 9.6.0)
    /System/Library/PrivateFrameworks/WebKit.framework/WebKit (compatibility version 1.0.0, current version 536.26.0)
    /System/Library/PrivateFrameworks/WebCore.framework/WebCore (compatibility version 1.0.0, current version 536.26.0)
    /System/Library/PrivateFrameworks/ProofReader.framework/ProofReader (compatibility version 1.0.0, current version 180.0.0)
    /System/Library/Frameworks/CFNetwork.framework/CFNetwork (compatibility version 1.0.0, current version 609.1.4)
    /usr/lib/libAccessibility.dylib (compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/Accelerate.framework/Accelerate (compatibility version 1.0.0, current version 4.0.0)
    /System/Library/PrivateFrameworks/PrintKit.framework/PrintKit (compatibility version 1.0.0, current version 109.2.0)
    /usr/lib/libMobileGestalt.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
    /usr/lib/libSystem.dylib (compatibility version 1.0.0, current version 125.0.0)
like image 71
Dave Verwer Avatar answered Oct 20 '22 13:10

Dave Verwer