Separate build directory using xcodebuild











up vote
13
down vote

favorite
4












The man page for xcodebuild reads:




Run xcodebuild from the directory
containing your project (i.e. the
directory containing the
projectname.xcodeproj package).




I would like to keep my source directory (which is a Subversion external) clean and unmodified, and build my object files and executables to a location completely outside of the source directory.



Is there any way to build into a separate build directory from a terminal using xcodebuild like you can do with make tools or even msbuild on Windows?










share|improve this question




























    up vote
    13
    down vote

    favorite
    4












    The man page for xcodebuild reads:




    Run xcodebuild from the directory
    containing your project (i.e. the
    directory containing the
    projectname.xcodeproj package).




    I would like to keep my source directory (which is a Subversion external) clean and unmodified, and build my object files and executables to a location completely outside of the source directory.



    Is there any way to build into a separate build directory from a terminal using xcodebuild like you can do with make tools or even msbuild on Windows?










    share|improve this question


























      up vote
      13
      down vote

      favorite
      4









      up vote
      13
      down vote

      favorite
      4






      4





      The man page for xcodebuild reads:




      Run xcodebuild from the directory
      containing your project (i.e. the
      directory containing the
      projectname.xcodeproj package).




      I would like to keep my source directory (which is a Subversion external) clean and unmodified, and build my object files and executables to a location completely outside of the source directory.



      Is there any way to build into a separate build directory from a terminal using xcodebuild like you can do with make tools or even msbuild on Windows?










      share|improve this question















      The man page for xcodebuild reads:




      Run xcodebuild from the directory
      containing your project (i.e. the
      directory containing the
      projectname.xcodeproj package).




      I would like to keep my source directory (which is a Subversion external) clean and unmodified, and build my object files and executables to a location completely outside of the source directory.



      Is there any way to build into a separate build directory from a terminal using xcodebuild like you can do with make tools or even msbuild on Windows?







      macos xcodebuild






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 7 '15 at 16:44









      ctn

      2,450821




      2,450821










      asked Feb 11 '11 at 14:08









      Dave Mateer

      12.7k1077130




      12.7k1077130
























          5 Answers
          5






          active

          oldest

          votes

















          up vote
          24
          down vote



          accepted










          You can set build settings from the command line. The CONFIGURATION_BUILD_DIR will set the build directory. For example:



          xcodebuild -project YourProject.xcodeproj -configuration Debug -target All ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES CONFIGURATION_BUILD_DIR=../some/other/dir


          A reference is found on Apple's site:




          • Build Setting Reference






          share|improve this answer

















          • 4




            I found that I also needed to set CONFIGURATION_TEMP_DIR, and then this worked for me.
            – Brent Ramerth
            Feb 9 '13 at 21:40






          • 2




            You can just set BUILD_DIR and that will work too :D
            – David Hernandez
            Feb 8 '16 at 18:25




















          up vote
          5
          down vote













          To achieve complete separation the following build settings have to be changed (more than just CONFIGURATION_BUILD_DIR like accepted answer suggests), otherwise Xcode still builds some of its artifacts under its default build folder.



          On my machine Xcode normally builds everything to ./Build and ./DerivedData where current directory is one of my project.



          I wanted xcodebuild to build everything under Build-command-line folder so I used xcodebuild -scheme MyScheme -showBuildSettings | grep Build/ to find all build settings that correspond to all build paths and by trial-end-error I found "the generative" build settings that are enough to redirect all build artefacts produced by xcodebuild to custom folder.



          I ended up using the following command:



          BUILD_DIR=./Build-command-line
          DERIVED_DATA_DIR=$(BUILD_DIR)/DerivedData

          xcodebuild -project MyProject.xcodeproj
          -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=`sysctl -n hw.ncpu`
          -scheme MyScheme
          -sdk iphonesimulator
          -destination 'platform=iOS Simulator,name=iPhone 6S Plus,OS=latest'
          -xcconfig command-line-build.xcconfig
          -derivedDataPath $(DERIVED_DATA_DIR)
          test


          Where command-line-build.xcconfig is:



          HERE_BUILD=$(SRCROOT)/Build-command-line
          HERE_INTERMEDIATES=$(HERE_BUILD)/Intermediates

          // Paths
          // the following paths are enough to redirect everything to $HERE_BUILD
          MODULE_CACHE_DIR = $(HERE_BUILD)/DerivedData/ModuleCache
          OBJROOT = $(HERE_INTERMEDIATES)
          SHARED_PRECOMPS_DIR = $(HERE_INTERMEDIATES)/PrecompiledHeaders
          SYMROOT


          Note: Make sure you use absolute paths in your xcconfig, otherwise you may have error: Xcode crashing on startup “parentPath must be nil but it is not.



          I have written a post about this solution with a bit of background: xcodebuild: how to really change its build path.



          P.S. Of course this information is subject to change but as of Xcode Version 7.3.1 (7D1014) it works perfectly for me.






          share|improve this answer






























            up vote
            2
            down vote













            In my project, setting SYMROOT turned out to be sufficient to build the project in a different location, leaving other locations untouched.



            From Apple's Xcode Build Setting Reference (which I came across via another answer here, thanks!):




            SYMROOT (Build Products Path)



            Description: Directory path. Identifies the root of the directory hierarchy that contains product files and intermediate build files. Product and build files are placed in subdirectories of this directory.



            ...



            Affects: BUILT_PRODUCTS_DIR, CONFIGURATION_BUILD_DIR (...)




            This setting is also mentioned a few times in the xcodebuild man page:




            Available actions are:



            build: Build the target in the build root (SYMROOT)...



            clean: Remove build products and intermediate files from the build root (SYMROOT)....







            share|improve this answer





















            • If you want to redirect everything to a custom folder, at least OBJROOT is very important because quite a few of folders depend on it, not on SYMROOT. I have just checked Xcode 7.3.1 - MODULE_CACHE_DIR and SHARED_PRECOMPS_DIR are also independent of SYMROOT. So your answer will still build some stuff to default build directory however maybe that is enough for your task.
              – Stanislav Pankevich
              Jun 3 '16 at 9:49




















            up vote
            1
            down vote













            You should set the SYMROOT build setting to your desired location. All of the other relevant build settings are derived from it.






            share|improve this answer




























              up vote
              0
              down vote













              Xcode 10



              For a Workspace if you're using CocoaPods:



              xcodebuild -workspace youProject.xcworkspace -scheme yourScheme -sdk iphonesimulator -configuration Release SYMROOT=$(PWD)/build


              That will put your .app in ./build/Release-iphonesimulator






              share|improve this answer























                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',
                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%2f4969932%2fseparate-build-directory-using-xcodebuild%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                5 Answers
                5






                active

                oldest

                votes








                5 Answers
                5






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                24
                down vote



                accepted










                You can set build settings from the command line. The CONFIGURATION_BUILD_DIR will set the build directory. For example:



                xcodebuild -project YourProject.xcodeproj -configuration Debug -target All ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES CONFIGURATION_BUILD_DIR=../some/other/dir


                A reference is found on Apple's site:




                • Build Setting Reference






                share|improve this answer

















                • 4




                  I found that I also needed to set CONFIGURATION_TEMP_DIR, and then this worked for me.
                  – Brent Ramerth
                  Feb 9 '13 at 21:40






                • 2




                  You can just set BUILD_DIR and that will work too :D
                  – David Hernandez
                  Feb 8 '16 at 18:25

















                up vote
                24
                down vote



                accepted










                You can set build settings from the command line. The CONFIGURATION_BUILD_DIR will set the build directory. For example:



                xcodebuild -project YourProject.xcodeproj -configuration Debug -target All ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES CONFIGURATION_BUILD_DIR=../some/other/dir


                A reference is found on Apple's site:




                • Build Setting Reference






                share|improve this answer

















                • 4




                  I found that I also needed to set CONFIGURATION_TEMP_DIR, and then this worked for me.
                  – Brent Ramerth
                  Feb 9 '13 at 21:40






                • 2




                  You can just set BUILD_DIR and that will work too :D
                  – David Hernandez
                  Feb 8 '16 at 18:25















                up vote
                24
                down vote



                accepted







                up vote
                24
                down vote



                accepted






                You can set build settings from the command line. The CONFIGURATION_BUILD_DIR will set the build directory. For example:



                xcodebuild -project YourProject.xcodeproj -configuration Debug -target All ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES CONFIGURATION_BUILD_DIR=../some/other/dir


                A reference is found on Apple's site:




                • Build Setting Reference






                share|improve this answer












                You can set build settings from the command line. The CONFIGURATION_BUILD_DIR will set the build directory. For example:



                xcodebuild -project YourProject.xcodeproj -configuration Debug -target All ARCHS=x86_64 ONLY_ACTIVE_ARCH=YES CONFIGURATION_BUILD_DIR=../some/other/dir


                A reference is found on Apple's site:




                • Build Setting Reference







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 11 '11 at 15:00









                Dave Mateer

                12.7k1077130




                12.7k1077130








                • 4




                  I found that I also needed to set CONFIGURATION_TEMP_DIR, and then this worked for me.
                  – Brent Ramerth
                  Feb 9 '13 at 21:40






                • 2




                  You can just set BUILD_DIR and that will work too :D
                  – David Hernandez
                  Feb 8 '16 at 18:25
















                • 4




                  I found that I also needed to set CONFIGURATION_TEMP_DIR, and then this worked for me.
                  – Brent Ramerth
                  Feb 9 '13 at 21:40






                • 2




                  You can just set BUILD_DIR and that will work too :D
                  – David Hernandez
                  Feb 8 '16 at 18:25










                4




                4




                I found that I also needed to set CONFIGURATION_TEMP_DIR, and then this worked for me.
                – Brent Ramerth
                Feb 9 '13 at 21:40




                I found that I also needed to set CONFIGURATION_TEMP_DIR, and then this worked for me.
                – Brent Ramerth
                Feb 9 '13 at 21:40




                2




                2




                You can just set BUILD_DIR and that will work too :D
                – David Hernandez
                Feb 8 '16 at 18:25






                You can just set BUILD_DIR and that will work too :D
                – David Hernandez
                Feb 8 '16 at 18:25














                up vote
                5
                down vote













                To achieve complete separation the following build settings have to be changed (more than just CONFIGURATION_BUILD_DIR like accepted answer suggests), otherwise Xcode still builds some of its artifacts under its default build folder.



                On my machine Xcode normally builds everything to ./Build and ./DerivedData where current directory is one of my project.



                I wanted xcodebuild to build everything under Build-command-line folder so I used xcodebuild -scheme MyScheme -showBuildSettings | grep Build/ to find all build settings that correspond to all build paths and by trial-end-error I found "the generative" build settings that are enough to redirect all build artefacts produced by xcodebuild to custom folder.



                I ended up using the following command:



                BUILD_DIR=./Build-command-line
                DERIVED_DATA_DIR=$(BUILD_DIR)/DerivedData

                xcodebuild -project MyProject.xcodeproj
                -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=`sysctl -n hw.ncpu`
                -scheme MyScheme
                -sdk iphonesimulator
                -destination 'platform=iOS Simulator,name=iPhone 6S Plus,OS=latest'
                -xcconfig command-line-build.xcconfig
                -derivedDataPath $(DERIVED_DATA_DIR)
                test


                Where command-line-build.xcconfig is:



                HERE_BUILD=$(SRCROOT)/Build-command-line
                HERE_INTERMEDIATES=$(HERE_BUILD)/Intermediates

                // Paths
                // the following paths are enough to redirect everything to $HERE_BUILD
                MODULE_CACHE_DIR = $(HERE_BUILD)/DerivedData/ModuleCache
                OBJROOT = $(HERE_INTERMEDIATES)
                SHARED_PRECOMPS_DIR = $(HERE_INTERMEDIATES)/PrecompiledHeaders
                SYMROOT


                Note: Make sure you use absolute paths in your xcconfig, otherwise you may have error: Xcode crashing on startup “parentPath must be nil but it is not.



                I have written a post about this solution with a bit of background: xcodebuild: how to really change its build path.



                P.S. Of course this information is subject to change but as of Xcode Version 7.3.1 (7D1014) it works perfectly for me.






                share|improve this answer



























                  up vote
                  5
                  down vote













                  To achieve complete separation the following build settings have to be changed (more than just CONFIGURATION_BUILD_DIR like accepted answer suggests), otherwise Xcode still builds some of its artifacts under its default build folder.



                  On my machine Xcode normally builds everything to ./Build and ./DerivedData where current directory is one of my project.



                  I wanted xcodebuild to build everything under Build-command-line folder so I used xcodebuild -scheme MyScheme -showBuildSettings | grep Build/ to find all build settings that correspond to all build paths and by trial-end-error I found "the generative" build settings that are enough to redirect all build artefacts produced by xcodebuild to custom folder.



                  I ended up using the following command:



                  BUILD_DIR=./Build-command-line
                  DERIVED_DATA_DIR=$(BUILD_DIR)/DerivedData

                  xcodebuild -project MyProject.xcodeproj
                  -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=`sysctl -n hw.ncpu`
                  -scheme MyScheme
                  -sdk iphonesimulator
                  -destination 'platform=iOS Simulator,name=iPhone 6S Plus,OS=latest'
                  -xcconfig command-line-build.xcconfig
                  -derivedDataPath $(DERIVED_DATA_DIR)
                  test


                  Where command-line-build.xcconfig is:



                  HERE_BUILD=$(SRCROOT)/Build-command-line
                  HERE_INTERMEDIATES=$(HERE_BUILD)/Intermediates

                  // Paths
                  // the following paths are enough to redirect everything to $HERE_BUILD
                  MODULE_CACHE_DIR = $(HERE_BUILD)/DerivedData/ModuleCache
                  OBJROOT = $(HERE_INTERMEDIATES)
                  SHARED_PRECOMPS_DIR = $(HERE_INTERMEDIATES)/PrecompiledHeaders
                  SYMROOT


                  Note: Make sure you use absolute paths in your xcconfig, otherwise you may have error: Xcode crashing on startup “parentPath must be nil but it is not.



                  I have written a post about this solution with a bit of background: xcodebuild: how to really change its build path.



                  P.S. Of course this information is subject to change but as of Xcode Version 7.3.1 (7D1014) it works perfectly for me.






                  share|improve this answer

























                    up vote
                    5
                    down vote










                    up vote
                    5
                    down vote









                    To achieve complete separation the following build settings have to be changed (more than just CONFIGURATION_BUILD_DIR like accepted answer suggests), otherwise Xcode still builds some of its artifacts under its default build folder.



                    On my machine Xcode normally builds everything to ./Build and ./DerivedData where current directory is one of my project.



                    I wanted xcodebuild to build everything under Build-command-line folder so I used xcodebuild -scheme MyScheme -showBuildSettings | grep Build/ to find all build settings that correspond to all build paths and by trial-end-error I found "the generative" build settings that are enough to redirect all build artefacts produced by xcodebuild to custom folder.



                    I ended up using the following command:



                    BUILD_DIR=./Build-command-line
                    DERIVED_DATA_DIR=$(BUILD_DIR)/DerivedData

                    xcodebuild -project MyProject.xcodeproj
                    -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=`sysctl -n hw.ncpu`
                    -scheme MyScheme
                    -sdk iphonesimulator
                    -destination 'platform=iOS Simulator,name=iPhone 6S Plus,OS=latest'
                    -xcconfig command-line-build.xcconfig
                    -derivedDataPath $(DERIVED_DATA_DIR)
                    test


                    Where command-line-build.xcconfig is:



                    HERE_BUILD=$(SRCROOT)/Build-command-line
                    HERE_INTERMEDIATES=$(HERE_BUILD)/Intermediates

                    // Paths
                    // the following paths are enough to redirect everything to $HERE_BUILD
                    MODULE_CACHE_DIR = $(HERE_BUILD)/DerivedData/ModuleCache
                    OBJROOT = $(HERE_INTERMEDIATES)
                    SHARED_PRECOMPS_DIR = $(HERE_INTERMEDIATES)/PrecompiledHeaders
                    SYMROOT


                    Note: Make sure you use absolute paths in your xcconfig, otherwise you may have error: Xcode crashing on startup “parentPath must be nil but it is not.



                    I have written a post about this solution with a bit of background: xcodebuild: how to really change its build path.



                    P.S. Of course this information is subject to change but as of Xcode Version 7.3.1 (7D1014) it works perfectly for me.






                    share|improve this answer














                    To achieve complete separation the following build settings have to be changed (more than just CONFIGURATION_BUILD_DIR like accepted answer suggests), otherwise Xcode still builds some of its artifacts under its default build folder.



                    On my machine Xcode normally builds everything to ./Build and ./DerivedData where current directory is one of my project.



                    I wanted xcodebuild to build everything under Build-command-line folder so I used xcodebuild -scheme MyScheme -showBuildSettings | grep Build/ to find all build settings that correspond to all build paths and by trial-end-error I found "the generative" build settings that are enough to redirect all build artefacts produced by xcodebuild to custom folder.



                    I ended up using the following command:



                    BUILD_DIR=./Build-command-line
                    DERIVED_DATA_DIR=$(BUILD_DIR)/DerivedData

                    xcodebuild -project MyProject.xcodeproj
                    -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=`sysctl -n hw.ncpu`
                    -scheme MyScheme
                    -sdk iphonesimulator
                    -destination 'platform=iOS Simulator,name=iPhone 6S Plus,OS=latest'
                    -xcconfig command-line-build.xcconfig
                    -derivedDataPath $(DERIVED_DATA_DIR)
                    test


                    Where command-line-build.xcconfig is:



                    HERE_BUILD=$(SRCROOT)/Build-command-line
                    HERE_INTERMEDIATES=$(HERE_BUILD)/Intermediates

                    // Paths
                    // the following paths are enough to redirect everything to $HERE_BUILD
                    MODULE_CACHE_DIR = $(HERE_BUILD)/DerivedData/ModuleCache
                    OBJROOT = $(HERE_INTERMEDIATES)
                    SHARED_PRECOMPS_DIR = $(HERE_INTERMEDIATES)/PrecompiledHeaders
                    SYMROOT


                    Note: Make sure you use absolute paths in your xcconfig, otherwise you may have error: Xcode crashing on startup “parentPath must be nil but it is not.



                    I have written a post about this solution with a bit of background: xcodebuild: how to really change its build path.



                    P.S. Of course this information is subject to change but as of Xcode Version 7.3.1 (7D1014) it works perfectly for me.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 23 '17 at 12:17









                    Community

                    11




                    11










                    answered Feb 26 '16 at 22:13









                    Stanislav Pankevich

                    5,62364487




                    5,62364487






















                        up vote
                        2
                        down vote













                        In my project, setting SYMROOT turned out to be sufficient to build the project in a different location, leaving other locations untouched.



                        From Apple's Xcode Build Setting Reference (which I came across via another answer here, thanks!):




                        SYMROOT (Build Products Path)



                        Description: Directory path. Identifies the root of the directory hierarchy that contains product files and intermediate build files. Product and build files are placed in subdirectories of this directory.



                        ...



                        Affects: BUILT_PRODUCTS_DIR, CONFIGURATION_BUILD_DIR (...)




                        This setting is also mentioned a few times in the xcodebuild man page:




                        Available actions are:



                        build: Build the target in the build root (SYMROOT)...



                        clean: Remove build products and intermediate files from the build root (SYMROOT)....







                        share|improve this answer





















                        • If you want to redirect everything to a custom folder, at least OBJROOT is very important because quite a few of folders depend on it, not on SYMROOT. I have just checked Xcode 7.3.1 - MODULE_CACHE_DIR and SHARED_PRECOMPS_DIR are also independent of SYMROOT. So your answer will still build some stuff to default build directory however maybe that is enough for your task.
                          – Stanislav Pankevich
                          Jun 3 '16 at 9:49

















                        up vote
                        2
                        down vote













                        In my project, setting SYMROOT turned out to be sufficient to build the project in a different location, leaving other locations untouched.



                        From Apple's Xcode Build Setting Reference (which I came across via another answer here, thanks!):




                        SYMROOT (Build Products Path)



                        Description: Directory path. Identifies the root of the directory hierarchy that contains product files and intermediate build files. Product and build files are placed in subdirectories of this directory.



                        ...



                        Affects: BUILT_PRODUCTS_DIR, CONFIGURATION_BUILD_DIR (...)




                        This setting is also mentioned a few times in the xcodebuild man page:




                        Available actions are:



                        build: Build the target in the build root (SYMROOT)...



                        clean: Remove build products and intermediate files from the build root (SYMROOT)....







                        share|improve this answer





















                        • If you want to redirect everything to a custom folder, at least OBJROOT is very important because quite a few of folders depend on it, not on SYMROOT. I have just checked Xcode 7.3.1 - MODULE_CACHE_DIR and SHARED_PRECOMPS_DIR are also independent of SYMROOT. So your answer will still build some stuff to default build directory however maybe that is enough for your task.
                          – Stanislav Pankevich
                          Jun 3 '16 at 9:49















                        up vote
                        2
                        down vote










                        up vote
                        2
                        down vote









                        In my project, setting SYMROOT turned out to be sufficient to build the project in a different location, leaving other locations untouched.



                        From Apple's Xcode Build Setting Reference (which I came across via another answer here, thanks!):




                        SYMROOT (Build Products Path)



                        Description: Directory path. Identifies the root of the directory hierarchy that contains product files and intermediate build files. Product and build files are placed in subdirectories of this directory.



                        ...



                        Affects: BUILT_PRODUCTS_DIR, CONFIGURATION_BUILD_DIR (...)




                        This setting is also mentioned a few times in the xcodebuild man page:




                        Available actions are:



                        build: Build the target in the build root (SYMROOT)...



                        clean: Remove build products and intermediate files from the build root (SYMROOT)....







                        share|improve this answer












                        In my project, setting SYMROOT turned out to be sufficient to build the project in a different location, leaving other locations untouched.



                        From Apple's Xcode Build Setting Reference (which I came across via another answer here, thanks!):




                        SYMROOT (Build Products Path)



                        Description: Directory path. Identifies the root of the directory hierarchy that contains product files and intermediate build files. Product and build files are placed in subdirectories of this directory.



                        ...



                        Affects: BUILT_PRODUCTS_DIR, CONFIGURATION_BUILD_DIR (...)




                        This setting is also mentioned a few times in the xcodebuild man page:




                        Available actions are:



                        build: Build the target in the build root (SYMROOT)...



                        clean: Remove build products and intermediate files from the build root (SYMROOT)....








                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Mar 8 '16 at 9:39









                        Ashley

                        5,21011119




                        5,21011119












                        • If you want to redirect everything to a custom folder, at least OBJROOT is very important because quite a few of folders depend on it, not on SYMROOT. I have just checked Xcode 7.3.1 - MODULE_CACHE_DIR and SHARED_PRECOMPS_DIR are also independent of SYMROOT. So your answer will still build some stuff to default build directory however maybe that is enough for your task.
                          – Stanislav Pankevich
                          Jun 3 '16 at 9:49




















                        • If you want to redirect everything to a custom folder, at least OBJROOT is very important because quite a few of folders depend on it, not on SYMROOT. I have just checked Xcode 7.3.1 - MODULE_CACHE_DIR and SHARED_PRECOMPS_DIR are also independent of SYMROOT. So your answer will still build some stuff to default build directory however maybe that is enough for your task.
                          – Stanislav Pankevich
                          Jun 3 '16 at 9:49


















                        If you want to redirect everything to a custom folder, at least OBJROOT is very important because quite a few of folders depend on it, not on SYMROOT. I have just checked Xcode 7.3.1 - MODULE_CACHE_DIR and SHARED_PRECOMPS_DIR are also independent of SYMROOT. So your answer will still build some stuff to default build directory however maybe that is enough for your task.
                        – Stanislav Pankevich
                        Jun 3 '16 at 9:49






                        If you want to redirect everything to a custom folder, at least OBJROOT is very important because quite a few of folders depend on it, not on SYMROOT. I have just checked Xcode 7.3.1 - MODULE_CACHE_DIR and SHARED_PRECOMPS_DIR are also independent of SYMROOT. So your answer will still build some stuff to default build directory however maybe that is enough for your task.
                        – Stanislav Pankevich
                        Jun 3 '16 at 9:49












                        up vote
                        1
                        down vote













                        You should set the SYMROOT build setting to your desired location. All of the other relevant build settings are derived from it.






                        share|improve this answer

























                          up vote
                          1
                          down vote













                          You should set the SYMROOT build setting to your desired location. All of the other relevant build settings are derived from it.






                          share|improve this answer























                            up vote
                            1
                            down vote










                            up vote
                            1
                            down vote









                            You should set the SYMROOT build setting to your desired location. All of the other relevant build settings are derived from it.






                            share|improve this answer












                            You should set the SYMROOT build setting to your desired location. All of the other relevant build settings are derived from it.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 25 '17 at 23:05









                            Jeremy Huddleston Sequoia

                            18.6k46075




                            18.6k46075






















                                up vote
                                0
                                down vote













                                Xcode 10



                                For a Workspace if you're using CocoaPods:



                                xcodebuild -workspace youProject.xcworkspace -scheme yourScheme -sdk iphonesimulator -configuration Release SYMROOT=$(PWD)/build


                                That will put your .app in ./build/Release-iphonesimulator






                                share|improve this answer



























                                  up vote
                                  0
                                  down vote













                                  Xcode 10



                                  For a Workspace if you're using CocoaPods:



                                  xcodebuild -workspace youProject.xcworkspace -scheme yourScheme -sdk iphonesimulator -configuration Release SYMROOT=$(PWD)/build


                                  That will put your .app in ./build/Release-iphonesimulator






                                  share|improve this answer

























                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    Xcode 10



                                    For a Workspace if you're using CocoaPods:



                                    xcodebuild -workspace youProject.xcworkspace -scheme yourScheme -sdk iphonesimulator -configuration Release SYMROOT=$(PWD)/build


                                    That will put your .app in ./build/Release-iphonesimulator






                                    share|improve this answer














                                    Xcode 10



                                    For a Workspace if you're using CocoaPods:



                                    xcodebuild -workspace youProject.xcworkspace -scheme yourScheme -sdk iphonesimulator -configuration Release SYMROOT=$(PWD)/build


                                    That will put your .app in ./build/Release-iphonesimulator







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited yesterday

























                                    answered yesterday









                                    Guy Daher

                                    3,38632654




                                    3,38632654






























                                         

                                        draft saved


                                        draft discarded



















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4969932%2fseparate-build-directory-using-xcodebuild%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

                                        Volksrepublik China

                                        How to test boost logger output in unit testing?

                                        Write to the output between two pipeline