在 Xcode 6 中重命名应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26197022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Renaming App in Xcode 6
提问by Jeff Janes
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/
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
在屏幕左上角的项目导航器窗格中缓慢双击项目名称。然后允许 Xcode 重命名文件
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.
这就是我所做的一切,也许这本身还不够,所以如果有人知道正确的方法,请告诉我。
回答by Camilo Sanchez
I also experienced this issue recently. Your XCode project should have two targets. One target for your app the other target for the tests.
我最近也遇到了这个问题。您的 XCode 项目应该有两个目标。您的应用程序的一个目标是测试的另一个目标。
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.
正确修改测试主机设置值,一切正常。
回答by sundhage
I resolved this by opening MyProject.xcodeproj/project.pbxproj with a text editor and manually replacing the incorrect names (*.app)
我通过使用文本编辑器打开 MyProject.xcodeproj/project.pbxproj 并手动替换不正确的名称 (*.app) 解决了这个问题
回答by Stefan
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.
我不太了解 Xcode 6,但由于我假设它使用的每个项目文件都是基于文本的,因此您可以在 shell 中尝试类似的操作,假设MyProjectDir
是您的项目目录并且OldProjectName
是您项目的旧名称。
You should clean and close the project in Xcode first.
您应该先在 Xcode 中清理并关闭项目。
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.
这将列出所有包含旧项目名称行的文件(每个文件首先包含匹配的行,然后是包含文件的“ls -l”格式的目录条目)。这样,您至少应该知道哪些文件仍然包含旧名称。也许使用文本编辑器改变它会完成这项工作。
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.
列出包含旧项目名称的所有文件。然后,如果您确定它们是由 Xcode 生成的,您可以重命名这些文件,甚至删除它们。
Of course, be sure to make a backup copy of your project first!
当然,一定要先备份你的项目!
回答by Nick Barr
I had what looks to be the identical issue.
我有什么看起来是相同的问题。
I solved it by:
我通过以下方式解决了它:
- navigating to the problem directory: in your case: shell.app.
- mv shell OLD_NAME. In other words: rename the file to the old name of your project.
- Clean + Run
- 导航到问题目录:在您的情况下:shell.app。
- mv 外壳 OLD_NAME。换句话说:将文件重命名为项目的旧名称。
- 清洁 + 运行
回答by d2burke
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:
造成这种情况的原因是对旧应用程序产品的挥之不去的引用。您需要删除该Derived Data
文件夹并执行清理。在那之后你应该一切都准备好了。请参阅此链接以获取更多阅读:
回答by Nick
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.
在 Xcode 7 中,重命名 CocoaTouch Framework 项目后,我必须管理方案,然后单击“立即自动创建方案”按钮。然后我删除了具有原始名称的方案。