2

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

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

 /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.

Community
  • 1
  • 1
Nik
  • 2,913
  • 7
  • 40
  • 66

5 Answers5

2

Replace these :

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

with :

#import <objc/objc-class.h>
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
2

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.

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.h is 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.

Greg
  • 8,230
  • 5
  • 38
  • 53
  • cleaning and rebuilding process dint work and I tried to search the file with name objc-class on my machine but I am not able to find it. – Nik Mar 21 '12 at 14:35
  • What you get when you open terminal and execute: ls /usr/include/objc/ – Greg Mar 21 '12 at 15:49
  • this is what I get ls: /usr/include/objc: No such file or directory – Nik Mar 21 '12 at 16:15
  • Folder /usr/include/objc is a standard include folder that contains headers for ObjectiveC and it should be created automatically when installing XCode. If you don't have that folder then it means there is something wrong with your installation. Which version of XCode are you using? – Greg Mar 21 '12 at 16:23
  • I tried finding the files with the following command - find / -name objc-class.h and found the following /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/usr/include/objc/objc-class.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/usr/include/objc/objc-class.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/objc/objc-class.h – Nik Mar 21 '12 at 16:27
  • That only proves that there is a problem with the installation. Looks like XCode wasn't properly installed after upgrading to 10.7. As far as I remember the distribution of XCode 4.3 has changed (now it's through App store) and thus it's location on disk. I don't know the specific configuration of your comp and it may be difficult to suggest the proper solution. Maybe you can try to uninstall XCode completely (and deleting all XCode folders from Applications and other folders where you can find it) and reinstall it? – Greg Mar 21 '12 at 16:34
  • Once XCode is installed it should create the /usr/include/objc folder automatically. Apparently it is in the installation folder (/Applications/XCode.app/Contents/Developer....) but hasn't been copied properly. Just a thought, can you try to manually copy the whole folder from the path that you found (e.g. /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/S‌​DKs/MacOSX10.7.sdk/usr/include/objc) to /usr/include ? – Greg Mar 21 '12 at 16:42
  • thax for the help.. I tried that and getting this now Interface Builder is unable to open documents of type CocoaTouch XIB. – Nik Mar 21 '12 at 16:55
  • Looks like another folder hasn't been copied correctyly too. I bet you will have this sort of problems until your XCode has been installed properly. – Greg Mar 21 '12 at 17:00
0

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

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

Trausti Thor
  • 3,722
  • 31
  • 41
0

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.

Stunner
  • 12,025
  • 12
  • 86
  • 145
0

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