如何解决无法读取 Xcode 中“/Users/path/myapp/Images.xcassets”的文件属性?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44842036/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:05:51  来源:igfitidea点击:

How to resolve Failed to read file attributes for "/Users/path/myapp/Images.xcassets" in Xcode?

iosxcodemacosassetsxcode9

提问by Anilkumar iOS ReactNative

Suddenly I am getting error in Xcode 9 beta like

突然间,我在 Xcode 9 beta 中遇到了错误,例如

"Failed to read file attributes for "/Users/path/myapp/Images.xcassets" in Xcode?" and unable to build as well I just dragged the "Images.Xcassets" folder to up that's it.

“无法在 Xcode 中读取“/Users/path/myapp/Images.xcassets”的文件属性?” 并且无法构建,我只是将“Images.Xcassets”文件夹拖到了上面。

I checked targets, Copy Bundle Resources and "Images.Xcassets" folder existed. But, I am unable to build the project.

我检查了目标,复制捆绑资源和“Images.Xcassets”文件夹存在。但是,我无法构建该项目。

回答by Chris Yim

I found out that my folder name is images.Xcassets, which Group name and Full Path is Images.xcassets. You should check your group name and full path in File inspector.

我发现我的文件夹名称是images.Xcassets,其中组名称和完整路径是Images.xcassets。您应该在文件检查器中检查您的组名和完整路径。

enter image description here

在此处输入图片说明

EDIT:
Here are two solutions:
1. Remove the group from Project Navigator (ALT+1), and add files back again (OPTION+ALT+A).
2. Click the folder icon from File Inspector (OPTION+ALT+1) and choose a new folder.

编辑:
这里有两个解决方案:
1. 从项目导航器 (ALT+1) 中删除组,然后再次添加文件 (OPTION+ALT+A)。
2. 单击文件检查器中的文件夹图标 (OPTION+ALT+1) 并选择一个新文件夹。

回答by Jamshed Alam

It's an issue of latest Xcode9. There are two ways to solve this issue.

这是最新的 Xcode9 的问题。有两种方法可以解决这个问题。

Follow these:

遵循这些:

  1. Remove reference the images.Xcassets file from your project. Once you remove it from project and add to project again solved my problem.
  1. 从您的项目中删除对 images.Xcassets 文件的引用。从项目中删除它并再次添加到项目后,我的问题就解决了。

enter image description here

在此处输入图片说明

  1. If option 1 don't work, delete(Trash) the full images.Xcassets file and add all icon again.
  1. 如果选项 1 不起作用,请删除(垃圾箱)完整的 images.Xcassets 文件并再次添加所有图标。

Make sure you add this in your icon name Build settings.

确保将其添加到您的图标名称构建设置中。

回答by Smart guy

"Quit the Xcode and restart." it worked out for me. I got the same problem with Xcode-9.0. I have tried it in multiple ways like deleting Derived data, Cleaning the project and closing the Xcode but nothing worked.

“退出 Xcode 并重新启动。” 它对我有用。我在 Xcode-9.0 上遇到了同样的问题。我以多种方式尝试过,例如删除派生数据、清理项目和关闭 Xcode,但没有任何效果。

Delete your derived data and then Quit X code Cmd+q quit the xcode and open it again.

删除您的派生数据,然后退出 X 代码 Cmd+q 退出 xcode 并再次打开它。

回答by Leonir Alves

I had this same problem though, using local pods. It seems that xcodebuild is now case sensitive relative to the resource path. ~/Folder/MyProject != ~/folder/MyProject

不过,我使用本地 pod 时遇到了同样的问题。似乎 xcodebuild 现在相对于资源路径区分大小写。 ~/Folder/MyProject != ~/folder/MyProject

回答by Fran

Closing and reopening Xcode fixed the problem for me

关闭并重新打开 Xcode 为我解决了问题