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

我只是一个虾纸丫 提交于 2019-12-10 10:32:00

问题


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?

回答1:


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/




回答2:


For CocoaTouch (iPhone) it's:

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

#import <Availability.h>

#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif



回答3:


if you deleted the pch header file, then pull it out of scm. if you don't use scm -- use scm (e.g. git).

if you're just referring to the precompiled result - xcode just rebuilds it as needed. it should never need to be rebuilt manually. if you actually need to rebuild it manually, you can locate it in your Derived Data directory (assuming Xc4), or simply clean the project and remove the precompiled headers during the clean. they will be automatically recreated on the next build.



来源:https://stackoverflow.com/questions/6567051/xcode-deleted-pch-file-by-mistake-can-it-be-recovered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!