20
votes

I have an app that I need to rename so the code can be reused with only slight changes and I am having difficulties.

I followed this link and it seemed to cover it but when I tried build it I received a linking error which also follows:

Link to resource:

http://matthewfecher.com/app-developement/xcode-tips-the-best-way-to-change-a-project-name-in-xcode/

This is the linking error I get and info I see

Ld /Users/jeffjanes/Library/Developer/Xcode/DerivedData/solfEightFive-aqlpurtbbyfkqmgjdryrxicllljh/Build/Products/Debug-iphoneos/solfEightFiveTests.xctest/solfEightFiveTests normal arm64
    cd "/Users/jeffjanes/Xcode Projects/solfEightFive/shell"
    export IPHONEOS_DEPLOYMENT_TARGET=8.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk -L/Users/jeffjanes/Library/Developer/Xcode/DerivedData/solfEightFive-aqlpurtbbyfkqmgjdryrxicllljh/Build/Products/Debug-iphoneos -F/Users/jeffjanes/Library/Developer/Xcode/DerivedData/solfEightFive-aqlpurtbbyfkqmgjdryrxicllljh/Build/Products/Debug-iphoneos -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/Developer/Library/Frameworks -filelist /Users/jeffjanes/Library/Developer/Xcode/DerivedData/solfEightFive-aqlpurtbbyfkqmgjdryrxicllljh/Build/Intermediates/solfEightFive.build/Debug-iphoneos/solfEightFiveTests.build/Objects-normal/arm64/solfEightFiveTests.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -bundle_loader /Users/jeffjanes/Library/Developer/Xcode/DerivedData/solfEightFive-aqlpurtbbyfkqmgjdryrxicllljh/Build/Products/Debug-iphoneos/shell.app/shell -framework XCTest -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=8.0 -Xlinker -dependency_info -Xlinker /Users/jeffjanes/Library/Developer/Xcode/DerivedData/solfEightFive-aqlpurtbbyfkqmgjdryrxicllljh/Build/Intermediates/solfEightFive.build/Debug-iphoneos/solfEightFiveTests.build/Objects-normal/arm64/solfEightFiveTests_dependency_info.dat -o /Users/jeffjanes/Library/Developer/Xcode/DerivedData/solfEightFive-aqlpurtbbyfkqmgjdryrxicllljh/Build/Products/Debug-iphoneos/solfEightFiveTests.xctest/solfEightFiveTests

ld: file not found: /Users/jeffjanes/Library/Developer/Xcode/DerivedData/solfEightFive-aqlpurtbbyfkqmgjdryrxicllljh/Build/Products/Debug-iphoneos/shell.app/shell
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is there something I am missing? I tried cleaning it and that seemed to have no effect.

This is just some clarification the process described in the link above suggests the following:

Double click slowly on the project name in the project navigator pane in the upper left hand portion of the screen. Then allow Xcode to rename the files

And

Renaming the scheme in the same way

That is all I did maybe that in itself was not enough so if someone knows the proper way please let me know.

6
Try a build folder clean: Command-Shift-Option-K. Tell me if it works and I'll post it as an answer.Undo♦
As per the last line in my inital question I tried that and it did not fix it I tried again to make sure but no changeJeff Janes
Try closing xcode and removing everything in ~/Library/Developer/Xcode/DerivedData. Then re-open xcode. Has fixed linker errors for me before. A clean is often not enough.cypres
Thanks for the idea Cypres but that did not do it. Still working on it.Jeff Janes

6 Answers

12
votes

I also experienced this issue recently. Your XCode project should have two targets. One target for your app the other target for the tests.

In the Build settings for the test target there is a setting name Test Host. The value for this setting does not get updated once you rename your app target.

Properly modify the Test Host setting value and everything should work.

4
votes

I resolved this by opening MyProject.xcodeproj/project.pbxproj with a text editor and manually replacing the incorrect names (*.app)

2
votes

First of all, I tried to post this only as a comment, but I am not allowed yet to do so.

I do not know Xcode 6 very well, but since I assume every project file it uses is text-based, you could try something like this in the shell, assuming MyProjectDir is your project directory and OldProjectName is your project's old name.

You should clean and close the project in Xcode first.

cd MyProjectDir
find . -type f -exec grep -i OldProjectName {} \; -ls

This will list you all files with lines containing the old project name (each first with the matching lines, followed by the containing file's directory entry in "ls -l" format). By this, you should at least know which files still contain the old name. Maybe changing that using a text editor will do the job.

You can also do

cd MyProjectDir
find . -iname "*OldProjectName*" -ls

to list all files containing the old project name. Then, you could either rename those files or even remove them if you are sure that they are generated by Xcode.

Of course, be sure to make a backup copy of your project first!

1
votes

I had what looks to be the identical issue.

I solved it by:

  1. navigating to the problem directory: in your case: shell.app.
  2. mv shell OLD_NAME. In other words: rename the file to the old name of your project.
  3. Clean + Run
0
votes

The cause of this is a lingering reference to the old app product. You need to delete the Derived Data folder and perform a Clean. You should be all set after that. See this link for more reading:

Delete Derived Data

0
votes

In Xcode 7, after renaming a CocoaTouch Framework project, I had to Manage Schemes, and click "Autocreate Schemes Now" button. Then i removed the scheme with the original name.