使用ARC编译时的ImageKit错误和警告

Sim*_*lli 3 cocoa imagekit automatic-ref-counting

我正在尝试将我的项目转换为ARC,但我在我的项目中使用ImageKit.ARC重构工具和我自己的手动重构都会在ImageKit头文件中使用ARC生成错误和警告,这些文件已包含在我自己的源文件中.它们看起来像这样:

In file included from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/ImageKit.h:9:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFController.h:12:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFOperation.m:10:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/IKImageBrowserView.h:176:14: error: the current deployment target does not support automated __weak references [4]
     IBOutlet __weak NSScroller*                   _horizontalScroller;
              ^
<built-in>:115:31: note: instantiated from:
 #define __weak __attribute__((objc_ownership(weak)))
                               ^
In file included from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/ImageKit.h:9:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFController.h:12:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFOperation.m:10:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/IKImageBrowserView.h:177:14: error: the current deployment target does not support automated __weak references [4]
     IBOutlet __weak id                            _delegate;
              ^
<built-in>:115:31: note: instantiated from:
 #define __weak __attribute__((objc_ownership(weak)))
                               ^
In file included from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/ImageKit.h:9:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFController.h:12:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFOperation.m:10:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/IKImageBrowserView.h:179:11: warning: '__strong' only applies to objective-c object or block pointer types; type here is 'void *' [3]
     void* __strong                                _reserved;
           ^
In file included from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/ImageKit.h:10:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFController.h:12:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFOperation.m:10:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/IKImageBrowserCell.h:36:2: error: the current deployment target does not support automated __weak references [4]
         __weak id                   _parent;
         ^
<built-in>:115:31: note: instantiated from:
 #define __weak __attribute__((objc_ownership(weak)))
                               ^
Run Code Online (Sandbox Code Playgroud)

那是我将项目设置设置为目标10.6的时候.当定位10.7时,我只是收到警告:

In file included from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/ImageKit.h:9:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFController.h:12:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFGenerator.m:12:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/IKImageBrowserView.h:179:11: warning: '__strong' only applies to objective-c object or block pointer types; type here is 'void *' [3]
     void* __strong                                _reserved;
           ^
In file included from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/ImageKit.h:10:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFController.h:12:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFGenerator.m:12:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/IKImageBrowserCell.h:37:8: warning: '__strong' only applies to objective-c object or block pointer types; type here is 'void *' [3]
         void* __strong              _ibCellReserved;
               ^
In file included from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/ImageKit.h:13:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFController.h:12:
In file included from /Volumes/Macintosh HD/Users/simone/Development/AFGenerator.m:12:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Headers/IKPictureTaker.h:31:11: warning: '__strong' only applies to objective-c object or block pointer types; type here is 'void *' [3]
     void *__strong _ikReserved;
           ^
3 warnings generated.
Run Code Online (Sandbox Code Playgroud)

但是,当使用ARC定位10.7时,我至少可以构建并运行我的程序.

这里发生了什么?这是正常的吗?或者ImageKit与ARC不兼容?

Sim*_*lli 5

事实证明,Xcode 4.2是barfing,因为我直接导入<ImageKit/ImageKit.h>,并且只在我的代码中链接了ImageKit框架.对于非ARC代码来说这很好,但ARC并不喜欢这样.

切换到导入<Quartz/Quartz.h>(其中包括ImageKit)并链接整个Quartz框架解决了这个问题.[更新:看起来你不必链接整个Quartz框架.将导入更改为<Quartz/Quartz.h>并保持直接链接ImageKit.

那真是怪了.