简体   繁体   English

在XCode中更改项目文件夹名称后出错

[英]Getting error after changing project folder name in XCode

When I created my project, I called it "Project1". 当我创建项目时,我称之为“Project1”。 Then, later I've changed it to "Project2" from the Xcode. 然后,我稍后将其从Xcode更改为“Project2”。 I changed all "Project1" to "Project2", but now, when I compile my project, it looks for files in Project2/Project1/myFile.swift and I get the next error: 我将所有“Project1”更改为“Project2”,但现在,当我编译我的项目时,它在Project2/Project1/myFile.swift查找文件,我得到下一个错误:

<unknown>:0: error: no such file or directory: '/Users/myusername/Copy/Projects/Project2/Project1/myFile.swift'

I need to make that it will look at 我需要让它看起来

/Users/myusername/Copy/Projects/Project2/myFile.swift

without Project1 in the path. 路径中没有Project1

How can I solve this problem? 我怎么解决这个问题? Also, I changed from Xcode Identity and Type section Location of my project. 此外,我更改了我的项目的Xcode Identity and Type部分Location

  1. Change you folder name in you finder "Project1" to "Project2" 将查找器“Project1”中的文件夹名称更改为“Project2”

  2. Remove "myFile.swift" file from project (copy on Desktop) 从项目中删除“myFile.swift”文件(在桌面上复制)

  3. Restart Xcode. 重启Xcode。 Copy "myFile.swift" in project select "Copy file to folder" hope this will help. 复制项目中的“myFile.swift”选择“将文件复制到文件夹”希望这会有所帮助。

Renaming projects in xcode in one of the most annoying things in iOS development. 在iOS开发中最烦人的事情之一,在xcode中重命名项目。 I assume you want to rename your app. 我假设您要重命名您的应用。 I faced this problem once and figured out a simple, clean way to do it. 我曾经遇到过这个问题,并想出了一个简单,干净的方法来做到这一点。

  1. Go back to the point where everything worked. 回到一切正常的地步。
  2. Open project in xcode and click on the project icon in the project structure( first file) 在xcode中打开项目,然后单击项目结构中的项目图标(第一个文件)
  3. Go to the info tab 转到信息标签
  4. Search for Bundle Name . 搜索Bundle Name Most probably it will automatically be set to $(PRODUCT_NAME) which is a shell variable that will set your app name the same as the project name. 最有可能它会自动设置为$(PRODUCT_NAME) ,这是一个shell变量,可以将您的应用名称设置为与项目名称相同。
  5. Set it to whatever you want your app name to be 将其设置为您想要的应用名称
  6. Done 完成

Note : 注意 :

  • If you use custom URL Schemes this might produce an error when redirecting. 如果使用custom URL Schemes ,则重定向时可能会产生错误。
  • ALWAYS use git or some other SVN in your projects. 总是在你的项目中使用git或其他一些SVN。 This will come in handy in this kind of situations 这将在这种情况下派上用场

Today I had the same problem when I renamed the folder containing the Xcode project and some parent folders of it. 今天,当我重命名包含Xcode项目的文件夹及其中的一些父文件夹时,我遇到了同样的问题。

In my case there where a .swift file shown with it's name in red in the list of files of Xcode (Navigator area). 在我的情况下,在Xcode(导航区域)的文件列表中,.swift文件以红色显示。 I think that this means that Xcode was not capable to find that file. 我认为这意味着Xcode无法找到该文件。

I selected that file (actually it's not a real file but a representation of it). 我选择了那个文件(实际上它不是真正的文件,而是它的表示)。

Then, in the File Inspector (Utility area), I clicked on the Folder icon and chose the file on Finder. 然后,在文件检查器(实用程序区域)中,单击“文件夹”图标并在Finder上选择该文件。

在此输入图像描述

This worked for me. 这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM