5

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)
5
  • 1
    ...but you don't show us the code that causes the warning? Feb 24, 2012 at 12:41
  • its a lot of code, and as i said the warning is not about any code that i wrote.
    – amit
    Feb 24, 2012 at 12:43
  • 2
    Often the warnings are "paired": one in your code, one in the header to make it easy to find the matching type. Show us line of your code that triggers the warning. Feb 24, 2012 at 12:49
  • the only link to my code is myapp-Prefix.pch
    – amit
    Feb 24, 2012 at 12:56
  • Give some examples of what comes after "type here is..." Give some example lines on which the error occurs.
    – JeremyP
    Feb 24, 2012 at 13:54

3 Answers 3

7

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

3

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).

1
  • Thanks I had this issue. Apparently when I dragged frameworks from another project to my new project it created framework folders. Deleting them from disk fixed the issues.
    – Paul Solt
    Aug 15, 2012 at 22:06
0

This is a wild guess : is your project using gcc ? If it is, try switching to clang

1
  • I am also using clang, the solution provided by @amit above worked for me.
    – dassimon
    Aug 18, 2015 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.