Instance variable declarations in implementation are inconsistent with interface

Thanks for AppCode, it's proving to be a very useful tool for iOS development.

It's my understanding that the new preferred way to declare instance variables in ObjC is within the class implementation, not the declaration, as in the following contrived example.  However, AppCode marks foo.m:3 as an error, indicating "Instance variable declarations in implementation are inconsistent with interface."  Moreover, some useful functionality is impaired.  For example, the auto-generation of instance variable declarations for properties insists on placing those declarations in the interface, forcing me to manually move them to the implementation.

Is there a current plan to bring AppCode up to date with respect to new ObjC coding standards?  In the mean time, is there a way to turn off that warning?

foo.h

1:  @interface Foo
2:  - (id)someMethod;
3:  @end

foo.m

1:  @implementation
2:  {
3:    id _instanceVariable;
4:  }
5:  
6:  - (id)someMethod
7:  {
8:    return _instanceVariable;
9:  }
10: @end
0
15 comments

AppCode will generate ivars in the implementation if your compiler is clang 3.0.
Please check that your Xcode is 4.2 and the compiler is set to "Apple clang".

0

Thanks for the reply Alexander. I double checked my project, and all three targets are set to use clang 3.0.

Any other suggestions?

I've also added a similar comment to OC-2484.

0

Thank you for the check. What's the version of your Xcode?

0

Xcode 4.2 Build 4D199

0

Sorry for the delay.
Could you please do one more check. If you type the following in the editor:

@interface Intf
@end

@implementation Intf
@end

@interface Intf() {
  int x;
}
@end



Are the instance variables in the category red (with the message "Category can't have superclass")? If AppCode shows the error, then it doesn't detect clang 3.0.
0

Yes, the instance variables are marked red, but the error is "Category can't have instance variables" rather than "Category can't have superclass".

0

OK, thank you. I meant "Category can't have instance variables", just copied the wrong error message :)
Which Xcode version is shown in "Preferences | Xcode" (last item in the list)?

0

4.2.1 (4D502)

I've upgraded to 4.2.1 since this thread started.

0

Did you have these problems with Xcode 4.2 (before you upgraded)?
Could you create the sample project with this problem and attach it here?

0

No, the problem seems to be specific to this project.  The same project opened on two different machines, even with different Xcode versions (4.2 & 4.2.1), exhibit the same problem.  If I create a new Xcode project, this problem does not occur.  Unfortunately, I can't post the project file in question -- but perhaps if you can tell me specifically what AppCode is looking for in my project file, I can examine my project file for problems.

0

Please execute the following on your project file:

cat <your project>.pbxproj | grep GCC


And send the output.
0

So, it appears that GCC_VERSION is not set if the compiler version is set to "Default Compiler", which is what I'm using.  (It actually displays as "Default Compiler (Apple LLVM compiler 3.0)").  So I think AppCode needs to be updated to make the same assumption that the Xcode build process is making - that a blank GCC_VERSION means to use the latest complier version.

I've verified that as a work-around, explicitly setting the compiler version does result in the expected behavior from AppCode.

                    GCC_DYNAMIC_NO_PIC = NO;
                    GCC_OPTIMIZATION_LEVEL = 0;
                    GCC_PRECOMPILE_PREFIX_HEADER = YES;
                    GCC_PREFIX_HEADER = Source/XXXX_Prefix.pch;
                    GCC_PRECOMPILE_PREFIX_HEADER = YES;
                    GCC_PREFIX_HEADER = Source/XXXX_Prefix.pch;
                    GCC_PRECOMPILE_PREFIX_HEADER = YES;
                    GCC_PREFIX_HEADER = Source/XXXX_Prefix.pch;
                    GCC_C_LANGUAGE_STANDARD = c99;
                    GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
                    GCC_WARN_ABOUT_RETURN_TYPE = YES;
                    GCC_WARN_UNUSED_VARIABLE = YES;
                    GCC_PRECOMPILE_PREFIX_HEADER = YES;
                    GCC_PREFIX_HEADER = Source/XXXX_Prefix.pch;
                    GCC_DYNAMIC_NO_PIC = NO;
                    GCC_OPTIMIZATION_LEVEL = 0;
                    GCC_PRECOMPILE_PREFIX_HEADER = YES;
                    GCC_PREFIX_HEADER = Source/XXXX_Prefix.pch;
                    GCC_PRECOMPILE_PREFIX_HEADER = YES;
                    GCC_PREFIX_HEADER = Source/XXXX_Prefix.pch;
                    GCC_C_LANGUAGE_STANDARD = gnu99;
                    GCC_DYNAMIC_NO_PIC = NO;
                    GCC_OPTIMIZATION_LEVEL = 0;
                    GCC_PRECOMPILE_PREFIX_HEADER = YES;
                    GCC_PREFIX_HEADER = "UISpecs/UISpecs-Prefix.pch";
                    GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
                    GCC_SYMBOLS_PRIVATE_EXTERN = NO;
                    GCC_VERSION = "";
                    GCC_C_LANGUAGE_STANDARD = gnu99;
                    GCC_PRECOMPILE_PREFIX_HEADER = YES;
                    GCC_PREFIX_HEADER = "UISpecs/UISpecs-Prefix.pch";
                    GCC_VERSION = "";
                    GCC_C_LANGUAGE_STANDARD = gnu99;
                    GCC_PRECOMPILE_PREFIX_HEADER = YES;
                    GCC_PREFIX_HEADER = "UISpecs/UISpecs-Prefix.pch";
                    GCC_VERSION = "";
                    GCC_C_LANGUAGE_STANDARD = c99;
                    GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
                    GCC_WARN_ABOUT_RETURN_TYPE = YES;
                    GCC_WARN_UNUSED_VARIABLE = YES;
                    GCC_C_LANGUAGE_STANDARD = c99;
                    GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
                    GCC_WARN_ABOUT_RETURN_TYPE = YES;
                    GCC_WARN_UNUSED_VARIABLE = YES;
0

Thank you for the investigation. We will issue the fix soon.

0

Please check the recent build - 1.0.2. Is the bug fixed for your project?

0

Yes it is.  Thanks for your help.

0

Please sign in to leave a comment.