9

使用 Xcode 4 和 iOS 6 SDK 为了使用 QuartzCore.framework 中的类,您必须链接 QuartzCore.framework 和#import <QuartzCore/QuartzCore.h>. 这很好,而且很有意义。我对自己的世界观很满意 :)

在带有 iOS 7 SDK 的 Xcode 5 中,QuartzCore 标头似乎会自动导入。使用 CA 类不会引发警告或链接器错误。

我的问题是这样的:

鉴于这些标头显然是从某个地方导入的并且库正在被链接,我如何跟踪导入的源和链接的框架?这更多只是为了我的好奇心,并更多地了解这个过程,而不是解决特定问题。

附加信息:

  • 模块已打开(默认情况下在 Xcode 5 中)但 @import 未在任何代码中使用。但是,切换Enable Modules (C and Objective-C)Link Frameworks Automatically两者都为“否”似乎不需要 QuartzCore 的#import 来编译。
  • 关闭模块后,查看产品 | 执行操作 | Preprocess 在预处理输出中显示 QuartzCore 标头。这解释了为什么代码可以编译,但不能解释它的来源。
  • otool在其输出中没有显示任何 QuartzCore 框架:

    $ 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)
    

用部分解决方案编辑

  • 我至少弄清楚了#import 的来源。检查 iOS 7 UIKit 标头,UISlider 现在包含了一个<QuartzCore/QuartzCore.h>在 iOS 6 中没有的导入。谜团已解决,但缺少链接器错误仍然令人好奇。
4

1 回答 1

2

看起来它正在由 UIKit 链接,可能与 LC_REEXPORT_DYLIB 链接。

有关此 Twitter 线程的更多信息:https ://twitter.com/daveverwer/status/390060215221354496

在 UIKit.framework 上运行 otool 显示它是链接的。

$ 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)
于 2013-10-15T10:52:01.287 回答