Xcode unittest build failed with error “Undefined symbols for architecture x86_64”












33















My unittest target build failed with below error:



Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MCStore", referenced from:
objc-class-ref in MCStoreTests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Basic information:




  • Xcode6.2

  • iOS8.2 SDK


What I have checked:





  • Symbols Hidden by Default is No


  • Other Linker Flags is -framework XCTest


  • Framework Search Paths is $(SDKROOT)/Developer/Library/Frameworks $(inherited)










share|improve this question

























  • Where is the MCStore class implemented?

    – Droppy
    Jun 19 '15 at 10:30











  • it's implemented in my application target.

    – Yuwen Yan
    Jun 19 '15 at 10:31











  • And the test target includes that implementation file?

    – Droppy
    Jun 19 '15 at 10:32











  • No, I have added my application target to the unittest target dependencies

    – Yuwen Yan
    Jun 19 '15 at 10:36
















33















My unittest target build failed with below error:



Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MCStore", referenced from:
objc-class-ref in MCStoreTests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Basic information:




  • Xcode6.2

  • iOS8.2 SDK


What I have checked:





  • Symbols Hidden by Default is No


  • Other Linker Flags is -framework XCTest


  • Framework Search Paths is $(SDKROOT)/Developer/Library/Frameworks $(inherited)










share|improve this question

























  • Where is the MCStore class implemented?

    – Droppy
    Jun 19 '15 at 10:30











  • it's implemented in my application target.

    – Yuwen Yan
    Jun 19 '15 at 10:31











  • And the test target includes that implementation file?

    – Droppy
    Jun 19 '15 at 10:32











  • No, I have added my application target to the unittest target dependencies

    – Yuwen Yan
    Jun 19 '15 at 10:36














33












33








33


9






My unittest target build failed with below error:



Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MCStore", referenced from:
objc-class-ref in MCStoreTests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Basic information:




  • Xcode6.2

  • iOS8.2 SDK


What I have checked:





  • Symbols Hidden by Default is No


  • Other Linker Flags is -framework XCTest


  • Framework Search Paths is $(SDKROOT)/Developer/Library/Frameworks $(inherited)










share|improve this question
















My unittest target build failed with below error:



Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MCStore", referenced from:
objc-class-ref in MCStoreTests.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Basic information:




  • Xcode6.2

  • iOS8.2 SDK


What I have checked:





  • Symbols Hidden by Default is No


  • Other Linker Flags is -framework XCTest


  • Framework Search Paths is $(SDKROOT)/Developer/Library/Frameworks $(inherited)







ios xcode






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 2:35









Cœur

18.3k9109148




18.3k9109148










asked Jun 19 '15 at 10:16









Yuwen YanYuwen Yan

1,89112445




1,89112445













  • Where is the MCStore class implemented?

    – Droppy
    Jun 19 '15 at 10:30











  • it's implemented in my application target.

    – Yuwen Yan
    Jun 19 '15 at 10:31











  • And the test target includes that implementation file?

    – Droppy
    Jun 19 '15 at 10:32











  • No, I have added my application target to the unittest target dependencies

    – Yuwen Yan
    Jun 19 '15 at 10:36



















  • Where is the MCStore class implemented?

    – Droppy
    Jun 19 '15 at 10:30











  • it's implemented in my application target.

    – Yuwen Yan
    Jun 19 '15 at 10:31











  • And the test target includes that implementation file?

    – Droppy
    Jun 19 '15 at 10:32











  • No, I have added my application target to the unittest target dependencies

    – Yuwen Yan
    Jun 19 '15 at 10:36

















Where is the MCStore class implemented?

– Droppy
Jun 19 '15 at 10:30





Where is the MCStore class implemented?

– Droppy
Jun 19 '15 at 10:30













it's implemented in my application target.

– Yuwen Yan
Jun 19 '15 at 10:31





it's implemented in my application target.

– Yuwen Yan
Jun 19 '15 at 10:31













