fast enumeration puzzlement

  • Here's a dead simple program:

      int main(int argc, char *argv[]) {

        NSMutableDictionary * D = [NSMutableDictionary  dictionaryWithCapacity:
    5 ];

        for (id key  in D) { }

        return 0;

      }
    Obviously, it won't do much, but here's the puzzle:
    I have the above main program in two projects, both open at the same time.
    One compiles and links OK;
    the other gives two compiler warnings:

    *  warning: Mac OS X version 10.5 or later is needed for use of
    foreach-collection-statement*

    *  warning: 'NSMutableDictionary' may not respond to
    '-countByEnumeratingWithState:objects:count:'*
    and a link error:

    *  Undefined symbols:*

    *  "_objc_enumerationMutation", referenced from: *

    *      _main in main.o*

    The project that works was recently created by making a new Project,
    a Cocoa application, and replacing the function 'main', nothing else.
    The other is a program I've been working on since pre-Leopard.

    I've compared the project settings for the two projects, but see no relevant
    differences.
    Any ideas, any one?
  • > *  warning: Mac OS X version 10.5 or later is needed for use of
    > foreach-collection-statement*

    This says to me that you're targeting a pre-10.5 SDK, rather than the
    current system.  Check your target's settings.

    Wade
  • On Dec 24, 2007, at 1:02 AM, Wade Tregaskis wrote:

    >> *  warning: Mac OS X version 10.5 or later is needed for use of
    >> foreach-collection-statement*
    >
    > This says to me that you're targeting a pre-10.5 SDK, rather than
    > the current system.

    Actually, it says that you have the Mac OS X Deployment Target set to
    something lower than 10.5.  Many developers set it to a lower value
    (e.g. 10.4 or 10.3) so their application will run on an earlier
    operating system, even though they are using features from a later one.

    The general rule is that the SDK specifies the most recent version of
    Mac OS X that you want to use features from, while the Mac OS X
    Deployment Target specifies the minimum version of Mac OS X that you
    want to run your software on.  If you don't specify a minimum, an SDK
    itself implies a minimum.

    I felt this needed spelling out again because I see a *lot* of people
    say things like "use the 10.3.9 SDK to run on 10.3.9," which isn't the
    case.

      -- Chris
  • Am 24.12.2007 um 12:45  schrieb Chris Hanson:
    > I felt this needed spelling out again because I see a *lot* of
    > people say things like "use the 10.3.9 SDK to run on 10.3.9," which
    > isn't the case.

    There's lots of additional settings which change depending on the SDK,
    though. For example GCC compiler version etc. Similarly, Objective C
    2.0 requires runtime support, i.e. in the compiler and libraries. So
    if he actually intended his project to still run before 10.5, the
    answer is "don't use ObjC 2.0 features".

    Cheers,
    -- M. Uli Kusterer
    "The Witnesses of TeachText are everywhere..."
    http://www.zathras.de
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today