xcode4 parameter of incompatible type - ios

A project that runs fine on Xcode3, fails to compile on Xcode4 with this error:
file://localhost/users/Ishaq/Projects/game01/libs/cocos2d/CCLayer.m:
error: Semantic Issue: Sending 'ccColor4B' (aka 'struct _ccColor4B')
to parameter of incompatible type 'CIColor *'
the code that throws this error is below (from cocos2d-iphone CCLayer.m):
+ (id) layerWithColor:(ccColor4B)color
{
return [[[self alloc] initWithColor:color] autorelease];
}
Somehow Xcode thinks this code is calling - (id)initWithColor:(CIColor *)color; of CIImage (inside CIImage.h). How can I set Xcode's brain straight? ;-)

I've got the same problem. My resolution was to explicitly cast it proper type which helps the compiler to find the proper class. So the code looks like this:
return [[(CCColorLayer*)[self alloc] initWithColor:color] autorelease];

You could change self to the actual classname CCLayer which should point Xcode in the right direction.

The same thing happened for me when using the "LLVM GCC 4.2" compiler. Changing the compiler setting to "Apple LLVM Compiler 3.0" fixed it.

Related

iOS 11 SDK "Expected a type" Compile Error

I'm facing a strange "Expected a type" Error in Xcode 9.4.1 while compiling this project, which was once started as an objective-c project.
The file I'm looking at is an .h file, in a lib in the project. Normally this error was related to any messed up parentheses, but I can't see anything, nor has the file been touched since years.
#import "DDXMLDocument.h"
#interface DDXMLDocument (MKPAdditions)
- (id)initWithReadIO:(xmlInputReadCallback)ioread closeIO:(xmlInputCloseCallback)ioclose context:(void*)ioctx options:(NSUInteger)mask error:(NSError **)error;
#end
Can anyone explain what this error means?
As it is getting more weird for me,
I found another error which actually comes behind the one described above at build time:
DDXMLDocument *document = [[DDXMLDocument alloc] initWithReadIO:readCallback
closeIO:closeCallback
context:(__bridge void *)(inputStream)
options:0
error:nil];
Complete error description:
Implicit conversion of a non-Objective-C pointer type 'int (*)(void *, char *, int)' to 'id' is disallowed with ARC
So I assume it has something to do with the MAC Upgrade and the latest compiler version now used.
import missing, that was becoming necessary, all other errors have been follow up failures. --> close

Xcode 8 no warning for assigning NSString to NSInteger?

I'm not sure when this started but it seems like Xcode is not giving me type mismatch warnings/errors like it used to. For example, I just discovered a bug in my code where I was assigning the result of a method that returns NSString * to an NSInteger. The method prototype is correctly defined but the compiler gave no warning. Here is the code:
+ (NSString *)countryDialPrefix;
NSInteger prefix = [CountryCodes countryDialPrefix];
Here are the warnings set for all languages:
This was in "Other Warning Flags" at the Project level:
-w -Xanalyzer -analyzer-disable-checker -Xanalyzer unix
So I removed the -w and that fixed it.

Setting the line cap of a CAShapeLayer

I'm having a really weird error pop up when I try to run one line of code.
I have a subclass of CAShapeLayer, on which I am trying to set the line cap style. I want to use the round cap style, but when I add this code:
[self setLineCap: kCGLineCapRound];
The build fails and I get this error and warning:
Implicit conversion of 'int' to 'NSString *' is disallowed with ARC
Incompatible integer to pointer conversion sending 'int' to parameter of type 'NSString *'
But if I add this:
[self setLineCap: kCGLineCapButt];
It builds just fine. Why is it breaking on the other line cap type? Is this a problem/bug with Quartz?
Pertinent info.
iOS SDK 8.1
Xcode 6.1.1
Deployment Target iOS 7.0
CAShapeLayer uses kCALineCap*** which is a defined constant string in the CAShapeLayer.h file, and not a kCGLineCap*** which is part of an enum.

xCode 6 how to fix "Use of undeclared identifier" for automatic property synthesis?

I'm using xCode6 Beta 3, and am running into an issue where a code which previously compiled fine (xCode 5.1.1 or xCode6 beta 2) suddenly started to give me "Use of undeclared identifier" errors when accessing an automatically synthesized instance variable:
- (void)setFinished:(BOOL)finished {
[self willChangeValueForKey:#"isFinished"];
_finished = finished;
[self didChangeValueForKey:#"isFinished"];
}
//ERROR:
Use of undeclared identifier '_finished'; did you mean 'finished'?
Adding #synthesize finished = _finished; makes the error go away, but is there a way to force xCode6 Beta 3 to use automatic property synthesis using underscore notation?
At first I thought it was a beta version bug, but today I saw that this type of errors occur on the XCode 6 GM Seed also, though I'm yet to discover in which particular cases.
Anyway, the fix is to add a synthesize statement in the #implementation block, explicitly declaring the name of the ivar as well as the property:
#synthesize property = _property
If you have an explicit getter, automatic property synthesized will be ignored.
Then you have to use #synthesize property = _property
pod update
then your can now update to 3.7.1 that has fixed this bug.

incompatible pointer types: UIImage and UIImageView

Sprite *shipViewTemp = [[UIImageView alloc] initWithImage:(UIImage *) ship];
This is the only error in my code, can anyone help?
xcode says
incompatible pointer types
Check out the full error that Xcode is giving you. Generally, the error/warning will be telling you exactly what's wrong. In this case the full error is likely:
Incompatible pointer types initializing 'Sprite' with an expression of type 'UIImageView *'
In this case, it's telling you that you're trying to assign an instance of UIImageView to a variable that is expecting a Sprite. (In my screenshot below I used NSString, but you'd see something similar with Sprite.)

Resources