Why does Apollo fail to build in Xcode - There can only be one fragment named …?










0















Using:



  • Xcode 10.1

  • Apollo 1.9.2

  • CocoaPods 1.5.3

  • Latest build phase script from Apollo

During Xcode's build phase, when it executes the Apollo GraphQL API script, I get errors for duplicate fragments and operations, a-la:



"There can only be one fragment named..."


or



"There can only be one operation named..."


and the project will refuse to build.



Cleaning the build folder will allow you to build or run the project once more before the errors come back.










share|improve this question


























    0















    Using:



    • Xcode 10.1

    • Apollo 1.9.2

    • CocoaPods 1.5.3

    • Latest build phase script from Apollo

    During Xcode's build phase, when it executes the Apollo GraphQL API script, I get errors for duplicate fragments and operations, a-la:



    "There can only be one fragment named..."


    or



    "There can only be one operation named..."


    and the project will refuse to build.



    Cleaning the build folder will allow you to build or run the project once more before the errors come back.










    share|improve this question
























      0












      0








      0








      Using:



      • Xcode 10.1

      • Apollo 1.9.2

      • CocoaPods 1.5.3

      • Latest build phase script from Apollo

      During Xcode's build phase, when it executes the Apollo GraphQL API script, I get errors for duplicate fragments and operations, a-la:



      "There can only be one fragment named..."


      or



      "There can only be one operation named..."


      and the project will refuse to build.



      Cleaning the build folder will allow you to build or run the project once more before the errors come back.










      share|improve this question














      Using:



      • Xcode 10.1

      • Apollo 1.9.2

      • CocoaPods 1.5.3

      • Latest build phase script from Apollo

      During Xcode's build phase, when it executes the Apollo GraphQL API script, I get errors for duplicate fragments and operations, a-la:



      "There can only be one fragment named..."


      or



      "There can only be one operation named..."


      and the project will refuse to build.



      Cleaning the build folder will allow you to build or run the project once more before the errors come back.







      xcode apollo






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 23:23









      cntrlzcntrlz

      464




      464






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The issue is that the bash find command is finding duplicate files in a local DerivedData/ directory! This is caused when:



          • You have the DerivedData/ directory set to Relative in Xcode

          • You're using the default build phase script provided by Apollo


          Change your build phase script for Apollo from this:



          $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift



          to this:



          $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift




          The Details:



          • If you don't care where your Derived Data goes, change the Location setting from Relative to Default (or any directory Apollo is not looking in). You can find the setting here: Xcode > Preferences > Locations > Derived Data

          • If you would rather keep your Derived Data where it is, alter the bash find command in the query passed to apollo-cli to exclude the DerivedData/ folder by appending -not -path "*DerivedData/*". You can find the script by going to Project Root > (Target Project) > Build Phases > Generate Apollo GraphQL API, (which you should have added during the installation steps, see here). Make it look like this:
            $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift

          You might need to delete the DerivedData/ folder one last time from your project folder, and it doesn't hurt to do one last clean (Command + Shift + K).






          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',
            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%2f53290954%2fwhy-does-apollo-fail-to-build-in-xcode-there-can-only-be-one-fragment-named%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The issue is that the bash find command is finding duplicate files in a local DerivedData/ directory! This is caused when:



            • You have the DerivedData/ directory set to Relative in Xcode

            • You're using the default build phase script provided by Apollo


            Change your build phase script for Apollo from this:



            $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift



            to this:



            $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift




            The Details:



            • If you don't care where your Derived Data goes, change the Location setting from Relative to Default (or any directory Apollo is not looking in). You can find the setting here: Xcode > Preferences > Locations > Derived Data

            • If you would rather keep your Derived Data where it is, alter the bash find command in the query passed to apollo-cli to exclude the DerivedData/ folder by appending -not -path "*DerivedData/*". You can find the script by going to Project Root > (Target Project) > Build Phases > Generate Apollo GraphQL API, (which you should have added during the installation steps, see here). Make it look like this:
              $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift

            You might need to delete the DerivedData/ folder one last time from your project folder, and it doesn't hurt to do one last clean (Command + Shift + K).






            share|improve this answer



























              0














              The issue is that the bash find command is finding duplicate files in a local DerivedData/ directory! This is caused when:



              • You have the DerivedData/ directory set to Relative in Xcode

              • You're using the default build phase script provided by Apollo


              Change your build phase script for Apollo from this:



              $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift



              to this:



              $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift




              The Details:



              • If you don't care where your Derived Data goes, change the Location setting from Relative to Default (or any directory Apollo is not looking in). You can find the setting here: Xcode > Preferences > Locations > Derived Data

              • If you would rather keep your Derived Data where it is, alter the bash find command in the query passed to apollo-cli to exclude the DerivedData/ folder by appending -not -path "*DerivedData/*". You can find the script by going to Project Root > (Target Project) > Build Phases > Generate Apollo GraphQL API, (which you should have added during the installation steps, see here). Make it look like this:
                $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift

              You might need to delete the DerivedData/ folder one last time from your project folder, and it doesn't hurt to do one last clean (Command + Shift + K).






              share|improve this answer

























                0












                0








                0







                The issue is that the bash find command is finding duplicate files in a local DerivedData/ directory! This is caused when:



                • You have the DerivedData/ directory set to Relative in Xcode

                • You're using the default build phase script provided by Apollo


                Change your build phase script for Apollo from this:



                $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift



                to this:



                $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift




                The Details:



                • If you don't care where your Derived Data goes, change the Location setting from Relative to Default (or any directory Apollo is not looking in). You can find the setting here: Xcode > Preferences > Locations > Derived Data

                • If you would rather keep your Derived Data where it is, alter the bash find command in the query passed to apollo-cli to exclude the DerivedData/ folder by appending -not -path "*DerivedData/*". You can find the script by going to Project Root > (Target Project) > Build Phases > Generate Apollo GraphQL API, (which you should have added during the installation steps, see here). Make it look like this:
                  $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift

                You might need to delete the DerivedData/ folder one last time from your project folder, and it doesn't hurt to do one last clean (Command + Shift + K).






                share|improve this answer













                The issue is that the bash find command is finding duplicate files in a local DerivedData/ directory! This is caused when:



                • You have the DerivedData/ directory set to Relative in Xcode

                • You're using the default build phase script provided by Apollo


                Change your build phase script for Apollo from this:



                $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql')" --schema=schema.json API.swift



                to this:



                $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift




                The Details:



                • If you don't care where your Derived Data goes, change the Location setting from Relative to Default (or any directory Apollo is not looking in). You can find the setting here: Xcode > Preferences > Locations > Derived Data

                • If you would rather keep your Derived Data where it is, alter the bash find command in the query passed to apollo-cli to exclude the DerivedData/ folder by appending -not -path "*DerivedData/*". You can find the script by going to Project Root > (Target Project) > Build Phases > Generate Apollo GraphQL API, (which you should have added during the installation steps, see here). Make it look like this:
                  $APOLLO_FRAMEWORK_PATH/check-and-run-apollo-cli.sh codegen:generate --queries="$(find . -name '*.graphql' -not -path "*DerivedData/*")" --schema=schema.json API.swift

                You might need to delete the DerivedData/ folder one last time from your project folder, and it doesn't hurt to do one last clean (Command + Shift + K).







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 '18 at 23:23









                cntrlzcntrlz

                464




                464



























                    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%2f53290954%2fwhy-does-apollo-fail-to-build-in-xcode-there-can-only-be-one-fragment-named%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







                    這個網誌中的熱門文章

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3

                    Museum of Modern and Contemporary Art of Trento and Rovereto