61

So after I create an Xcode 6 project, even if I haven't written any code in it, if I try renaming it by double clicking the bolded program title in the upper left hand corner of the navigator and then confirming that I want the checked items' names changed, I get the following error when I try running it: "clang: error: linker command failed with exit code 1 (use -v to see invocation)"

I've even tried using the find tool to see all the things named the previous name, including the info.plist (which I think is the problem) and changing them to the new name. By renaming the info.plist manually I get an error saying that doesn't exist.

What am I doing wrong?

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
blue
  • 7,175
  • 16
  • 81
  • 179

8 Answers8

146

I saw the same error after changing the name, and I was able to fix it by clearing the "Test Host" values in the Build Settings of my "Tests" target:

enter image description here

Alternatively, If you need your tests to be able to run after changing the name of your project, you should be able to update the MyProject.app/MyProject value in both fields to reflect the new name of your project (ie. MyNewProject.app/MyNewProject)

chasew
  • 8,438
  • 7
  • 41
  • 48
6

If above method(s) doesn't work and if for now you don't feel like needing to test anything in your project, just remove your project test target.

Later on if you need to create some tests, you will still be able to add test targets again.

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
  • 1
    This worked for me. I simply added the existing tests to the new test target. In addition I was using `@testable import MyModule>` in some of the XCTest subclasses. The module name needed to be updated. – Murray Sagal Apr 28 '16 at 19:14
5

Go to the Build Settings of my "Tests" target then change the paths from the old project name to your new project name

Test Host
 - Debug   Build/Debug-iphoneos/OldProjectName.app/OldProjectName
 - Release Build/Release-iphoneos/OldProjectName.app/OldProjectName

Test Host
 - Debug   Build/Debug-iphoneos/NewProjectName.app/NewProjectName
 - Release Build/Release-iphoneos/NewProjectName.app/NewProjectName

Just simply clearing them would break your tests so you need to replace them with the new project name.

Norly Canarias
  • 1,736
  • 1
  • 21
  • 19
2

Ran into this too, after copying and renaming the folder with an xcode project. I think it's a bug in xcode. Best file a bug with bugreporter (https://bugreport.apple.com/). Removing the test target from my project fixed it for me, too.

RickJansen
  • 1,615
  • 18
  • 24
0

Here is what I've done to fix the similar problem since I changed the project name and folders under the project.

  1. Select project file : projectName.xcodeproj
  2. Right click on the project file and click "Show package contents" to open project.pbxproj file.
  3. Once ope project.pbxproj file, replace all from old project name (whatever you changed from) to new name.
  4. You can change the name of sub folder if you changed folder name too.

Hope this help.

0

There are different places where you should check for the rename. You should check for the "old" project name in the test target and in the project target. Search for the old name string and rename them manually to the new name.

Luciano LB
  • 53
  • 6
-2

If you doesn't use the test target you can delete this target.

Alessandro Pirovano
  • 2,509
  • 28
  • 21
-3

There are many places you have to check upon re-naming. This approach does not seem at all practical.

If you really need to do this, I recommend creating a new project and just copying the necessary files over to the new project.

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • 1
    Still there has to be a more user-friendly way to simply rename a project or isn't there? If you've created a larger project with a more complex storyboard as well you may not want to copy/paste everything just to adapt that single word within the title of the project, I guess... – alexeis Oct 07 '14 at 15:05
  • The things you want to change are largely cosmetic. Put your project in folder with your preferred name and you are done. No, there does not have to be (and there is no) more user-friendly way to do this. – Mundi Oct 07 '14 at 21:09
  • skyguy is using xcode's built-in way of renaming a project. it takes care of all the "many places" you need to fix, so it really is very practical. That it happens to break in one place when renaming Swift projects is a minor xcode bug. – nevyn Dec 08 '14 at 04:52