使用ARC进行编译时出现ImageKit错误和警告

时间:2011-11-15 21:49:27

标签: cocoa automatic-ref-counting imagekit

我正在尝试将项目转换为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)))
                               ^

当我将项目设置设置为目标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.

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

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

1 个答案:

答案 0 :(得分:5)

原来,Xcode 4.2正在进行barfing,因为我正在导入&lt; ImageKit / ImageKit.h&gt;直接,并且只在我的代码中链接了ImageKit框架。对于非ARC代码来说这很好,但ARC并不喜欢这样。

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

这很奇怪。