1

ProjectName-Prefix.pch is Missing in Xcode 6.

We can create .h file and use #define to create constants and then include this file to prefix file of our project before Xcode 6.

Sample constant.h file

 #define OK @"OK"

Go to View Controller include file in header #import "Constants.h" OR Define in pch file ,so that all View controllers can access the file

In viewDidLoad

NSLog(@"%@",OK);

My question is

where to include my constant.h file so can be access the file from all view controllers like we did using .pch file?

EDIT: My question is replacement of .pch file ? As if apple remove it from Xcode their must be some alternate to achieve this goal without adding .pch and include in every single file to be used

9to5ios
  • 4,838
  • 2
  • 32
  • 59
  • 1
    You can add .pch file, check this link http://stackoverflow.com/a/26126037/5362916 – Uma Madhavi Jan 29 '16 at 06:17
  • 1
    I think your question has a pretty good answer here (http://stackoverflow.com/questions/24158648/why-isnt-projectname-prefix-pch-created-automatically-in-xcode-6) – Roohul Jul 12 '16 at 05:41

3 Answers3

1

You answered your question yourself. Here

We can create .h file and use #define to create constants and then include this file to prefix file of our project before Xcode 6.

You include the Common.h file inside the pch file. And you dont have to #import anything, as PCH file is available in all classes, and any import inside the PCH file is also available in all classes. Hence PCH files are termed as Pre-Compiled Header files.

Saheb Roy
  • 5,661
  • 2
  • 18
  • 34
  • my question is replacement of .pch file ? As if apple remove it from Xcode their must be some alternate to achieve this goal without adding .pch and include in every single file to be used – 9to5ios Jan 29 '16 at 09:16
0

You can configure a pch file in Build Settings->Prefix Header. Type in the path to the pch file or a .h file relative to the xcodeproj file.

-1

Yes You can create header file for Xcode. I am sure pch is best way to used whole application. You can import constant file on pch and used in whole application.