Search code examples
xcodexcode-template

Xcode, deleted .pch file by mistake, can it be recovered?


As i understand it, .pch files are responsible for precompiling header files. Sounds like something that can rebuilt or recreated.

2 questions:

  1. Does Xcode have something similar to recycle bin from there file deletions can be undone?
  2. Is there a direct way to rebuild .pch file?

Solution

  • The .pch file is generally very simple, and its contents depends upon the project type. The basic idea is that it includes the heavyweight header files. Xcode itself doesn't modify this file beyond the basic template; it'd only be different from the template if you changed it yourself.

    For a Cocoa application, it is:

    //
    // Prefix header for all source files of the '%s' target in the '%s' project
    //
    
    #ifdef __OBJC__
        #import <Cocoa/Cocoa.h>
    #endif
    

    That's it! You can find all the templates in the SDK folder.

    iOS: /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/