'__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)
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:
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:
(Which I had done based on this answer)
it seems i've solved it. for some reason i had a "Framework" folder with headers in my project local folder. removing that folder and the warnings are gone. i don't know how and why that folder was created. (i did not created it).
This is a wild guess : is your project using gcc ? If it is, try switching to clang