And the test target includes that implementation file?

– Droppy
Jun 19 '15 at 10:32





And the test target includes that implementation file?

– Droppy
Jun 19 '15 at 10:32













No, I have added my application target to the unittest target dependencies

– Yuwen Yan
Jun 19 '15 at 10:36





No, I have added my application target to the unittest target dependencies

– Yuwen Yan
Jun 19 '15 at 10:36












7 Answers
7






active

oldest

votes


















79














According to this link, I need to set Bundle Loader with below content in unittest target Build Settings



$(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp






share|improve this answer
























  • helpful link, thanks

    – Kate Geld
    Oct 23 '15 at 14:03






  • 2





    This answer is a life-saver dude!!! I am so happy I have stumbled upon it!!! So many thanks!!!

    – Soberman
    Feb 16 '16 at 19:03






  • 4





    Why does this work? And why does this not work out of the box in XCode?

    – yurgis
    Nov 8 '16 at 0:50






  • 3





    These line are worth gold!!! Thanks very much. Helped me solving endless Mach-O linker errors in a project with unit-test, ui-test and different deployment targets.

    – Darkglow
    Jan 24 '17 at 11:12






  • 2





    I had to do this with a brand new project created with XCode 8.2.

    – MdaG
    Feb 4 '17 at 12:01



















9














At least as of Xcode 7.3 test targets let you select a "Host Application". In the Test target (but not presently the UI Test target) this automatically populates the "Test Host" build setting, but not the "Bundle Loader", which can lead to classes not being found.



Considering this, if you set your test targets' "Bundle Loader" Build Setting to $(TEST_HOST), it will always contain the right value even if you change the Host Application.



This is effectively the opposite of the advice given in the link @yuwen-yan posted, and should amount to less work.






share|improve this answer





















  • 2





    I found $(TEST_HOST) to be the default configuration, however still one of my pods isn't found.

    – Lars Blumberg
    Jun 8 '16 at 9:27






  • 1





    In Xcode9.2, its now under Test target > Build settings > Testing > Test host. Adding $(TEST_HOST) still works. However, I also did update my cocoapods.

    – quik_silv
    Aug 2 '18 at 21:40





















2














Experienced the same issue.
What fixed it for me was setting enable modules (c and objective-c) to YES in the Testing target Build Settings.






share|improve this answer































    1














    So here is what worked for me...



    override func setUp() {

    super.setUp()

    let promise = expectation(description: "App has finished running")

    DispatchQueue.global(qos: .background).async{
    // Wait on the background thread
    sleep(4)
    DispatchQueue.main.async {
    // Fullfill the promise in the main thread
    promise.fulfill()
    }
    }

    // Initialize the storyboard
    let storyboard = UIStoryboard(name: "Main", bundle: nil)

    // Get the view controller
    sut = storyboard.instantiateViewController(withIdentifier: String(describing: ViewController.self)) as? ViewController
    _ = sut.view

    waitForExpectations(timeout: 5) { (_) in
    // Finish set up after the app is done running its code
    }

    }// End setUp() Method





    share|improve this answer































      0














      Experienced the same linker error after adding test target to old project which was created 2 or 3 XCode versions ago. Furthermore, project has various xcodeproject/target/bundle names. All possible renames, cleanings, Build settings, Build phases, Scheme manipulations did not worked for me.



      What did actually worked after a long struggle is recreating the project along with all targets from scratch in latest Xcode version. It finally links! And in this case you don't even need to manually modify Search paths, Bundle loader, Xcode will do it for you.






      share|improve this answer































        0














        This error may be the result of having wrong test target type, namely ui test target.



        UI test targets can't use the internals of the main target, not even with @testable imports. Unit test targets OTOH can use the internals.



        See more details in this answer.



        (I believe this has changed in some XCode version which causes confusion. Typical way is just to include a huge bunch of files from the original target in the ui test target. A proper way is to design UI tests in such a way that they don't need or use much code from the main target.)






        share|improve this answer































          -2














          Below are the steps that I performed to fix the issue while trying to add unit test target in Xcode 9:




          1. Go to 'Manage Schemes'.

          2. Click on '+' button at the bottom.

          3. Select the newly added Target and select 'OK'.

          4. Make sure 'Shared' option is selected for the newly added target.






          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%2f30935640%2fxcode-unittest-build-failed-with-error-undefined-symbols-for-architecture-x86-6%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            7 Answers
            7






            active

            oldest

            votes








            7 Answers
            7






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            79














            According to this link, I need to set Bundle Loader with below content in unittest target Build Settings



            $(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp






            share|improve this answer
























            • helpful link, thanks

              – Kate Geld
              Oct 23 '15 at 14:03






            • 2





              This answer is a life-saver dude!!! I am so happy I have stumbled upon it!!! So many thanks!!!

              – Soberman
              Feb 16 '16 at 19:03






            • 4





              Why does this work? And why does this not work out of the box in XCode?

              – yurgis
              Nov 8 '16 at 0:50






            • 3





              These line are worth gold!!! Thanks very much. Helped me solving endless Mach-O linker errors in a project with unit-test, ui-test and different deployment targets.

              – Darkglow
              Jan 24 '17 at 11:12






            • 2





              I had to do this with a brand new project created with XCode 8.2.

              – MdaG
              Feb 4 '17 at 12:01
















            79














            According to this link, I need to set Bundle Loader with below content in unittest target Build Settings



            $(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp






            share|improve this answer
























            • helpful link, thanks

              – Kate Geld
              Oct 23 '15 at 14:03






            • 2





              This answer is a life-saver dude!!! I am so happy I have stumbled upon it!!! So many thanks!!!

              – Soberman
              Feb 16 '16 at 19:03






            • 4





              Why does this work? And why does this not work out of the box in XCode?

              – yurgis
              Nov 8 '16 at 0:50






            • 3





              These line are worth gold!!! Thanks very much. Helped me solving endless Mach-O linker errors in a project with unit-test, ui-test and different deployment targets.

              – Darkglow
              Jan 24 '17 at 11:12






            • 2





              I had to do this with a brand new project created with XCode 8.2.

              – MdaG
              Feb 4 '17 at 12:01














            79












            79








            79







            According to this link, I need to set Bundle Loader with below content in unittest target Build Settings



            $(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp






            share|improve this answer













            According to this link, I need to set Bundle Loader with below content in unittest target Build Settings



            $(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 19 '15 at 13:20









            Yuwen YanYuwen Yan

            1,89112445




            1,89112445













            • helpful link, thanks

              – Kate Geld
              Oct 23 '15 at 14:03






            • 2





              This answer is a life-saver dude!!! I am so happy I have stumbled upon it!!! So many thanks!!!

              – Soberman
              Feb 16 '16 at 19:03






            • 4





              Why does this work? And why does this not work out of the box in XCode?

              – yurgis
              Nov 8 '16 at 0:50






            • 3





              These line are worth gold!!! Thanks very much. Helped me solving endless Mach-O linker errors in a project with unit-test, ui-test and different deployment targets.

              – Darkglow
              Jan 24 '17 at 11:12






            • 2





              I had to do this with a brand new project created with XCode 8.2.

              – MdaG
              Feb 4 '17 at 12:01



















            • helpful link, thanks

              – Kate Geld
              Oct 23 '15 at 14:03






            • 2





              This answer is a life-saver dude!!! I am so happy I have stumbled upon it!!! So many thanks!!!

              – Soberman
              Feb 16 '16 at 19:03






            • 4





              Why does this work? And why does this not work out of the box in XCode?

              – yurgis
              Nov 8 '16 at 0:50






            • 3





              These line are worth gold!!! Thanks very much. Helped me solving endless Mach-O linker errors in a project with unit-test, ui-test and different deployment targets.

              – Darkglow
              Jan 24 '17 at 11:12






            • 2





              I had to do this with a brand new project created with XCode 8.2.

              – MdaG
              Feb 4 '17 at 12:01

















            helpful link, thanks

            – Kate Geld
            Oct 23 '15 at 14:03





            helpful link, thanks

            – Kate Geld
            Oct 23 '15 at 14:03




            2




            2





            This answer is a life-saver dude!!! I am so happy I have stumbled upon it!!! So many thanks!!!

            – Soberman
            Feb 16 '16 at 19:03





            This answer is a life-saver dude!!! I am so happy I have stumbled upon it!!! So many thanks!!!

            – Soberman
            Feb 16 '16 at 19:03




            4




            4





            Why does this work? And why does this not work out of the box in XCode?

            – yurgis
            Nov 8 '16 at 0:50





            Why does this work? And why does this not work out of the box in XCode?

            – yurgis
            Nov 8 '16 at 0:50




            3




            3





            These line are worth gold!!! Thanks very much. Helped me solving endless Mach-O linker errors in a project with unit-test, ui-test and different deployment targets.

            – Darkglow
            Jan 24 '17 at 11:12





            These line are worth gold!!! Thanks very much. Helped me solving endless Mach-O linker errors in a project with unit-test, ui-test and different deployment targets.

            – Darkglow
            Jan 24 '17 at 11:12




            2




            2





            I had to do this with a brand new project created with XCode 8.2.

            – MdaG
            Feb 4 '17 at 12:01





            I had to do this with a brand new project created with XCode 8.2.

            – MdaG
            Feb 4 '17 at 12:01













            9














            At least as of Xcode 7.3 test targets let you select a "Host Application". In the Test target (but not presently the UI Test target) this automatically populates the "Test Host" build setting, but not the "Bundle Loader", which can lead to classes not being found.



            Considering this, if you set your test targets' "Bundle Loader" Build Setting to $(TEST_HOST), it will always contain the right value even if you change the Host Application.



            This is effectively the opposite of the advice given in the link @yuwen-yan posted, and should amount to less work.






            share|improve this answer





















            • 2





              I found $(TEST_HOST) to be the default configuration, however still one of my pods isn't found.

              – Lars Blumberg
              Jun 8 '16 at 9:27






            • 1





              In Xcode9.2, its now under Test target > Build settings > Testing > Test host. Adding $(TEST_HOST) still works. However, I also did update my cocoapods.

              – quik_silv
              Aug 2 '18 at 21:40


















            9














            At least as of Xcode 7.3 test targets let you select a "Host Application". In the Test target (but not presently the UI Test target) this automatically populates the "Test Host" build setting, but not the "Bundle Loader", which can lead to classes not being found.



            Considering this, if you set your test targets' "Bundle Loader" Build Setting to $(TEST_HOST), it will always contain the right value even if you change the Host Application.



            This is effectively the opposite of the advice given in the link @yuwen-yan posted, and should amount to less work.






            share|improve this answer





















            • 2





              I found $(TEST_HOST) to be the default configuration, however still one of my pods isn't found.

              – Lars Blumberg
              Jun 8 '16 at 9:27






            • 1





              In Xcode9.2, its now under Test target > Build settings > Testing > Test host. Adding $(TEST_HOST) still works. However, I also did update my cocoapods.

              – quik_silv
              Aug 2 '18 at 21:40
















            9












            9








            9







            At least as of Xcode 7.3 test targets let you select a "Host Application". In the Test target (but not presently the UI Test target) this automatically populates the "Test Host" build setting, but not the "Bundle Loader", which can lead to classes not being found.



            Considering this, if you set your test targets' "Bundle Loader" Build Setting to $(TEST_HOST), it will always contain the right value even if you change the Host Application.



            This is effectively the opposite of the advice given in the link @yuwen-yan posted, and should amount to less work.






            share|improve this answer















            At least as of Xcode 7.3 test targets let you select a "Host Application". In the Test target (but not presently the UI Test target) this automatically populates the "Test Host" build setting, but not the "Bundle Loader", which can lead to classes not being found.



            Considering this, if you set your test targets' "Bundle Loader" Build Setting to $(TEST_HOST), it will always contain the right value even if you change the Host Application.



            This is effectively the opposite of the advice given in the link @yuwen-yan posted, and should amount to less work.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 28 '16 at 15:18

























            answered Apr 27 '16 at 18:25









            Ben ThielkerBen Thielker

            3,01931417




            3,01931417








            • 2





              I found $(TEST_HOST) to be the default configuration, however still one of my pods isn't found.

              – Lars Blumberg
              Jun 8 '16 at 9:27






            • 1





              In Xcode9.2, its now under Test target > Build settings > Testing > Test host. Adding $(TEST_HOST) still works. However, I also did update my cocoapods.

              – quik_silv
              Aug 2 '18 at 21:40
















            • 2





              I found $(TEST_HOST) to be the default configuration, however still one of my pods isn't found.

              – Lars Blumberg
              Jun 8 '16 at 9:27






            • 1





              In Xcode9.2, its now under Test target > Build settings > Testing > Test host. Adding $(TEST_HOST) still works. However, I also did update my cocoapods.

              – quik_silv
              Aug 2 '18 at 21:40










            2




            2





            I found $(TEST_HOST) to be the default configuration, however still one of my pods isn't found.

            – Lars Blumberg
            Jun 8 '16 at 9:27





            I found $(TEST_HOST) to be the default configuration, however still one of my pods isn't found.

            – Lars Blumberg
            Jun 8 '16 at 9:27




            1




            1





            In Xcode9.2, its now under Test target > Build settings > Testing > Test host. Adding $(TEST_HOST) still works. However, I also did update my cocoapods.

            – quik_silv
            Aug 2 '18 at 21:40







            In Xcode9.2, its now under Test target > Build settings > Testing > Test host. Adding $(TEST_HOST) still works. However, I also did update my cocoapods.

            – quik_silv
            Aug 2 '18 at 21:40













            2














            Experienced the same issue.
            What fixed it for me was setting enable modules (c and objective-c) to YES in the Testing target Build Settings.






            share|improve this answer




























              2














              Experienced the same issue.
              What fixed it for me was setting enable modules (c and objective-c) to YES in the Testing target Build Settings.






              share|improve this answer


























                2












                2








                2







                Experienced the same issue.
                What fixed it for me was setting enable modules (c and objective-c) to YES in the Testing target Build Settings.






                share|improve this answer













                Experienced the same issue.
                What fixed it for me was setting enable modules (c and objective-c) to YES in the Testing target Build Settings.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 24 '16 at 11:25









                RazRaz

                1,9231740




                1,9231740























                    1














                    So here is what worked for me...



                    override func setUp() {

                    super.setUp()

                    let promise = expectation(description: "App has finished running")

                    DispatchQueue.global(qos: .background).async{
                    // Wait on the background thread
                    sleep(4)
                    DispatchQueue.main.async {
                    // Fullfill the promise in the main thread
                    promise.fulfill()
                    }
                    }

                    // Initialize the storyboard
                    let storyboard = UIStoryboard(name: "Main", bundle: nil)

                    // Get the view controller
                    sut = storyboard.instantiateViewController(withIdentifier: String(describing: ViewController.self)) as? ViewController
                    _ = sut.view

                    waitForExpectations(timeout: 5) { (_) in
                    // Finish set up after the app is done running its code
                    }

                    }// End setUp() Method





                    share|improve this answer




























                      1














                      So here is what worked for me...



                      override func setUp() {

                      super.setUp()

                      let promise = expectation(description: "App has finished running")

                      DispatchQueue.global(qos: .background).async{
                      // Wait on the background thread
                      sleep(4)
                      DispatchQueue.main.async {
                      // Fullfill the promise in the main thread
                      promise.fulfill()
                      }
                      }

                      // Initialize the storyboard
                      let storyboard = UIStoryboard(name: "Main", bundle: nil)

                      // Get the view controller
                      sut = storyboard.instantiateViewController(withIdentifier: String(describing: ViewController.self)) as? ViewController
                      _ = sut.view

                      waitForExpectations(timeout: 5) { (_) in
                      // Finish set up after the app is done running its code
                      }

                      }// End setUp() Method





                      share|improve this answer


























                        1












                        1








                        1







                        So here is what worked for me...



                        override func setUp() {

                        super.setUp()

                        let promise = expectation(description: "App has finished running")

                        DispatchQueue.global(qos: .background).async{
                        // Wait on the background thread
                        sleep(4)
                        DispatchQueue.main.async {
                        // Fullfill the promise in the main thread
                        promise.fulfill()
                        }
                        }

                        // Initialize the storyboard
                        let storyboard = UIStoryboard(name: "Main", bundle: nil)

                        // Get the view controller
                        sut = storyboard.instantiateViewController(withIdentifier: String(describing: ViewController.self)) as? ViewController
                        _ = sut.view

                        waitForExpectations(timeout: 5) { (_) in
                        // Finish set up after the app is done running its code
                        }

                        }// End setUp() Method





                        share|improve this answer













                        So here is what worked for me...



                        override func setUp() {

                        super.setUp()

                        let promise = expectation(description: "App has finished running")

                        DispatchQueue.global(qos: .background).async{
                        // Wait on the background thread
                        sleep(4)
                        DispatchQueue.main.async {
                        // Fullfill the promise in the main thread
                        promise.fulfill()
                        }
                        }

                        // Initialize the storyboard
                        let storyboard = UIStoryboard(name: "Main", bundle: nil)

                        // Get the view controller
                        sut = storyboard.instantiateViewController(withIdentifier: String(describing: ViewController.self)) as? ViewController
                        _ = sut.view

                        waitForExpectations(timeout: 5) { (_) in
                        // Finish set up after the app is done running its code
                        }

                        }// End setUp() Method






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Nov 21 '18 at 23:26









                        Deo KaluleDeo Kalule

                        111




                        111























                            0














                            Experienced the same linker error after adding test target to old project which was created 2 or 3 XCode versions ago. Furthermore, project has various xcodeproject/target/bundle names. All possible renames, cleanings, Build settings, Build phases, Scheme manipulations did not worked for me.



                            What did actually worked after a long struggle is recreating the project along with all targets from scratch in latest Xcode version. It finally links! And in this case you don't even need to manually modify Search paths, Bundle loader, Xcode will do it for you.






                            share|improve this answer




























                              0














                              Experienced the same linker error after adding test target to old project which was created 2 or 3 XCode versions ago. Furthermore, project has various xcodeproject/target/bundle names. All possible renames, cleanings, Build settings, Build phases, Scheme manipulations did not worked for me.



                              What did actually worked after a long struggle is recreating the project along with all targets from scratch in latest Xcode version. It finally links! And in this case you don't even need to manually modify Search paths, Bundle loader, Xcode will do it for you.






                              share|improve this answer


























                                0












                                0








                                0







                                Experienced the same linker error after adding test target to old project which was created 2 or 3 XCode versions ago. Furthermore, project has various xcodeproject/target/bundle names. All possible renames, cleanings, Build settings, Build phases, Scheme manipulations did not worked for me.



                                What did actually worked after a long struggle is recreating the project along with all targets from scratch in latest Xcode version. It finally links! And in this case you don't even need to manually modify Search paths, Bundle loader, Xcode will do it for you.






                                share|improve this answer













                                Experienced the same linker error after adding test target to old project which was created 2 or 3 XCode versions ago. Furthermore, project has various xcodeproject/target/bundle names. All possible renames, cleanings, Build settings, Build phases, Scheme manipulations did not worked for me.



                                What did actually worked after a long struggle is recreating the project along with all targets from scratch in latest Xcode version. It finally links! And in this case you don't even need to manually modify Search paths, Bundle loader, Xcode will do it for you.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Jun 29 '18 at 9:14









                                Alexander StepanishinAlexander Stepanishin

                                14818




                                14818























                                    0














                                    This error may be the result of having wrong test target type, namely ui test target.



                                    UI test targets can't use the internals of the main target, not even with @testable imports. Unit test targets OTOH can use the internals.



                                    See more details in this answer.



                                    (I believe this has changed in some XCode version which causes confusion. Typical way is just to include a huge bunch of files from the original target in the ui test target. A proper way is to design UI tests in such a way that they don't need or use much code from the main target.)






                                    share|improve this answer




























                                      0














                                      This error may be the result of having wrong test target type, namely ui test target.



                                      UI test targets can't use the internals of the main target, not even with @testable imports. Unit test targets OTOH can use the internals.



                                      See more details in this answer.



                                      (I believe this has changed in some XCode version which causes confusion. Typical way is just to include a huge bunch of files from the original target in the ui test target. A proper way is to design UI tests in such a way that they don't need or use much code from the main target.)






                                      share|improve this answer


























                                        0












                                        0








                                        0







                                        This error may be the result of having wrong test target type, namely ui test target.



                                        UI test targets can't use the internals of the main target, not even with @testable imports. Unit test targets OTOH can use the internals.



                                        See more details in this answer.



                                        (I believe this has changed in some XCode version which causes confusion. Typical way is just to include a huge bunch of files from the original target in the ui test target. A proper way is to design UI tests in such a way that they don't need or use much code from the main target.)






                                        share|improve this answer













                                        This error may be the result of having wrong test target type, namely ui test target.



                                        UI test targets can't use the internals of the main target, not even with @testable imports. Unit test targets OTOH can use the internals.



                                        See more details in this answer.



                                        (I believe this has changed in some XCode version which causes confusion. Typical way is just to include a huge bunch of files from the original target in the ui test target. A proper way is to design UI tests in such a way that they don't need or use much code from the main target.)







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Oct 17 '18 at 5:27









                                        Peter LambergPeter Lamberg

                                        3,79513350




                                        3,79513350























                                            -2














                                            Below are the steps that I performed to fix the issue while trying to add unit test target in Xcode 9:




                                            1. Go to 'Manage Schemes'.

                                            2. Click on '+' button at the bottom.

                                            3. Select the newly added Target and select 'OK'.

                                            4. Make sure 'Shared' option is selected for the newly added target.






                                            share|improve this answer




























                                              -2














                                              Below are the steps that I performed to fix the issue while trying to add unit test target in Xcode 9:




                                              1. Go to 'Manage Schemes'.

                                              2. Click on '+' button at the bottom.

                                              3. Select the newly added Target and select 'OK'.

                                              4. Make sure 'Shared' option is selected for the newly added target.






                                              share|improve this answer


























                                                -2












                                                -2








                                                -2







                                                Below are the steps that I performed to fix the issue while trying to add unit test target in Xcode 9:




                                                1. Go to 'Manage Schemes'.

                                                2. Click on '+' button at the bottom.

                                                3. Select the newly added Target and select 'OK'.

                                                4. Make sure 'Shared' option is selected for the newly added target.






                                                share|improve this answer













                                                Below are the steps that I performed to fix the issue while trying to add unit test target in Xcode 9:




                                                1. Go to 'Manage Schemes'.

                                                2. Click on '+' button at the bottom.

                                                3. Select the newly added Target and select 'OK'.

                                                4. Make sure 'Shared' option is selected for the newly added target.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Jan 2 '18 at 17:42









                                                NishNish

                                                1063




                                                1063






























                                                    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%2f30935640%2fxcode-unittest-build-failed-with-error-undefined-symbols-for-architecture-x86-6%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

                                                    Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

                                                    Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

                                                    A Topological Invariant for $pi_3(U(n))$