Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

iphone - '__strong' only applies to objective-c object or block pointer types; type here is XXX" warning

i get many warnings of type:

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

the warnings are pointing to framework headers. e.g NSNotification, NSURL, NSIndexset etc..

what are they and how can i repair it?

note 1: i use ARC

note 2: the app seems to work

edit 1: the warnings seems to originate from my pch file. which is:

//
// 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

edit 2: example of warning: warning in NSString.h point to:

/* 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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Amir's answer did not work for me, but it led me to a similar solution: make sure you also don't have a Frameworks path in your FRAMEWORK_SEARCH_PATHS in project settings or target settings. Mine had an entry that looked like this:

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

The symptom was that if I command-clicked Foundation/Foundation.h in my prefix.ch and then right clicked in the page->Show in Finder, it was in iPhoneOS.platform. But doing the same with Availability.h took me to iPhoneSimulator.platform.

So having some files including from each platform seems to have caused the __strong warnings and also some link errors where it said missing architecture i386, so I lost the ability to run inside iOS Simulator.

This bug took me 2 days to solve because that path had been in my target settings for months, but wasn't causing problems. Something about going to Xcode 6 revealed it, but not immediately, it just occurred spontaneously early this week when I was upgrading Google AdMob SDK and perhaps triggered a cache rebuild.

The particularly insidious thing about it was that trying to compile backups of my project also failed with the same error.

Let that sink in for a moment, and imagine the sense of impending doom.

I began to suspect hardware failures or a virus at that point, but luckily..

The bug was at the Xcode level, not the project level. Which leads me to believe it has something to do with SHARED_PRECOMPS_DIR, CACHE_ROOT or possibly /var/folders but by then I had upgraded to Yosemite out of sheer desperation and could not diff my hard drive against my Time Machine backup, which had Mavericks. In hindsight, that's where I blew it. That meant that I had to try a dozen other potential solutions involving PCH and other caches, none of which worked. Neither did deleting the project's derived data directories in:

~/Library/Developer/Xcode/DerivedData

(Which I had done based on this answer)

See also:

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

and:

Build Error - missing required architecture i386 in file

Specifically:

Sean Roehnelt's answer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...