xcode 在ios中获取文件未找到错误

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

getting file not found error in ios

iosxcodesharekitfile-not-found

提问by Nik

Hi I am new to iOS development. Here is my problem.

嗨,我是 iOS 开发的新手。这是我的问题。

I am given a mac machine with 10.6.X and Xcode for the same. I am given a pre-written project for iPhone. I wanted to run the project on my iPhone so I had to upgrade my mac and Xcode to 10.7.x and the xcode for the same. I had to do this as my iPhone was running on iOS 5.1. So my problem is that before upgrading the project was getting compiled and running properly on simulator but now after upgrade I am getting the following error

我得到了一台装有 10.6.X 和 Xcode 的 mac 机器。我得到了一个预先编写好的 iPhone 项目。我想在我的 iPhone 上运行这个项目,所以我不得不将我的 mac 和 Xcode 升级到 10.7.x 以及相同的 xcode。我不得不这样做,因为我的 iPhone 在 iOS 5.1 上运行。所以我的问题是,在升级项目之前,在模拟器上编译并正常运行,但现在升级后我收到以下错误

 /usr/include/objc/objc-class.h file not found

I googled a lot, but all the search if pointing to the same link as given in this link

我用谷歌搜索了很多,但所有搜索都指向与此链接中给出的链接相同的链接

This link did not work for me as when I try to change the import statement it leads to more 5 to 6 errors.

此链接对我不起作用,因为当我尝试更改导入语句时,它会导致更多 5 到 6 个错误。

回答by Greg

Not sure if that will help, but sometimes XCode messes up the cached data when changing the imported .h files. Try to delete the project derived information, e.g. organizer->projects->Derived Data. Then clean the project and rebuild.

不确定这是否会有所帮助,但有时 XCode 在更改导入的 .h 文件时会弄乱缓存的数据。尝试删除项目派生信息,例如管理器->项目->派生数据。然后清理项目并重建。

Also, the solution that you reference is system specific, which may explain why it doesn't work for you. In particular:

此外,您参考的解决方案是特定于系统的,这可以解释为什么它对您不起作用。特别是:

#import </usr/include/objc/objc-class.h>

Notice the /usr/at the beginning of the import. This means that the file will be loaded from an absolute path starting from the root folder /, which may be different on Mac or various flavors of Linux. Try to find where exactly the file objc-class.his located in your system and either add that path to the Header Search Path (XCode Targets -> Build Settings, section Search Paths) or add the import with location specific for your system.

请注意/usr/导入开始处的 。这意味着文件将从根文件夹开始的绝对路径加载/,这在 Mac 或各种风格的 Linux 上可能不同。尝试查找文件objc-class.h在系统中的确切位置,然后将该路径添加到标题搜索路径(XCode 目标 -> 构建设置,搜索路径部分)或添加具有特定于您系统的位置的导入。

回答by Paresh Navadiya

Replacethese :

Replace这些 :

 #import </usr/include/objc/objc-class.h>

with :

和 :

#import <objc/objc-class.h>

回答by Stunner

Got this issue with Xcode 5. I had to remove and re-add the library to my project in order for it to work. I deleted (moved to trash) and then re-added.

在 Xcode 5 中遇到了这个问题。我必须删除该库并将其重新添加到我的项目中才能使其正常工作。我删除(移到垃圾箱)然后重新添加。

回答by Hafiz Muhammad Farooq Rasheed

You just have to replace this #import /usr/include/objc/objc-class.h with only #import folderName/objcClassName.h

你只需要用#import folderName/objcClassName.h替换这个 #import /usr/include/objc/objc-class.h

回答by Trausti Thor

After xcode 4.6 this breaks again. I just fixed this like this :

在 xcode 4.6 之后,这再次中断。我只是这样解决这个问题:

cd /usr/include/
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/objc .

Now it works like a charm

现在它就像一个魅力