iOS - Unable to build, header missing (although present in folder) - ios

I installed HTMLKit via pods.
Everything went well and I am able to see it loaded.
Unfortunately, when I try to build the project, it fails telling me that it couldn't find a specific header.
This is how I import the pod in my file:
#import "../../../Pods/HTMLKit/Sources/HTMLParser.m"
I am no expert in objective c so I am not sure if that's correct. One thing that is weird is that I always imported header files, but this time it seems that I need to import an .m file?
If I try to import the header file of that, it simply says that the header is not found (although, as always it's there in the folder).
I am not sure how to fix it. I've seen some answers here on SO but they all use a different version of xcode so I am not sure what to do.

Try #import <>
And if it show you something automatically I think it will work.
Again, Not “”. Use <>.

Related

Xcode refuses to let me import Swift files to Objective-C files ('projectname-swift.h' not found)

I downloaded this Xcode project and I want to use my Swift files in the Objective-C files but the 'OpenShop-Swift.h' file not found error refuses to go away.
I have tried what seems like every solution on Stack Overflow, including from here and here. Most other solutions were duplicates of the common:
In build settings, set defines module to yes and product module name for the target to your project name and make sure objective-c generated interface header name is correct.
This top solution seemed promising but I am having trouble understanding what he was saying.
If you decide to give it a whirl, just know that the project lacks a working backend and won't compile properly if you get past the file not found error. But, if you add to one of the .m files you should be able to get the error before the project finishes compiling.
Technically, this is not a duplicate since all the other solutions have failed.
I have found the solution thanks to #skladek. I created a swift file and allowed Xcode to create a bridging header file for me when it asked, and the error went away.
I thought the bridging header file (OpenShop-Bridging-Header.h) was to allow the importation of Obj-C code to Swift files and not vice-versa. Thus far everything I have read on the internet has corroborated this, so it's not clear to me why this solution works. Thanks to #skladek once again.

import swift class in objective-c, <myModule>-Swift.h file not found

I have an iOS project written with Objective-C. I created an Swift class in the project, the bridging header file for accessing objective-c in Swift is generated successfully, and it works fine.
My problem is the other way around. I want to import Swift class in objective-c code.
In xcode, target -> Build Settings--> Swift Compiler section, I see Objective-C Generated Interface Header Name field with value myModule-Swift.h , but when I import this header in my objective-c class:
#import "myModule-Swift.h"
I get compiler error:
myModule-Swift.h file not found
and in project, I cannot find this file either. How can I solve this problem?
My xcode version is 6.4
Updated May 2018 Xcode 9.3
Build Settings->Objective-C Generated Interface Header Nameand set the value to YourModule-Swift.h (this is usually already set, this is the filename you need to import on .m file #import "YourModule-Swift.h"
(Example, Project named CData)
Same as Step 1, Go to Build Settings and search for "Defines Module", set both values to YES
Create a class that extends NSObject on .swift file
Build the project again
Import YourModule-Swift.h file on .m file (Please notice it's case sensitive, Mymodule !== MyModule)
In case anybody is wondering why after spending hours on this issue it is still unresolved, you might be in a situation similar to mine, where I was actually developing a framework, rather than an app.
In such case, the format of the import statement for Objective-C Generated Interface Header is as follows:
#import <ModuleName/ModuleName-Swift.h>
OMG.. the actual import statement was not "class-Swift.h" but rather "projectname-Swift.h"
You can find the name of the file if you look under build settings->Swift Compiler Code Generation -> Objective-C Generated Interface Header Name
The file was not generated when I dragged in Swift source into the GUI. Only when I right-clicked->Add file to "project". It then asked to generate the header files.
My addition to Daniel Kroms answer:
Never add -Swift.h Header to header. Even if it seems to work. Add the Import to .m file only!
In case you use in your header swift classes, make a forward declaration with #class swiftclassname before your #interface
Then you will see your real errors in your code.
For me, the problem was that I had bitcode on. When I clicked on the "Update to recommended project settings", it changed a few settings which probably the culprit. I turned "Enabled Bitcode" to "No" in the Build Settings and it is fixed now.
I was stacked this for a quite a while. In my case, my target name is something like "my-app" using dash as a part of target name. I tried to #import "my-app-Swift.h", but Xcode kept giving me errors.
I dug under 'DerivedData' folder and I found "my_app-Swift.h". So if you are using some interesting characters for the target name. You may try replace those with underscore _.
I ran into the same issue yesterday and worked for hours to fix it with no avail. Others may have been in the same boat as I. I did all of the steps described above, but nothing worked.
The cause of mine breaking was because of project name artifacts all over my project (from previously changing its name improperly).
If all of the above steps fail, I would suggest doing like I did and renaming your project so that Xcode can reset somethings... That solved the problem for me.
Doing so worked like a charm!
In my case, I have forgotten to check a swift framework to the target/classes that I was using it, really specifically case but it may help someone in the future.
For me the solution was to create a new target. For an unknown reason, the target that I had didn't have that "Swift Compiler - General" settings and thus no to "Objective-C Generated Interface Header Name" field. Having that field specified in the project was not enough.
This is not an exact answer but more of a workaround, but can save you time in some difficult cases. If you, as suggested by some of the the previous answers, can actually find the swift header buried inside the derived data folder, you are allowed to import it using the full path. This is not specific to the swift header, instead it can be applied to any header. Hope you can find this answer useful.
This answer solves my problem, but what's confusing to me is that when I convert bitcode to YES, then clean Xcode DerivedData, bulid again,also Bulid succeeds

referring to an installed pod within Prefix.pch

Finally taking on pods. Everything seems to work, for example, dropped in Parse, install pod'd, see it in a view controller.m file just fine.
BUT.. now i want to drop Parse into the pch as i use it so often. My pre-pods line was:
#import "Parse/Parse.h"
I tried this, and
#import <Parse/Parse.h>
and
#import <Parse.h>
.. and every variant i can think of, no luck. I can of course drop imports where required, but this is more convenient, despite the suggestions not to use this route.
What i find most confusing is that the UI pre-fills in the path for me for second option, so it finds it, but on build, it fails with
'Parse/Parse.h' file not found.
Thanks for suggesting a working syntax.
This may not be the perfect answer, as there are so my cocoapods fans using the repo that this is likely due to my newness to it, but i had to manually create an entry into User Header Search Paths which was "Pods" and set it recursive.
Then all was good.

Importing a Header File and Having .m Changes Carry Over in Xcode

For my first iPhone app, I've been using SDWebImage on Github to pull images from the internet.
This package comes with a SDWebImage.framework. I've been able to import that header file with "#import SDWebImage/UIImageView+WebCache.h which is fine so far.
However, I needed to make the cache time much shorter, so after reading some on this subject, I imported the package's Xcode project into my app. By adding those files, I can now see a WebImageCache.m file separate from the header files in the framework. Unfortunately, I can't figure out how to get my work in the .m file to impact how my view controller imports SDWebImage. I've found where I need to change the maxCacheAge, but it's no good if I can't get Xcode to read it.
Any ideas? Thanks!
remove the framework or you'll have the same class/category twice -- copy the header next to the m file in your project

cant import NYXImagesKit library

I am trying to import the NYXImagesKit library in to my iOS 5.1 project but it will not show up as importable code. It cannot find the library. I have dragged the NYXImagesKit library in to the project and added the libraries. I have also added the following to my build phases:
However I still get an error saying it cannot find NYXImagesKit.h when i try to import it.
NYXImagesKit can be found from here: https://github.com/Nyx0uf/NYXImagesKit
Ive used this in a previous project so I know that it works.
screenshot of location of .h file:
header search paths:
You are not having an issue with "importing" the library proper. (I would not like to appear pedantic, but a library is linked, not imported). The issue you are having is with the header file which comes with the library.
To fix it, you should make sure to add the path to NYXImagesKit.h in your project build sentting (Search Headers Path). This can by found under Build options in your project settings.
Alternatively, an easier way is to add the NYXImagesKit.h file to your project (like any .m file). Then it will be found without the need to specify an header search path.
EDIT:
Since from what you report, everything seems ok, he only idea I can come up with is making sure that the paths are defined for your target (as opposed to the project overall); but I guess it is already like that.
Other than that, only resort is thinking that the project got corrupted somehow. You can inspect the project.pbxproj file inside your .xcodeproj document with a text editor and ensure that everything looks fine.
If everything fails, just start over with a new project.

Resources