How to append values in xcconfig variables?












42















I'm using Xcode and .xcconfig files. I'm trying to append some values in the preprocessor definitions, but I simply can't make it work.



I tried the following (as well as many variations of this), but no luck so far:



GCC_PREPROCESSOR_DEFINITIONS = '$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE'



The NEW_VALUE symbol is simply never added to the preprocessor definitions.



Does anyone had success appending new values to variables in xcconfig files?










share|improve this question





























    42















    I'm using Xcode and .xcconfig files. I'm trying to append some values in the preprocessor definitions, but I simply can't make it work.



    I tried the following (as well as many variations of this), but no luck so far:



    GCC_PREPROCESSOR_DEFINITIONS = '$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE'



    The NEW_VALUE symbol is simply never added to the preprocessor definitions.



    Does anyone had success appending new values to variables in xcconfig files?










    share|improve this question



























      42












      42








      42


      15






      I'm using Xcode and .xcconfig files. I'm trying to append some values in the preprocessor definitions, but I simply can't make it work.



      I tried the following (as well as many variations of this), but no luck so far:



      GCC_PREPROCESSOR_DEFINITIONS = '$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE'



      The NEW_VALUE symbol is simply never added to the preprocessor definitions.



      Does anyone had success appending new values to variables in xcconfig files?










      share|improve this question
















      I'm using Xcode and .xcconfig files. I'm trying to append some values in the preprocessor definitions, but I simply can't make it work.



      I tried the following (as well as many variations of this), but no luck so far:



      GCC_PREPROCESSOR_DEFINITIONS = '$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE'



      The NEW_VALUE symbol is simply never added to the preprocessor definitions.



      Does anyone had success appending new values to variables in xcconfig files?







      xcode xcconfig






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 15 '10 at 21:49









      cdespinosa

      18.7k53038




      18.7k53038










      asked Sep 8 '09 at 13:19









      Martin CoteMartin Cote

      21.2k126797




      21.2k126797
























          8 Answers
          8






          active

          oldest

          votes


















          31














          For reasons stated in other answers to this question, you can't inherit values easily.



          I recommend defining your settings in cascade. Let's assume APP is your project prefix and make this simple defining only a few CFLAGS:



          platform.xcconfig:



          APP_PLATFORM_CFLAGS = -DMAS=1


          project.xcconfig:



          #include "platform.xcconfig"
          APP_PROJECT_CFLAGS = -DBETA=1


          target-one.xcconfig:



          #include "project.xcconfig"
          APP_TARGET_CFLAGS = -DSUPER_COOL=1
          #include "merge.xcconfig"


          target-two.xcconfig:



          #include "project.xcconfig"
          APP_TARGET_CFLAGS = -DULTRA_COOL=1
          #include "merge.xcconfig"


          merge.xcconfig:



          OTHER_CFLAGS = $(inherited) $(APP_PLATFORM_CFLAGS) $(APP_PROJECT_CFLAGS) $(APP_TARGET_CFLAGS)


          Then, you'll base each of your targets build configurations on target-xxx.xcconfig. A real project will use more complex setups, using a configuration file for the project and a different one for the target, but you get the idea.



          Also, remember that $(inherited) refers to higher level in the hierarchy, not earlier. For instance, it inherits from Project level at Target level. Not sure if this apply to Xcode 4 too.



          This is a simplification of GTM, go there to learn more.






          share|improve this answer































            10














            According to the Xcode Build System Guide:




            When a configuration unit contains
            more than one definition for a
            particular build setting, Xcode uses
            the last definition in the unit. Keep
            in mind that configuration files do
            not have access to build setting
            definitions made in configuration
            files they include. That is, you
            cannot modify the definition made in
            an included configuration file; you
            can only replace it.




            So, I guess this mean that it is not possible to append values to a given variable.






            share|improve this answer

































              7














              This works:



              xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(value) NEW_VALUE'





              share|improve this answer





















              • 1





                Thanks, I simply use GCC_PREPROCESSOR_DEFINITIONS=$(value) NEW_VALUE though (no quotes).

                – mkeiser
                Nov 27 '13 at 21:17













              • Should be the accepted answer

                – Paul Beusterien
                Apr 25 '18 at 2:45



















              4














              There is another question with an answer that might help with this particular problem. It describes a technique that has each layer compose a subset of the definitions, then bring them all together at the leaf-level xcconfig.






              share|improve this answer

































                4














                I think I've stumbled on a slightly better approach while trying to integrate the Cocoapods xcconfig files into my own. I like to set the following in my projects



                GCC_PREPROCESSOR_DEFINITIONS = CONFIGURATION_$(CONFIGURATION)


                Unfortunately this conflicts with the definitions that comes with the Pods.xcconfig. As is stated elsewhere $(inherited) doesn't work as expected. What does work is the following



                GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)


                UPDATE:



                If you need to override a setting for a particular configuration then you'd be tempted to write something like



                GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)
                GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 CONFIGURATION_$(CONFIGURATION) $(inherited)


                Sadly this won't work BUT putting the second declaration into a file that only get's loaded by the Debug configuration will properly override setting.






                share|improve this answer


























                • The GCC_PREPROCESSOR_DEFINITIONS[config=*] = ... syntax works in Xcode 5. I used it in target-specific .xcconfig files to append centrally defined project-wide build settings to target-specific settings: BLA[config=*] = $(BLA_TARGET_SPECIFIC) $(BLA_PROJECT_WIDE).

                  – bassim
                  Sep 22 '14 at 19:23



















                3














                As stated in other answers, prior to Xcode 10, xcconfig files could not simply inherit and extend each other's values. But,



                Since Xcode 10, xcconfig now work as one might expect them to : $(inherited) actually expand to the previously defined value of the variable.




                When an .xcconfig file contains multiple assignments of the same build setting, later assignments using $(inherited) or $(<setting_name>) will inherit from earlier assignments in the .xcconfig. The legacy build system caused every use of $(inherited) or $(<setting_name>) to skip any other values defined within the .xcconfig. To detect whether your .xcconfig is affected by this improvement, running defaults write com.apple.dt.XCBuild EnableCompatibilityWarningsForXCBuildTransition -bool YES in Terminal will cause Xcode to generate a warning about this situation.




                (Xcode 10 beta 1 release notes)



                So for example, given two simple .xcconfig files:



                //  Generic.xcconfig
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_GENERIC_FLAG




                // Debug.xcconfig
                #include "Generic.xcconfig"
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG


                Assuming your project uses Debug.xcconfig for its Debug configuration, you'll get the expected value -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG for OTHER_SWIFT_FLAGS.



                (instead of just -DMY_DEBUG_FLAG in Xcode 9 and earlier releases)





                The new behavior is pretty straightforward: $(inherited) is simply replaced by the previously defined value of the variable, if any.



                So in the previous example, if we expand the #include statement, we'll get the following xcconfig file:



                // Merged xcconfig files after resolving #include
                OTHER_SWIFT_FLAGS = -DMY_GENERIC_FLAG
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG



                • On the first line OTHER_SWIFT_FLAGS value is -DMY_GENERIC_FLAG ($(inherited) expands to nothing, because this is the first definition of OTHER_SWIFT_FLAGS we encounter1).

                • On the second line OTHER_SWIFT_FLAGS if overwritten, and its value is now -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG (its previous value + the newly added flag).




                On a more complex xcconfig setup, things could look like this:



                //  First.xcconfig
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG




                // Second.xcconfig
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG




                // Last.xcconfig
                #include "Generic.xcconfig"
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG




                // Merge.xcconfig
                #include "First.xcconfig"
                #include "Second.xcconfig"
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                #include "Last.xcconfig"


                We'll assume this time we're using the Merge.xcconfig in our configuration.



                The resolved value for OTHER_SWIFT_FLAGS will then be -DMY_FIRST_FLAG -DMY_SECOND_FLAG -DMY_INTERMEDIATE_FLAG -DMY_LAST_FLAG.



                This might be surprising at first, but it actually makes sense: once the #include are resolved, we end up with this xcconfig:



                OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG


                The final resolved value is then the one defined on the last line, which is -DMY_LAST_FLAG plus the value it inherited from the previous line -DMY_INTERMEDIATE_FLAG etc etc.



                Note that naturally, if you forget $(inherited) in one of the definitions, you'll break the inheritance chain and only get the values from the bottom definitions, up the definition without $(inherited).





                1 One may expect the xcconfig file to inherit previous values defined at the Project level, but it doesn't seem to be the case





                📡 As of Xcode 10 beta 1, it seems the build settings editor doesn't properly resolve the correct value for variables defined in the xcconfig files, and displays the values as if resolved with the old pre-Xcode 10 behavior. I filed rdar://40873121 regarding this (https://openradar.appspot.com/radar?id=4925869923500032).






                share|improve this answer

































                  1














                  This works for me in Xcode 2.4.1:




                  GCC_PREPROCESSOR_DEFINITIONS = "$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE"


                  You do have to sometimes allow a few seconds between editing a config file and the change showing up in a target's Build Info.






                  share|improve this answer





















                  • 1





                    Not much luck with XCode 3.2 :(

                    – Martin Cote
                    Sep 9 '09 at 19:14



















                  0














                  You want to use the placeholder $(inherited) to represent the value inherited from lower levels, e.g.



                  GCC_PREPROCESSOR_DEFINITIONS = "$(inherited) NEW_VALUE"





                  share|improve this answer





















                  • 8





                    This looks like a perfect answer, but it’s wrong. $(inherited) doesn’t work within xcconfig files; in particular, you can’t use it to extend a definition from an included file.

                    – Jens Ayton
                    Mar 6 '11 at 12:35






                  • 2





                    then how do you extend?

                    – Van Du Tran
                    Sep 19 '13 at 15:45











                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "1"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1393987%2fhow-to-append-values-in-xcconfig-variables%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  8 Answers
                  8






                  active

                  oldest

                  votes








                  8 Answers
                  8






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  31














                  For reasons stated in other answers to this question, you can't inherit values easily.



                  I recommend defining your settings in cascade. Let's assume APP is your project prefix and make this simple defining only a few CFLAGS:



                  platform.xcconfig:



                  APP_PLATFORM_CFLAGS = -DMAS=1


                  project.xcconfig:



                  #include "platform.xcconfig"
                  APP_PROJECT_CFLAGS = -DBETA=1


                  target-one.xcconfig:



                  #include "project.xcconfig"
                  APP_TARGET_CFLAGS = -DSUPER_COOL=1
                  #include "merge.xcconfig"


                  target-two.xcconfig:



                  #include "project.xcconfig"
                  APP_TARGET_CFLAGS = -DULTRA_COOL=1
                  #include "merge.xcconfig"


                  merge.xcconfig:



                  OTHER_CFLAGS = $(inherited) $(APP_PLATFORM_CFLAGS) $(APP_PROJECT_CFLAGS) $(APP_TARGET_CFLAGS)


                  Then, you'll base each of your targets build configurations on target-xxx.xcconfig. A real project will use more complex setups, using a configuration file for the project and a different one for the target, but you get the idea.



                  Also, remember that $(inherited) refers to higher level in the hierarchy, not earlier. For instance, it inherits from Project level at Target level. Not sure if this apply to Xcode 4 too.



                  This is a simplification of GTM, go there to learn more.






                  share|improve this answer




























                    31














                    For reasons stated in other answers to this question, you can't inherit values easily.



                    I recommend defining your settings in cascade. Let's assume APP is your project prefix and make this simple defining only a few CFLAGS:



                    platform.xcconfig:



                    APP_PLATFORM_CFLAGS = -DMAS=1


                    project.xcconfig:



                    #include "platform.xcconfig"
                    APP_PROJECT_CFLAGS = -DBETA=1


                    target-one.xcconfig:



                    #include "project.xcconfig"
                    APP_TARGET_CFLAGS = -DSUPER_COOL=1
                    #include "merge.xcconfig"


                    target-two.xcconfig:



                    #include "project.xcconfig"
                    APP_TARGET_CFLAGS = -DULTRA_COOL=1
                    #include "merge.xcconfig"


                    merge.xcconfig:



                    OTHER_CFLAGS = $(inherited) $(APP_PLATFORM_CFLAGS) $(APP_PROJECT_CFLAGS) $(APP_TARGET_CFLAGS)


                    Then, you'll base each of your targets build configurations on target-xxx.xcconfig. A real project will use more complex setups, using a configuration file for the project and a different one for the target, but you get the idea.



                    Also, remember that $(inherited) refers to higher level in the hierarchy, not earlier. For instance, it inherits from Project level at Target level. Not sure if this apply to Xcode 4 too.



                    This is a simplification of GTM, go there to learn more.






                    share|improve this answer


























                      31












                      31








                      31







                      For reasons stated in other answers to this question, you can't inherit values easily.



                      I recommend defining your settings in cascade. Let's assume APP is your project prefix and make this simple defining only a few CFLAGS:



                      platform.xcconfig:



                      APP_PLATFORM_CFLAGS = -DMAS=1


                      project.xcconfig:



                      #include "platform.xcconfig"
                      APP_PROJECT_CFLAGS = -DBETA=1


                      target-one.xcconfig:



                      #include "project.xcconfig"
                      APP_TARGET_CFLAGS = -DSUPER_COOL=1
                      #include "merge.xcconfig"


                      target-two.xcconfig:



                      #include "project.xcconfig"
                      APP_TARGET_CFLAGS = -DULTRA_COOL=1
                      #include "merge.xcconfig"


                      merge.xcconfig:



                      OTHER_CFLAGS = $(inherited) $(APP_PLATFORM_CFLAGS) $(APP_PROJECT_CFLAGS) $(APP_TARGET_CFLAGS)


                      Then, you'll base each of your targets build configurations on target-xxx.xcconfig. A real project will use more complex setups, using a configuration file for the project and a different one for the target, but you get the idea.



                      Also, remember that $(inherited) refers to higher level in the hierarchy, not earlier. For instance, it inherits from Project level at Target level. Not sure if this apply to Xcode 4 too.



                      This is a simplification of GTM, go there to learn more.






                      share|improve this answer













                      For reasons stated in other answers to this question, you can't inherit values easily.



                      I recommend defining your settings in cascade. Let's assume APP is your project prefix and make this simple defining only a few CFLAGS:



                      platform.xcconfig:



                      APP_PLATFORM_CFLAGS = -DMAS=1


                      project.xcconfig:



                      #include "platform.xcconfig"
                      APP_PROJECT_CFLAGS = -DBETA=1


                      target-one.xcconfig:



                      #include "project.xcconfig"
                      APP_TARGET_CFLAGS = -DSUPER_COOL=1
                      #include "merge.xcconfig"


                      target-two.xcconfig:



                      #include "project.xcconfig"
                      APP_TARGET_CFLAGS = -DULTRA_COOL=1
                      #include "merge.xcconfig"


                      merge.xcconfig:



                      OTHER_CFLAGS = $(inherited) $(APP_PLATFORM_CFLAGS) $(APP_PROJECT_CFLAGS) $(APP_TARGET_CFLAGS)


                      Then, you'll base each of your targets build configurations on target-xxx.xcconfig. A real project will use more complex setups, using a configuration file for the project and a different one for the target, but you get the idea.



                      Also, remember that $(inherited) refers to higher level in the hierarchy, not earlier. For instance, it inherits from Project level at Target level. Not sure if this apply to Xcode 4 too.



                      This is a simplification of GTM, go there to learn more.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 13 '11 at 12:39









                      djromerodjromero

                      18.5k46366




                      18.5k46366

























                          10














                          According to the Xcode Build System Guide:




                          When a configuration unit contains
                          more than one definition for a
                          particular build setting, Xcode uses
                          the last definition in the unit. Keep
                          in mind that configuration files do
                          not have access to build setting
                          definitions made in configuration
                          files they include. That is, you
                          cannot modify the definition made in
                          an included configuration file; you
                          can only replace it.




                          So, I guess this mean that it is not possible to append values to a given variable.






                          share|improve this answer






























                            10














                            According to the Xcode Build System Guide:




                            When a configuration unit contains
                            more than one definition for a
                            particular build setting, Xcode uses
                            the last definition in the unit. Keep
                            in mind that configuration files do
                            not have access to build setting
                            definitions made in configuration
                            files they include. That is, you
                            cannot modify the definition made in
                            an included configuration file; you
                            can only replace it.




                            So, I guess this mean that it is not possible to append values to a given variable.






                            share|improve this answer




























                              10












                              10








                              10







                              According to the Xcode Build System Guide:




                              When a configuration unit contains
                              more than one definition for a
                              particular build setting, Xcode uses
                              the last definition in the unit. Keep
                              in mind that configuration files do
                              not have access to build setting
                              definitions made in configuration
                              files they include. That is, you
                              cannot modify the definition made in
                              an included configuration file; you
                              can only replace it.




                              So, I guess this mean that it is not possible to append values to a given variable.






                              share|improve this answer















                              According to the Xcode Build System Guide:




                              When a configuration unit contains
                              more than one definition for a
                              particular build setting, Xcode uses
                              the last definition in the unit. Keep
                              in mind that configuration files do
                              not have access to build setting
                              definitions made in configuration
                              files they include. That is, you
                              cannot modify the definition made in
                              an included configuration file; you
                              can only replace it.




                              So, I guess this mean that it is not possible to append values to a given variable.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Jan 15 '10 at 21:50









                              cdespinosa

                              18.7k53038




                              18.7k53038










                              answered Sep 9 '09 at 19:44









                              Martin CoteMartin Cote

                              21.2k126797




                              21.2k126797























                                  7














                                  This works:



                                  xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(value) NEW_VALUE'





                                  share|improve this answer





















                                  • 1





                                    Thanks, I simply use GCC_PREPROCESSOR_DEFINITIONS=$(value) NEW_VALUE though (no quotes).

                                    – mkeiser
                                    Nov 27 '13 at 21:17













                                  • Should be the accepted answer

                                    – Paul Beusterien
                                    Apr 25 '18 at 2:45
















                                  7














                                  This works:



                                  xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(value) NEW_VALUE'





                                  share|improve this answer





















                                  • 1





                                    Thanks, I simply use GCC_PREPROCESSOR_DEFINITIONS=$(value) NEW_VALUE though (no quotes).

                                    – mkeiser
                                    Nov 27 '13 at 21:17













                                  • Should be the accepted answer

                                    – Paul Beusterien
                                    Apr 25 '18 at 2:45














                                  7












                                  7








                                  7







                                  This works:



                                  xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(value) NEW_VALUE'





                                  share|improve this answer















                                  This works:



                                  xcodebuild GCC_PREPROCESSOR_DEFINITIONS='$(value) NEW_VALUE'






                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Sep 27 '12 at 21:04









                                  andrewsi

                                  10.7k112947




                                  10.7k112947










                                  answered Sep 27 '12 at 16:30









                                  Laxman BattiniLaxman Battini

                                  9111




                                  9111








                                  • 1





                                    Thanks, I simply use GCC_PREPROCESSOR_DEFINITIONS=$(value) NEW_VALUE though (no quotes).

                                    – mkeiser
                                    Nov 27 '13 at 21:17













                                  • Should be the accepted answer

                                    – Paul Beusterien
                                    Apr 25 '18 at 2:45














                                  • 1





                                    Thanks, I simply use GCC_PREPROCESSOR_DEFINITIONS=$(value) NEW_VALUE though (no quotes).

                                    – mkeiser
                                    Nov 27 '13 at 21:17













                                  • Should be the accepted answer

                                    – Paul Beusterien
                                    Apr 25 '18 at 2:45








                                  1




                                  1





                                  Thanks, I simply use GCC_PREPROCESSOR_DEFINITIONS=$(value) NEW_VALUE though (no quotes).

                                  – mkeiser
                                  Nov 27 '13 at 21:17







                                  Thanks, I simply use GCC_PREPROCESSOR_DEFINITIONS=$(value) NEW_VALUE though (no quotes).

                                  – mkeiser
                                  Nov 27 '13 at 21:17















                                  Should be the accepted answer

                                  – Paul Beusterien
                                  Apr 25 '18 at 2:45





                                  Should be the accepted answer

                                  – Paul Beusterien
                                  Apr 25 '18 at 2:45











                                  4














                                  There is another question with an answer that might help with this particular problem. It describes a technique that has each layer compose a subset of the definitions, then bring them all together at the leaf-level xcconfig.






                                  share|improve this answer






























                                    4














                                    There is another question with an answer that might help with this particular problem. It describes a technique that has each layer compose a subset of the definitions, then bring them all together at the leaf-level xcconfig.






                                    share|improve this answer




























                                      4












                                      4








                                      4







                                      There is another question with an answer that might help with this particular problem. It describes a technique that has each layer compose a subset of the definitions, then bring them all together at the leaf-level xcconfig.






                                      share|improve this answer















                                      There is another question with an answer that might help with this particular problem. It describes a technique that has each layer compose a subset of the definitions, then bring them all together at the leaf-level xcconfig.







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited May 23 '17 at 12:02









                                      Community

                                      11




                                      11










                                      answered Jan 15 '10 at 19:37









                                      fbreretofbrereto

                                      28.7k15111167




                                      28.7k15111167























                                          4














                                          I think I've stumbled on a slightly better approach while trying to integrate the Cocoapods xcconfig files into my own. I like to set the following in my projects



                                          GCC_PREPROCESSOR_DEFINITIONS = CONFIGURATION_$(CONFIGURATION)


                                          Unfortunately this conflicts with the definitions that comes with the Pods.xcconfig. As is stated elsewhere $(inherited) doesn't work as expected. What does work is the following



                                          GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)


                                          UPDATE:



                                          If you need to override a setting for a particular configuration then you'd be tempted to write something like



                                          GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)
                                          GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 CONFIGURATION_$(CONFIGURATION) $(inherited)


                                          Sadly this won't work BUT putting the second declaration into a file that only get's loaded by the Debug configuration will properly override setting.






                                          share|improve this answer


























                                          • The GCC_PREPROCESSOR_DEFINITIONS[config=*] = ... syntax works in Xcode 5. I used it in target-specific .xcconfig files to append centrally defined project-wide build settings to target-specific settings: BLA[config=*] = $(BLA_TARGET_SPECIFIC) $(BLA_PROJECT_WIDE).

                                            – bassim
                                            Sep 22 '14 at 19:23
















                                          4














                                          I think I've stumbled on a slightly better approach while trying to integrate the Cocoapods xcconfig files into my own. I like to set the following in my projects



                                          GCC_PREPROCESSOR_DEFINITIONS = CONFIGURATION_$(CONFIGURATION)


                                          Unfortunately this conflicts with the definitions that comes with the Pods.xcconfig. As is stated elsewhere $(inherited) doesn't work as expected. What does work is the following



                                          GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)


                                          UPDATE:



                                          If you need to override a setting for a particular configuration then you'd be tempted to write something like



                                          GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)
                                          GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 CONFIGURATION_$(CONFIGURATION) $(inherited)


                                          Sadly this won't work BUT putting the second declaration into a file that only get's loaded by the Debug configuration will properly override setting.






                                          share|improve this answer


























                                          • The GCC_PREPROCESSOR_DEFINITIONS[config=*] = ... syntax works in Xcode 5. I used it in target-specific .xcconfig files to append centrally defined project-wide build settings to target-specific settings: BLA[config=*] = $(BLA_TARGET_SPECIFIC) $(BLA_PROJECT_WIDE).

                                            – bassim
                                            Sep 22 '14 at 19:23














                                          4












                                          4








                                          4







                                          I think I've stumbled on a slightly better approach while trying to integrate the Cocoapods xcconfig files into my own. I like to set the following in my projects



                                          GCC_PREPROCESSOR_DEFINITIONS = CONFIGURATION_$(CONFIGURATION)


                                          Unfortunately this conflicts with the definitions that comes with the Pods.xcconfig. As is stated elsewhere $(inherited) doesn't work as expected. What does work is the following



                                          GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)


                                          UPDATE:



                                          If you need to override a setting for a particular configuration then you'd be tempted to write something like



                                          GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)
                                          GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 CONFIGURATION_$(CONFIGURATION) $(inherited)


                                          Sadly this won't work BUT putting the second declaration into a file that only get's loaded by the Debug configuration will properly override setting.






                                          share|improve this answer















                                          I think I've stumbled on a slightly better approach while trying to integrate the Cocoapods xcconfig files into my own. I like to set the following in my projects



                                          GCC_PREPROCESSOR_DEFINITIONS = CONFIGURATION_$(CONFIGURATION)


                                          Unfortunately this conflicts with the definitions that comes with the Pods.xcconfig. As is stated elsewhere $(inherited) doesn't work as expected. What does work is the following



                                          GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)


                                          UPDATE:



                                          If you need to override a setting for a particular configuration then you'd be tempted to write something like



                                          GCC_PREPROCESSOR_DEFINITIONS[config=*] = CONFIGURATION_$(CONFIGURATION) $(inherited)
                                          GCC_PREPROCESSOR_DEFINITIONS[config=Debug] = DEBUG=1 CONFIGURATION_$(CONFIGURATION) $(inherited)


                                          Sadly this won't work BUT putting the second declaration into a file that only get's loaded by the Debug configuration will properly override setting.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Aug 15 '14 at 16:32

























                                          answered Aug 14 '14 at 22:13









                                          James MooreJames Moore

                                          35926




                                          35926













                                          • The GCC_PREPROCESSOR_DEFINITIONS[config=*] = ... syntax works in Xcode 5. I used it in target-specific .xcconfig files to append centrally defined project-wide build settings to target-specific settings: BLA[config=*] = $(BLA_TARGET_SPECIFIC) $(BLA_PROJECT_WIDE).

                                            – bassim
                                            Sep 22 '14 at 19:23



















                                          • The GCC_PREPROCESSOR_DEFINITIONS[config=*] = ... syntax works in Xcode 5. I used it in target-specific .xcconfig files to append centrally defined project-wide build settings to target-specific settings: BLA[config=*] = $(BLA_TARGET_SPECIFIC) $(BLA_PROJECT_WIDE).

                                            – bassim
                                            Sep 22 '14 at 19:23

















                                          The GCC_PREPROCESSOR_DEFINITIONS[config=*] = ... syntax works in Xcode 5. I used it in target-specific .xcconfig files to append centrally defined project-wide build settings to target-specific settings: BLA[config=*] = $(BLA_TARGET_SPECIFIC) $(BLA_PROJECT_WIDE).

                                          – bassim
                                          Sep 22 '14 at 19:23





                                          The GCC_PREPROCESSOR_DEFINITIONS[config=*] = ... syntax works in Xcode 5. I used it in target-specific .xcconfig files to append centrally defined project-wide build settings to target-specific settings: BLA[config=*] = $(BLA_TARGET_SPECIFIC) $(BLA_PROJECT_WIDE).

                                          – bassim
                                          Sep 22 '14 at 19:23











                                          3














                                          As stated in other answers, prior to Xcode 10, xcconfig files could not simply inherit and extend each other's values. But,



                                          Since Xcode 10, xcconfig now work as one might expect them to : $(inherited) actually expand to the previously defined value of the variable.




                                          When an .xcconfig file contains multiple assignments of the same build setting, later assignments using $(inherited) or $(<setting_name>) will inherit from earlier assignments in the .xcconfig. The legacy build system caused every use of $(inherited) or $(<setting_name>) to skip any other values defined within the .xcconfig. To detect whether your .xcconfig is affected by this improvement, running defaults write com.apple.dt.XCBuild EnableCompatibilityWarningsForXCBuildTransition -bool YES in Terminal will cause Xcode to generate a warning about this situation.




                                          (Xcode 10 beta 1 release notes)



                                          So for example, given two simple .xcconfig files:



                                          //  Generic.xcconfig
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_GENERIC_FLAG




                                          // Debug.xcconfig
                                          #include "Generic.xcconfig"
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG


                                          Assuming your project uses Debug.xcconfig for its Debug configuration, you'll get the expected value -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG for OTHER_SWIFT_FLAGS.



                                          (instead of just -DMY_DEBUG_FLAG in Xcode 9 and earlier releases)





                                          The new behavior is pretty straightforward: $(inherited) is simply replaced by the previously defined value of the variable, if any.



                                          So in the previous example, if we expand the #include statement, we'll get the following xcconfig file:



                                          // Merged xcconfig files after resolving #include
                                          OTHER_SWIFT_FLAGS = -DMY_GENERIC_FLAG
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG



                                          • On the first line OTHER_SWIFT_FLAGS value is -DMY_GENERIC_FLAG ($(inherited) expands to nothing, because this is the first definition of OTHER_SWIFT_FLAGS we encounter1).

                                          • On the second line OTHER_SWIFT_FLAGS if overwritten, and its value is now -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG (its previous value + the newly added flag).




                                          On a more complex xcconfig setup, things could look like this:



                                          //  First.xcconfig
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG




                                          // Second.xcconfig
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG




                                          // Last.xcconfig
                                          #include "Generic.xcconfig"
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG




                                          // Merge.xcconfig
                                          #include "First.xcconfig"
                                          #include "Second.xcconfig"
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                                          #include "Last.xcconfig"


                                          We'll assume this time we're using the Merge.xcconfig in our configuration.



                                          The resolved value for OTHER_SWIFT_FLAGS will then be -DMY_FIRST_FLAG -DMY_SECOND_FLAG -DMY_INTERMEDIATE_FLAG -DMY_LAST_FLAG.



                                          This might be surprising at first, but it actually makes sense: once the #include are resolved, we end up with this xcconfig:



                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                                          OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG


                                          The final resolved value is then the one defined on the last line, which is -DMY_LAST_FLAG plus the value it inherited from the previous line -DMY_INTERMEDIATE_FLAG etc etc.



                                          Note that naturally, if you forget $(inherited) in one of the definitions, you'll break the inheritance chain and only get the values from the bottom definitions, up the definition without $(inherited).





                                          1 One may expect the xcconfig file to inherit previous values defined at the Project level, but it doesn't seem to be the case





                                          📡 As of Xcode 10 beta 1, it seems the build settings editor doesn't properly resolve the correct value for variables defined in the xcconfig files, and displays the values as if resolved with the old pre-Xcode 10 behavior. I filed rdar://40873121 regarding this (https://openradar.appspot.com/radar?id=4925869923500032).






                                          share|improve this answer






























                                            3














                                            As stated in other answers, prior to Xcode 10, xcconfig files could not simply inherit and extend each other's values. But,



                                            Since Xcode 10, xcconfig now work as one might expect them to : $(inherited) actually expand to the previously defined value of the variable.




                                            When an .xcconfig file contains multiple assignments of the same build setting, later assignments using $(inherited) or $(<setting_name>) will inherit from earlier assignments in the .xcconfig. The legacy build system caused every use of $(inherited) or $(<setting_name>) to skip any other values defined within the .xcconfig. To detect whether your .xcconfig is affected by this improvement, running defaults write com.apple.dt.XCBuild EnableCompatibilityWarningsForXCBuildTransition -bool YES in Terminal will cause Xcode to generate a warning about this situation.




                                            (Xcode 10 beta 1 release notes)



                                            So for example, given two simple .xcconfig files:



                                            //  Generic.xcconfig
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_GENERIC_FLAG




                                            // Debug.xcconfig
                                            #include "Generic.xcconfig"
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG


                                            Assuming your project uses Debug.xcconfig for its Debug configuration, you'll get the expected value -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG for OTHER_SWIFT_FLAGS.



                                            (instead of just -DMY_DEBUG_FLAG in Xcode 9 and earlier releases)





                                            The new behavior is pretty straightforward: $(inherited) is simply replaced by the previously defined value of the variable, if any.



                                            So in the previous example, if we expand the #include statement, we'll get the following xcconfig file:



                                            // Merged xcconfig files after resolving #include
                                            OTHER_SWIFT_FLAGS = -DMY_GENERIC_FLAG
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG



                                            • On the first line OTHER_SWIFT_FLAGS value is -DMY_GENERIC_FLAG ($(inherited) expands to nothing, because this is the first definition of OTHER_SWIFT_FLAGS we encounter1).

                                            • On the second line OTHER_SWIFT_FLAGS if overwritten, and its value is now -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG (its previous value + the newly added flag).




                                            On a more complex xcconfig setup, things could look like this:



                                            //  First.xcconfig
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG




                                            // Second.xcconfig
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG




                                            // Last.xcconfig
                                            #include "Generic.xcconfig"
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG




                                            // Merge.xcconfig
                                            #include "First.xcconfig"
                                            #include "Second.xcconfig"
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                                            #include "Last.xcconfig"


                                            We'll assume this time we're using the Merge.xcconfig in our configuration.



                                            The resolved value for OTHER_SWIFT_FLAGS will then be -DMY_FIRST_FLAG -DMY_SECOND_FLAG -DMY_INTERMEDIATE_FLAG -DMY_LAST_FLAG.



                                            This might be surprising at first, but it actually makes sense: once the #include are resolved, we end up with this xcconfig:



                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                                            OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG


                                            The final resolved value is then the one defined on the last line, which is -DMY_LAST_FLAG plus the value it inherited from the previous line -DMY_INTERMEDIATE_FLAG etc etc.



                                            Note that naturally, if you forget $(inherited) in one of the definitions, you'll break the inheritance chain and only get the values from the bottom definitions, up the definition without $(inherited).





                                            1 One may expect the xcconfig file to inherit previous values defined at the Project level, but it doesn't seem to be the case





                                            📡 As of Xcode 10 beta 1, it seems the build settings editor doesn't properly resolve the correct value for variables defined in the xcconfig files, and displays the values as if resolved with the old pre-Xcode 10 behavior. I filed rdar://40873121 regarding this (https://openradar.appspot.com/radar?id=4925869923500032).






                                            share|improve this answer




























                                              3












                                              3








                                              3







                                              As stated in other answers, prior to Xcode 10, xcconfig files could not simply inherit and extend each other's values. But,



                                              Since Xcode 10, xcconfig now work as one might expect them to : $(inherited) actually expand to the previously defined value of the variable.




                                              When an .xcconfig file contains multiple assignments of the same build setting, later assignments using $(inherited) or $(<setting_name>) will inherit from earlier assignments in the .xcconfig. The legacy build system caused every use of $(inherited) or $(<setting_name>) to skip any other values defined within the .xcconfig. To detect whether your .xcconfig is affected by this improvement, running defaults write com.apple.dt.XCBuild EnableCompatibilityWarningsForXCBuildTransition -bool YES in Terminal will cause Xcode to generate a warning about this situation.




                                              (Xcode 10 beta 1 release notes)



                                              So for example, given two simple .xcconfig files:



                                              //  Generic.xcconfig
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_GENERIC_FLAG




                                              // Debug.xcconfig
                                              #include "Generic.xcconfig"
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG


                                              Assuming your project uses Debug.xcconfig for its Debug configuration, you'll get the expected value -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG for OTHER_SWIFT_FLAGS.



                                              (instead of just -DMY_DEBUG_FLAG in Xcode 9 and earlier releases)





                                              The new behavior is pretty straightforward: $(inherited) is simply replaced by the previously defined value of the variable, if any.



                                              So in the previous example, if we expand the #include statement, we'll get the following xcconfig file:



                                              // Merged xcconfig files after resolving #include
                                              OTHER_SWIFT_FLAGS = -DMY_GENERIC_FLAG
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG



                                              • On the first line OTHER_SWIFT_FLAGS value is -DMY_GENERIC_FLAG ($(inherited) expands to nothing, because this is the first definition of OTHER_SWIFT_FLAGS we encounter1).

                                              • On the second line OTHER_SWIFT_FLAGS if overwritten, and its value is now -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG (its previous value + the newly added flag).




                                              On a more complex xcconfig setup, things could look like this:



                                              //  First.xcconfig
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG




                                              // Second.xcconfig
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG




                                              // Last.xcconfig
                                              #include "Generic.xcconfig"
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG




                                              // Merge.xcconfig
                                              #include "First.xcconfig"
                                              #include "Second.xcconfig"
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                                              #include "Last.xcconfig"


                                              We'll assume this time we're using the Merge.xcconfig in our configuration.



                                              The resolved value for OTHER_SWIFT_FLAGS will then be -DMY_FIRST_FLAG -DMY_SECOND_FLAG -DMY_INTERMEDIATE_FLAG -DMY_LAST_FLAG.



                                              This might be surprising at first, but it actually makes sense: once the #include are resolved, we end up with this xcconfig:



                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG


                                              The final resolved value is then the one defined on the last line, which is -DMY_LAST_FLAG plus the value it inherited from the previous line -DMY_INTERMEDIATE_FLAG etc etc.



                                              Note that naturally, if you forget $(inherited) in one of the definitions, you'll break the inheritance chain and only get the values from the bottom definitions, up the definition without $(inherited).





                                              1 One may expect the xcconfig file to inherit previous values defined at the Project level, but it doesn't seem to be the case





                                              📡 As of Xcode 10 beta 1, it seems the build settings editor doesn't properly resolve the correct value for variables defined in the xcconfig files, and displays the values as if resolved with the old pre-Xcode 10 behavior. I filed rdar://40873121 regarding this (https://openradar.appspot.com/radar?id=4925869923500032).






                                              share|improve this answer















                                              As stated in other answers, prior to Xcode 10, xcconfig files could not simply inherit and extend each other's values. But,



                                              Since Xcode 10, xcconfig now work as one might expect them to : $(inherited) actually expand to the previously defined value of the variable.




                                              When an .xcconfig file contains multiple assignments of the same build setting, later assignments using $(inherited) or $(<setting_name>) will inherit from earlier assignments in the .xcconfig. The legacy build system caused every use of $(inherited) or $(<setting_name>) to skip any other values defined within the .xcconfig. To detect whether your .xcconfig is affected by this improvement, running defaults write com.apple.dt.XCBuild EnableCompatibilityWarningsForXCBuildTransition -bool YES in Terminal will cause Xcode to generate a warning about this situation.




                                              (Xcode 10 beta 1 release notes)



                                              So for example, given two simple .xcconfig files:



                                              //  Generic.xcconfig
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_GENERIC_FLAG




                                              // Debug.xcconfig
                                              #include "Generic.xcconfig"
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG


                                              Assuming your project uses Debug.xcconfig for its Debug configuration, you'll get the expected value -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG for OTHER_SWIFT_FLAGS.



                                              (instead of just -DMY_DEBUG_FLAG in Xcode 9 and earlier releases)





                                              The new behavior is pretty straightforward: $(inherited) is simply replaced by the previously defined value of the variable, if any.



                                              So in the previous example, if we expand the #include statement, we'll get the following xcconfig file:



                                              // Merged xcconfig files after resolving #include
                                              OTHER_SWIFT_FLAGS = -DMY_GENERIC_FLAG
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_DEBUG_FLAG



                                              • On the first line OTHER_SWIFT_FLAGS value is -DMY_GENERIC_FLAG ($(inherited) expands to nothing, because this is the first definition of OTHER_SWIFT_FLAGS we encounter1).

                                              • On the second line OTHER_SWIFT_FLAGS if overwritten, and its value is now -DMY_GENERIC_FLAG -DMY_DEBUG_FLAG (its previous value + the newly added flag).




                                              On a more complex xcconfig setup, things could look like this:



                                              //  First.xcconfig
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG




                                              // Second.xcconfig
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG




                                              // Last.xcconfig
                                              #include "Generic.xcconfig"
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG




                                              // Merge.xcconfig
                                              #include "First.xcconfig"
                                              #include "Second.xcconfig"
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                                              #include "Last.xcconfig"


                                              We'll assume this time we're using the Merge.xcconfig in our configuration.



                                              The resolved value for OTHER_SWIFT_FLAGS will then be -DMY_FIRST_FLAG -DMY_SECOND_FLAG -DMY_INTERMEDIATE_FLAG -DMY_LAST_FLAG.



                                              This might be surprising at first, but it actually makes sense: once the #include are resolved, we end up with this xcconfig:



                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_FIRST_FLAG
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_SECOND_FLAG
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_INTERMEDIATE_FLAG
                                              OTHER_SWIFT_FLAGS = $(inherited) -DMY_LAST_FLAG


                                              The final resolved value is then the one defined on the last line, which is -DMY_LAST_FLAG plus the value it inherited from the previous line -DMY_INTERMEDIATE_FLAG etc etc.



                                              Note that naturally, if you forget $(inherited) in one of the definitions, you'll break the inheritance chain and only get the values from the bottom definitions, up the definition without $(inherited).





                                              1 One may expect the xcconfig file to inherit previous values defined at the Project level, but it doesn't seem to be the case





                                              📡 As of Xcode 10 beta 1, it seems the build settings editor doesn't properly resolve the correct value for variables defined in the xcconfig files, and displays the values as if resolved with the old pre-Xcode 10 behavior. I filed rdar://40873121 regarding this (https://openradar.appspot.com/radar?id=4925869923500032).







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Nov 21 '18 at 17:21

























                                              answered Jun 6 '18 at 23:34









                                              Guillaume AlgisGuillaume Algis

                                              7,87053261




                                              7,87053261























                                                  1














                                                  This works for me in Xcode 2.4.1:




                                                  GCC_PREPROCESSOR_DEFINITIONS = "$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE"


                                                  You do have to sometimes allow a few seconds between editing a config file and the change showing up in a target's Build Info.






                                                  share|improve this answer





















                                                  • 1





                                                    Not much luck with XCode 3.2 :(

                                                    – Martin Cote
                                                    Sep 9 '09 at 19:14
















                                                  1














                                                  This works for me in Xcode 2.4.1:




                                                  GCC_PREPROCESSOR_DEFINITIONS = "$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE"


                                                  You do have to sometimes allow a few seconds between editing a config file and the change showing up in a target's Build Info.






                                                  share|improve this answer





















                                                  • 1





                                                    Not much luck with XCode 3.2 :(

                                                    – Martin Cote
                                                    Sep 9 '09 at 19:14














                                                  1












                                                  1








                                                  1







                                                  This works for me in Xcode 2.4.1:




                                                  GCC_PREPROCESSOR_DEFINITIONS = "$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE"


                                                  You do have to sometimes allow a few seconds between editing a config file and the change showing up in a target's Build Info.






                                                  share|improve this answer















                                                  This works for me in Xcode 2.4.1:




                                                  GCC_PREPROCESSOR_DEFINITIONS = "$(GCC_PREPROCESSOR_DEFINITIONS) NEW_VALUE"


                                                  You do have to sometimes allow a few seconds between editing a config file and the change showing up in a target's Build Info.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited Sep 9 '09 at 12:13

























                                                  answered Sep 9 '09 at 10:11









                                                  Charles AndersonCharles Anderson

                                                  7,384124866




                                                  7,384124866








                                                  • 1





                                                    Not much luck with XCode 3.2 :(

                                                    – Martin Cote
                                                    Sep 9 '09 at 19:14














                                                  • 1





                                                    Not much luck with XCode 3.2 :(

                                                    – Martin Cote
                                                    Sep 9 '09 at 19:14








                                                  1




                                                  1





                                                  Not much luck with XCode 3.2 :(

                                                  – Martin Cote
                                                  Sep 9 '09 at 19:14





                                                  Not much luck with XCode 3.2 :(

                                                  – Martin Cote
                                                  Sep 9 '09 at 19:14











                                                  0














                                                  You want to use the placeholder $(inherited) to represent the value inherited from lower levels, e.g.



                                                  GCC_PREPROCESSOR_DEFINITIONS = "$(inherited) NEW_VALUE"





                                                  share|improve this answer





















                                                  • 8





                                                    This looks like a perfect answer, but it’s wrong. $(inherited) doesn’t work within xcconfig files; in particular, you can’t use it to extend a definition from an included file.

                                                    – Jens Ayton
                                                    Mar 6 '11 at 12:35






                                                  • 2





                                                    then how do you extend?

                                                    – Van Du Tran
                                                    Sep 19 '13 at 15:45
















                                                  0














                                                  You want to use the placeholder $(inherited) to represent the value inherited from lower levels, e.g.



                                                  GCC_PREPROCESSOR_DEFINITIONS = "$(inherited) NEW_VALUE"





                                                  share|improve this answer





















                                                  • 8





                                                    This looks like a perfect answer, but it’s wrong. $(inherited) doesn’t work within xcconfig files; in particular, you can’t use it to extend a definition from an included file.

                                                    – Jens Ayton
                                                    Mar 6 '11 at 12:35






                                                  • 2





                                                    then how do you extend?

                                                    – Van Du Tran
                                                    Sep 19 '13 at 15:45














                                                  0












                                                  0








                                                  0







                                                  You want to use the placeholder $(inherited) to represent the value inherited from lower levels, e.g.



                                                  GCC_PREPROCESSOR_DEFINITIONS = "$(inherited) NEW_VALUE"





                                                  share|improve this answer















                                                  You want to use the placeholder $(inherited) to represent the value inherited from lower levels, e.g.



                                                  GCC_PREPROCESSOR_DEFINITIONS = "$(inherited) NEW_VALUE"






                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited Mar 6 '11 at 12:33









                                                  Jens Ayton

                                                  14k32843




                                                  14k32843










                                                  answered Jan 15 '10 at 21:51









                                                  cdespinosacdespinosa

                                                  18.7k53038




                                                  18.7k53038








                                                  • 8





                                                    This looks like a perfect answer, but it’s wrong. $(inherited) doesn’t work within xcconfig files; in particular, you can’t use it to extend a definition from an included file.

                                                    – Jens Ayton
                                                    Mar 6 '11 at 12:35






                                                  • 2





                                                    then how do you extend?

                                                    – Van Du Tran
                                                    Sep 19 '13 at 15:45














                                                  • 8





                                                    This looks like a perfect answer, but it’s wrong. $(inherited) doesn’t work within xcconfig files; in particular, you can’t use it to extend a definition from an included file.

                                                    – Jens Ayton
                                                    Mar 6 '11 at 12:35






                                                  • 2





                                                    then how do you extend?

                                                    – Van Du Tran
                                                    Sep 19 '13 at 15:45








                                                  8




                                                  8





                                                  This looks like a perfect answer, but it’s wrong. $(inherited) doesn’t work within xcconfig files; in particular, you can’t use it to extend a definition from an included file.

                                                  – Jens Ayton
                                                  Mar 6 '11 at 12:35





                                                  This looks like a perfect answer, but it’s wrong. $(inherited) doesn’t work within xcconfig files; in particular, you can’t use it to extend a definition from an included file.

                                                  – Jens Ayton
                                                  Mar 6 '11 at 12:35




                                                  2




                                                  2





                                                  then how do you extend?

                                                  – Van Du Tran
                                                  Sep 19 '13 at 15:45





                                                  then how do you extend?

                                                  – Van Du Tran
                                                  Sep 19 '13 at 15:45


















                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f1393987%2fhow-to-append-values-in-xcconfig-variables%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  Costa Masnaga

                                                  Fotorealismo

                                                  Sidney Franklin