'__strong'仅适用于objective-c对象或块指针类型; 在这里键入XXX"警告

ami*_*mit 5 iphone objective-c compiler-warnings automatic-ref-counting

我收到许多类型的警告:

'__strong'仅适用于objective-c对象或块指针类型; 这里输入的是......

警告指向框架标题.例如NSNotification,NSURL,NSIndexset等.

它们是什么,我该如何修复它?

注1:我使用ARC

注意2:该应用程序似乎工作

编辑1:警告似乎来自我的pch文件.这是:

//
// Prefix header for all source files of the 'myapp' target in the 'myapp' project
//

#import <Availability.h>

#ifndef __IPHONE_5_0
     #warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif
Run Code Online (Sandbox Code Playgroud)

编辑2:警告示例:NSString.h中的警告指向:

/* Methods to convert NSString to a NULL-terminated cString using the specified encoding.     Note, these are the "new" cString methods, and are not deprecated like the older cString     methods which do not take encoding arguments.
*/
- (__strong const char *)cStringUsingEncoding:(NSStringEncoding)encoding; //"Autoreleased"; NULL return if encoding conversion not possible; for performance reasons, lifetime of this should not be considered longer than the lifetime of the receiving string (if the receiver string is freed, this might go invalid then, before the end of the autorelease scope)
Run Code Online (Sandbox Code Playgroud)

Zac*_*ris 7

Amir的回答对我不起作用,但它让我得到了一个类似的解决方案:确保在项目设置或目标设置中FRAMEWORK_SEARCH_PATHS中没有Frameworks路径. 我有一个看起来像这样的条目:

$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks

症状是,如果我在prefix.ch中命令单击Foundation/Foundation.h然后右键单击页面 - >在Finder中显示,则它在iPhoneOS.platform中.但是使用Availability.h做同样的事情就把我带到了iPhoneSimulator.platform.

因此,包含来自每个平台的一些文件似乎已经导致__strong警告以及一些链接错误,其中它说缺少架构i386,所以我失去了在iOS模拟器中运行的能力.

这个错误花了我2天的时间来解决,因为该路径已经在我的目标设置中持续数月,但没有造成问题.关于去Xcode 6的事情揭示了它,但不是立即,它本周早些时候是在我升级Google AdMob SDK并且可能触发缓存重建时自发发生的.

关于它的特别阴险的是,尝试编译我的项目的备份也失败了同样的错误.

让它沉入片刻,想象即将到来的厄运感.

我开始怀疑硬件故障或病毒,但幸运的是......

该错误发生在Xcode级别,而不是项目级别.这让我相信它与SHARED_PRECOMPS_DIR,CACHE_ROOT或可能的/ var /文件夹有关,但到那时我已经完全升级到Yosemite绝望而且无法将我的硬盘驱动器与我的Time Machine备份区分开来,后者有Mavericks.事后来看,这就是我吹它的地方.这意味着我必须尝试其他涉及PCH和其他缓存的其他潜在解决方案,其中没有一个有效.也没有删除项目的派生数据目录:

〜/资源库/开发/ Xcode中/ DerivedData

(我根据这个答案做了什么)

也可以看看:

无法在Xcode 6中构建 - Apple框架中的ARC问题

和:

构建错误 - 缺少文件中所需的体系结构i386

特别:

Sean Roehnelt的回答


ami*_*mit 3

看来我已经解决了。由于某种原因,我的项目本地文件夹中有一个带有标题的“Framework”文件夹。删除该文件夹,警告就会消失。我不知道该文件夹是如何以及为何创建的。(我没有创建它)。