Problem when inheriting settings in xcconfig files

  • Hi everyone,

    I have a project which defines the build and target settings through
    xcconfig files. Now, I would like to define other linker flags in the
    top level root xcconfig file, and re-use these in other xcconfig files
    that includes this xcconfig file. Like...

    root.xcconfig:
    OTHER_LDFLAGS = -framework Carbon

    using_root_as_base.xcconfig:

    #include "root.xcconfig"
    OTHER_LDFLAGS = -framework Cocoa $(OTHER_LDFLAGS)

    Why doesn't the above work as expected? E.g. when I watch the output
    from the build process, the build setting that uses
    "using_root_as_base.xcconfig" only passes "-framework Cocoa" to the
    linker, instead of "-framework Cocoa -framework Carbon". I've seen
    examples floating around the internet that uses this format, are they
    wrong too, or is it something that has changed lately? If i _don't_
    define the OTHER_LDFLAGS in "using_root_as_base.xcconfig" the build
    log shows that the linker uses "-framework Carbon", as expected.

    I'm on Leopard, 10.5.1...

    Any ideas?

    Regards
    Mattias
  • On Dec 11, 2007 12:49 PM, Mattias Arrelid <mattias...> wrote:
    > Hi everyone,
    >
    > I have a project which defines the build and target settings through
    > xcconfig files. Now, I would like to define other linker flags in the
    > top level root xcconfig file, and re-use these in other xcconfig files
    > that includes this xcconfig file. Like...
    >
    > root.xcconfig:
    > OTHER_LDFLAGS = -framework Carbon
    >
    > using_root_as_base.xcconfig:
    >
    > #include "root.xcconfig"
    > OTHER_LDFLAGS = -framework Cocoa $(OTHER_LDFLAGS)
    >
    > Why doesn't the above work as expected? E.g. when I watch the output
    > from the build process, the build setting that uses
    > "using_root_as_base.xcconfig" only passes "-framework Cocoa" to the
    > linker, instead of "-framework Cocoa -framework Carbon". I've seen
    > examples floating around the internet that uses this format, are they
    > wrong too, or is it something that has changed lately? If i _don't_
    > define the OTHER_LDFLAGS in "using_root_as_base.xcconfig" the build
    > log shows that the linker uses "-framework Carbon", as expected.

    I'm not sure if that's supposed to work, but try

    OTHER_LDFLAGS = -framework Cocoa $(inherited)

    instead.

    Jon
  • Le 11 déc. 07 à 13:49, Mattias Arrelid a écrit :

    > Hi everyone,
    >
    > I have a project which defines the build and target settings through
    > xcconfig files. Now, I would like to define other linker flags in
    > the top level root xcconfig file, and re-use these in other xcconfig
    > files that includes this xcconfig file. Like...
    >
    > root.xcconfig:
    > OTHER_LDFLAGS = -framework Carbon
    >
    > using_root_as_base.xcconfig:
    >
    > #include "root.xcconfig"
    > OTHER_LDFLAGS = -framework Cocoa $(OTHER_LDFLAGS)
    >
    > Why doesn't the above work as expected? E.g. when I watch the output
    > from the build process, the build setting that uses
    > "using_root_as_base.xcconfig" only passes "-framework Cocoa" to the
    > linker, instead of "-framework Cocoa -framework Carbon". I've seen
    > examples floating around the internet that uses this format, are
    > they wrong too, or is it something that has changed lately? If i
    > _don't_ define the OTHER_LDFLAGS in "using_root_as_base.xcconfig"
    > the build log shows that the linker uses "-framework Carbon", as
    > expected.
    >
    > I'm on Leopard, 10.5.1...
    >
    > Any ideas?

    Try this.

    #include "root.xcconfig"
    OTHER_LDFLAGS = $(inherited) -framework Cocoa

    I don't remember where i discover this variable in the first place but
    it's really usefull.
  • On 11 dec 2007, at 13.55, Jonathan del Strother wrote:
    > On Dec 11, 2007 12:49 PM, Mattias Arrelid <mattias...> wrote:
    >> Hi everyone,
    >>
    >> I have a project which defines the build and target settings through
    >> xcconfig files. Now, I would like to define other linker flags in the
    >> top level root xcconfig file, and re-use these in other xcconfig
    >> files
    >> that includes this xcconfig file. Like...
    >>
    >> root.xcconfig:
    >> OTHER_LDFLAGS = -framework Carbon
    >>
    >> using_root_as_base.xcconfig:
    >>
    >> #include "root.xcconfig"
    >> OTHER_LDFLAGS = -framework Cocoa $(OTHER_LDFLAGS)
    >>
    >> Why doesn't the above work as expected? E.g. when I watch the output
    >> from the build process, the build setting that uses
    >> "using_root_as_base.xcconfig" only passes "-framework Cocoa" to the
    >> linker, instead of "-framework Cocoa -framework Carbon". I've seen
    >> examples floating around the internet that uses this format, are they
    >> wrong too, or is it something that has changed lately? If i _don't_
    >> define the OTHER_LDFLAGS in "using_root_as_base.xcconfig" the build
    >> log shows that the linker uses "-framework Carbon", as expected.
    >
    >
    > I'm not sure if that's supposed to work, but try
    >
    > OTHER_LDFLAGS = -framework Cocoa $(inherited)
    >
    > instead.
    >
    > Jon

    That doesn't seem to work - it gives the same result as when using $
    (SETTING_NAME), see:
    http://www.cocoabuilder.com/archive/message/xcode/2006/7/21/8357

    Could it be something else that gets in the way?

    / Mattias
  • On Dec 11, 2007, at 4:49 AM, Mattias Arrelid wrote:

    > I have a project which defines the build and target settings through
    > xcconfig files. Now, I would like to define other linker flags in
    > the top level root xcconfig file, and re-use these in other xcconfig
    > files that includes this xcconfig file. Like...

    This is an Xcode question and thus would be best asked on the xcode-
    users list.  Thanks.

    > root.xcconfig:
    > OTHER_LDFLAGS = -framework Carbon
    >
    > using_root_as_base.xcconfig:
    >
    > #include "root.xcconfig"
    > OTHER_LDFLAGS = -framework Cocoa $(OTHER_LDFLAGS)
    >
    > Why doesn't the above work as expected?

    Because each included xcconfig file doesn't define a "level" of
    configuration.  In other words, the #include directive is text-
    substitution just as it is in C, not file-referencing.  So your
    using_root_as_base.xcconfig is exactly equivalent to the following text:

    OTHER_LDFLAGS = -framework Carbon
    OTHER_LDFLAGS = -framework Cocoa $(OTHER_LDFLAGS)

    This defines OTHER_LDFLAGS, and then defines OTHER_LDFLAGS *again* to
    reference the value at the next level of the build settings stack.  It
    doesn't define two levels of build settings stack.

      -- Chris
  • On 12/12/07, Chris Hanson <cmh...> wrote:
    > On Dec 11, 2007, at 4:49 AM, Mattias Arrelid wrote:
    >
    >> I have a project which defines the build and target settings through
    >> xcconfig files. Now, I would like to define other linker flags in
    >> the top level root xcconfig file, and re-use these in other xcconfig
    >> files that includes this xcconfig file. Like...
    >
    > This is an Xcode question and thus would be best asked on the xcode-
    > users list.  Thanks.
    >
    >> root.xcconfig:
    >> OTHER_LDFLAGS = -framework Carbon
    >>
    >> using_root_as_base.xcconfig:
    >>
    >> #include "root.xcconfig"
    >> OTHER_LDFLAGS = -framework Cocoa $(OTHER_LDFLAGS)
    >>
    >> Why doesn't the above work as expected?
    >
    > Because each included xcconfig file doesn't define a "level" of
    > configuration.  In other words, the #include directive is text-
    > substitution just as it is in C, not file-referencing.  So your
    > using_root_as_base.xcconfig is exactly equivalent to the following text:
    >
    > OTHER_LDFLAGS = -framework Carbon
    > OTHER_LDFLAGS = -framework Cocoa $(OTHER_LDFLAGS)
    >
    > This defines OTHER_LDFLAGS, and then defines OTHER_LDFLAGS *again* to
    > reference the value at the next level of the build settings stack.  It
    > doesn't define two levels of build settings stack.
    >
    > -- Chris

    That seems reasonable. And thanks for pointing me in the xcode-users
    mailing list direction (never thought of such a list, how clumsy of
    me).

    Regards
    Mattias
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