4

I've been building my program in the "Debug X86-64" mode (Xcode 3.6) and everything works flawlessly. However, I just tried switching to "Release X86-64" mode and upon compiling received the following errors for each of my properties:

Synthesized property 'x' must either be named the same as a compatible ivar or must
explicitly name an ivar.

Where 'x' is one of my properties, the first being 'company' (I received 51 errors of this type.). In my .h interface file, I've listed the items this way:

@property (copy) NSString   *company,
                        *address1,
                        *address2,
                        *city,
                        *usState,
                        *zip,
                        *phone,
                        *fax,
                        *email,
                        *web; // etc, etc.

In my .M implementation file, I've synthesized them as so:

@synthesize company,
        address1,
        address2,
        city,
        usState,
        zip,
        phone,
        fax,
        email,
        web; // etc, etc.

My understanding was that the instance variables are automatically created for these properties... in fact, they seem to be working perfectly, up until I try to compile in "release" mode.

I couldn't find anything in the books I have to explain this. Am I doing something wrong, or more specifically, what should I include to fix this for "release" compiles?

Thanks!

Greg Steiner
  • 647
  • 1
  • 9
  • 20
  • 3
    OK, so I have just found another thread that seems to add more light to the subject: http://stackoverflow.com/questions/7110245/error-building-32-bit-os-x-app It has occurred to me that while I have a 64bit machine, I'm running OS 10.6.8... could this have something to do with it? Could the compiler be attempting to compile in 32bit mode? – Greg Steiner May 07 '12 at 03:46
  • 1
    I may be getting better at this, but I suspect I know how to fix it, though I need some confirmation. I found this thread: http://stackoverflow.com/questions/10043624/property-declaration-w-o-explicit-ivar-naming and I definitely did NOT declare the instance variables in the interface section, which currently looks like this: @interface DBContactRecord : NSObject { } I will attempt that next, but if someone can confirm, that would be most helpful :) – Greg Steiner May 07 '12 at 03:54
  • 2
    Your Xcode project's build settings will tell you whether you're building for 32-bit (i386) or 64 (x86_64). Incidentally, there is no such thing as “Xcode 3.6”. – Peter Hosey May 07 '12 at 04:06
  • Late night typo... I'm running Xcode version 3.2.6 :) – Greg Steiner May 07 '12 at 12:54

3 Answers3

2

There is another quick solution: also add those properties in the delegate definition

    @interface YourAppDelegate : NSObject <NSApplicationDelegate> {
      NSTextField * company;
      NSSlider * company;
         ...
     }

    @property (copy) NSString   *company,
                                *address1,
                                ... ;
sbillah
  • 136
  • 1
  • 6
1

I believe I have answered my own question here. I have done two things to correct these errors:

First, I've added instance variable declarations in the interface file. Second, I changed the @Synthesize directives to this:

@synthesize company = company;
@synthesize address1 = address1;
etc...

This has fixed all of the errors and everything compiles correctly in both build and release modes.

Greg Steiner
  • 647
  • 1
  • 9
  • 20
  • 3
    You don't need to explicitly specify the name of the variable if it's the same as the property's name. Better still would be to make it not be: Name the variable `_company` instead, so that you can't accidentally refer to it instead of the property by forgetting `self.`. – Peter Hosey May 07 '12 at 22:33
0

Disable 32-bit architecture in the build settings if you just want to release, but don't want to bother with "old" runtime limitations. (Actually what "new" runtime has finally got, was implemented in IBM SOM since 1991, so "old" and "new" are very relative when it comes to Objective-C runtime, but that's another story.)

OCTAGRAM
  • 618
  • 6
  • 12