Xcode not creating .h file - ios

I am using Xcode 6.0.1
I created a new project which automatically generated .h and .m files .
When I try to add a new Objective-C file, it is only creating .m file. .h file is not getting generated.
I tried all preferences, nowhere i found an option which says "Generate .h file".
Out of curiosity I checked Library/Developer/Xcode/Templates where only one folder exists.
/Users/rajeshreddy/Library/Developer/Xcode/Templates
Rajeshs-MacBook-Pro:Templates rajeshreddy$ ls
File Templates cocos2d v3.x
Rajeshs-MacBook-Pro:Templates rajeshreddy$
Is there any setting which I can enable to generate .h file?

You need to create a new CocoaTouch class, like this:
And that should give you both a .m and a .h file.

Related

imported xcode generated swift header not found in .pch file

I have recently added a Swift file to my Objective-C only project. Xcode created the necessary header files, including the Objective-C Generated Interface Header. Everything works fine if I #import this header file "myProject-Swift.h" to the .m file where I am accessing the Swift class I have added.
However I will want to eventually use this Swift class throughout my project, and to avoid importing it every single time, I wanted to add this myProject-Swift.h import file to my .pch prefix file.
However when I try to build my app after having added this, I get a 'myProject-Swift.h' file not found error and the build fails.
Does this mean it is not possible to import this myProject-Swift.h in a .pch file?
Is it really only possible to do it in each .m file individually?

.pch replacement to put constant file

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
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.
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.
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.

XCode Can't Find Imported header from framework

I am getting an error that it can not find the header file, but I have added the file via "link binary with library" under Build Phases.
The file is WhirlyGlobeComponent.h
and I imported... #import "WhirlyGlobeComponent.h" and it said that the file can not be found.
What could I doing wrong. I have already cleaned the project.
Just drag and drop the .h and the .m file into your swift project. Then Xcode should create a Briding-Header.h file for you. In there you have to add the .h file:
#import "WhirlyGlobeComponent.h"
After that, you should be able to use the WhirlyGlobeComponent without any additional imports in your swift files.

Mixing Swift and Objective-C : "ProjectName-Swift.h" file not found

I'm working on an iOS project that contains Swift and Objective-C Classes.
To instantiate an object described in Objective-C, I've understand that I needed to have a Bridging-Header file that contains all the imports of the headers I will have to use on my Swift classes. And it works great on my project.
I made all classes I needed, I subclassed Objective-C classes in Swift, everything is OK.
My problem is when it comes to do the opposite: instantiate a swift object in an Objective-C file. So I read that I need to have those options:
Define Modules as Yes
add the line #import "<#YourProjectName#>-Swift.h" on the *.m file I'm working on.
And that is what I did:
I changed all the values on the Build Settings that needed to be changed. I added the import line, I even tried to create the header file, but I still have the "<#YourProjectName#>-Swift.h" file not found error.
Of course, I replaced the YourProjectName by the actual module name, the one I found under Product Module Name in Packaging section on Build Settings. Also, there is no spaces in the Project Name.
Did I forgot a step?
Make sure you are importing the -Swift.h file from a .m Objective-C file and not a .h header file. The docs only talk about importing from .m:
... import the Xcode-generated header file for your Swift code into any Objective-C .m file you want to use your Swift code from.
The -Swift.h file is generated during the build and I've found that importing it from a .h file always fails, even when I know the file exists. Since it's generated by the build, I'm guessing it's cleaned out when the compiler is sifting through the headers and regenerated once the .swift files are compiled.

Xcode 6 not generating .h file

I upgraded to Xcode 6, now when I add a new Objective-C file it does not automatically create a .h file.. Am I missing something? Has anyone see this issue?
Header files used to be created automatically when you create a .m file. When upgrading to Xcode 6, sometimes the "automatically create header file" box becomes unchecked. Make sure this box is checked when creating a new .m file.
This only works with CocoaTouch classes, it looks like it does not work with regular .m/Obj-C classes

Resources