28

This is my .pch file -

   //
// Prefix header for all source files of the 'English Club' target in the 'English Club' project
//

#import <Availability.h>

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import <CoreData/CoreData.h>
    #import "Helper.h"
    #import "Animations.h"
    #import "Constants.h"
    #import "SoundPlayer.h"
    #import "UAirship.h"
    #import "UAStoreFront.h"
    #import "UIIMagesNames.h"
    #import "UIView+Sizes.h"
    #import "HelpButton.h"
    #import "SoundPlayer.h"
    #import <RestKit/RestKit.h>
    #import "UIHelpSoundFiles.h"


#endif

Still it is very frequent that Xcode will give me errors that he can not find those classes. (Helper for example). The thing is that the project will be compiled and work fine but I have hundreds of errors that disturb me looking for the real ones.

Any idea why?

leppie
  • 115,091
  • 17
  • 196
  • 297
shannoga
  • 19,649
  • 20
  • 104
  • 169

6 Answers6

85

This appears to be a known issue in Xcode 4.4 (as seen in the release notes)

It is suggested to Delete the PCH index folder to workaround this issue.

To locate this folder, in Xcode, open the Organizer and select the Projects tab, then select the project in the left-hand pane. You should see the Derived Data path for this particular project with a small arrow to Show in Finder. If you click on this arrow, you will be taken to the right location in Finder. If you then navigate to the Index subfolder and delete PrecompiledHeaders folder, you should be all set.

Xcode should re-index, and re-create this folder, but the errors should be gone.

  • 3
    Thanks man!. That was driving me crazy!. Still happens with Xcode 4.6 ¬_¬ – rmvz3 Feb 19 '13 at 02:34
  • 1
    Worked here too in Xcode 4.6.2. My categories were not detected by code completion anymore. Thanks! – Form May 09 '13 at 01:43
  • Deleting the derived data completely didn't work but your solution fixed it for me, thanks. – Yunus Nedim Mehel Mar 10 '14 at 08:37
  • 2
    Still happening in XCode 5.1.1! I recently enabled FileVault, maybe that adds to the issue? Wish I could upvote this again after you helped me fix this problem twice a year apart! – Rembrandt Q. Einstein May 15 '14 at 16:09
  • 3
    Still an issue for me in 5.1.1 too. The crazy thing is that I already tried deleting all Derived Data, but that didn't work... But going into the Derived Data folder and deleting the PrecompiledHeaders folder did! Huh... – jowie May 28 '14 at 09:25
18

I found that just updating your pch file (add and delete space) and rebuild will cause xcode to fix those problems

Yariv Nissim
  • 13,273
  • 1
  • 38
  • 44
3

I know this is an old post but I wanted to share my experience. Im running Xcode 6.1 the fix was to delete the Tests target. for example MyProjectNameTests.

otakuProgrammer
  • 298
  • 2
  • 12
1

Also check if both your app.pch and the app_Test.pch have the required imports. Sometimes you might be staring at the main pch, but the errors are for the unit tests pch.

Jelle
  • 1,024
  • 10
  • 18
1

Xcode 5 Update:

You can now delete derived data straight from Xcode Organizer. Delete, clean, and build solved the problem for me.

enter image description here

Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141
0

Also one of the problem could be that .pch file is not set for a target. To do that do the following:
1. Go to the target settings.
2. Option Precompile Prefix Header set to YES.
3. For Prefix Header add a project relative path or an absolute path.

Sergio
  • 1,702
  • 1
  • 20
  • 24