1

Hope all of you'll be fine.
I am doing a project in which i need to add core-data functionality. I am working on xcode-5. I need to add pch file in xcode-5 existing project as it was missing in the project. I have searched a lot on net to add pch file in xcode-5 but only found procedures to add pch file in xcode-6. which is totally different with xocde-5. Please provide step by step help to add pch file in xcode 5 (as I am new to ios). Many thanks in advance.

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
Zeebok
  • 388
  • 1
  • 4
  • 15
  • You don't need a pch file, it's only ever a convenience. Not every file in your project needs the import so you should import just where you need it... – Wain May 17 '15 at 16:53
  • Dear @Wain, Thanks for your such a quick reply. Actually i really don't know that while using core-data where it will be needed to import Coredata.h. So thats why i need to import pch file in my project. – Zeebok May 17 '15 at 16:59
  • Strictly, you don't need to import Coredata.h anywhere. Import the classes that you use in the files that you use them. If you import more than 5 Core Data files in one file then consider importing Coredata.h instead. – Wain May 17 '15 at 17:20
  • ok, fine and many thanks for your consideration dear @Wain. – Zeebok May 17 '15 at 18:25
  • see also: http://stackoverflow.com/questions/322597/class-vs-import – Wain May 17 '15 at 18:32

1 Answers1

0

Here is how you can set the prefix header, it has to be done in the target's build settings:

In Xcode and in your open project, select the project-icon in the upper left corner so you can see the PROJECT and the TARGETS.

Select the target where you want to add the prefix header file. On the right side, select Build Settings. In the search field on the right side, type prefix header to reveal the setting Prefix Header quickly (and at the left side of the search field, select ALL).

The path to put here is either an absolute path or a path relative to the Xcode project-file.


Here an example of a prefix header file that I use to share the DSLog macro:

// Zero-Prefix.pch

#ifdef __OBJC__
    #import <Cocoa/Cocoa.h>
#endif

#ifdef DEBUG
#   define DSLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define DSLog(...)
#endif