gpt4 book ai didi

iphone - '__strong' 仅适用于 objective-c 对象或 block 指针类型;这里输入的是 XXX”警告

转载 作者:太空狗 更新时间:2023-10-30 03:49:04 26 4
gpt4 key购买 nike

我收到很多类型的警告:

'__strong' only applies to objective-c object or block pointer types; type here is...

警告指向框架 header 。例如 NSNotification、NSURL、NSIndexset 等。

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

注1:我用的是ARC

注意 2:该应用程序似乎可以运行

编辑 1:警告似乎源 self 的 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

编辑 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)

最佳答案

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

$(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/folders 有关,但到那时我出于绝望升级到优胜美地并且无法将我的硬盘驱动器与我的 Time Machine 备份进行比较,后者有 Mavericks。事后看来,这就是我搞砸的地方。这意味着我不得不尝试其他十几种涉及 PCH 和其他缓存的潜在解决方案,但都没有奏效。也没有删除项目的派生数据目录:

~/Library/Developer/Xcode/DerivedData

(这是我根据 this answer 做的)

另见:

Can't Build in Xcode 6 - ARC Issues in Apple Frameworks

和:

Build Error - missing required architecture i386 in file

具体来说:

Sean Roehnelt's answer

关于iphone - '__strong' 仅适用于 objective-c 对象或 block 指针类型;这里输入的是 XXX”警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9430933/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com