XCode "File Not Found" error - ios

I am new to Xcode and i am working on a SoundBoard app. In my viewcontroller.m file, I typed in #import " (less than)AVFoundation/AVAudioPlayer.h", only to get the error "File not Found". I did add the AVFoundation.framework file though, so i don't understand why i am getting this error.
Help?

Your import statement should look like this
#import <AVFoundation/AVFoundation.h>
If you have declared it like this then you might have a problem with how you are adding the AVFoundation Library. In Xcode 4 you need to select the Project in the Project Navigator
Select the Build Phases tab and expand Link Binary With Libraries.
Click the + button and add AVFoundation.
Hopefully this corrects your issue otherwise its an issue with the Header Search Paths.

When you add your frameworks make sure you do not copy them to your project, just use them in their original locations. To find out where those frameworks are located right click on a framework and select "show in finder".
This has worked for me.

Related

objective-C #import with route

When I used a third-party SDK, I followed the guide to import the SDK package into my project by drawing the floder into the project navigator.
The guide show I can use it by adding:
#import "package.h"
but I got an error 'package.h' file not found.
Then I found using  #import "SDK/a/package.h" is OK.
The sample project given with the SDK also just use the name without path.
Am I use the wrong way to import the Code? or did I miss some steps before using them?
You need to enable "Target membership" option in project navigator for header file, under "Utility view".
If that does not work, make sure your ".h" file it's added on Build phases -> Headers -> Public.

FMDB not working in swift?

In my project I added FMDB using cocoapods. I then created a bridging header for FMDB. But when I import FMDB.h using #import "FMDB.h" I receive the error "FMDB.h not found".
When I import "#import " from folder, Xcode again gives me errors for importing inside FMDB framework files: "Include of non-modular header inside framework module (module name)"
What is the problem?
I had the same problem and found that none of the FM...h files were even in the folder being used by the code. Once I put them there, it worked.
If you highlight the FMDB.h file in the project navigator, you will see the path being searched for the files in the upper right corner of the screen under "Identity and Type" called "Full Path". If you check that physical location, you will likely find that the files are not there to be found.
enter image description here
Try going to the Build Settings tab under the "Target" and set Allow Non-modular Includes in Framework Modules to YES.
If that doesn't work, try selecting the FMDB.h file in the project navigator. In the target membership area on the right there is a drop down menu next to the target. Select "Public" there. It may be set to "Project" right now.
Hope that helps!

Adding FacebookSDK

I drag/drop facebooksdk.framework to my project(and i select copy items). I complete coded part and when i run my project it worked without any problem.
However when i close xCode and start xCode and run my project x code gives red error messages. Its;
"/Users/me/Desktop/xcode/swift/projects/projects/projects/projects-Bridging-Header.h:6:9: 'FacebookSDK/FacebookSDK.h' file not found"
and other one is;
"Failed to import bridging header '/Users/me/Desktop/xcode/swift/projects/projects/projects/projects-Bridging-Header.h'
The problem solved by re-added facebooksdk.framework file to my project. Did i have to always add this framework to my project(everytime i start this project xcode gives red errors)? Is there any way to fix that?
Thank you.
You need to import your facebooksdk.framework like this one inside projects-Bridging-Header.h
#import <FacebookSDK/FacebookSDK.h>

Importing static third party library

I've started iOS development this week and have run into an issue importing a third party SDK which is in the form of a static library.
This seems like it should be pretty straight forward but I can't seem to get Xcode to recognize the library.
The SDK ( due to an NDA I can't name the source) is in the form of two .a files, one of which is about 10kb and the other that is a little over 10MB. There is also an "includes" directory that has header files.
What I have done is highlight my project in the project explorer on the left, hit the "Build Phases" tab and under "Link Binary With Libraries" I add the .a file. Under build settings I go to "Search Paths" and I add the path to the includes directory under "User Header Search Paths".
Now in my project explorer I see the library I added under "Frameworks" as filename.a - however the icon is different than the other frameworks I have in that it looks like a blank document(don't know if that is relevant) and there is no arrow icon next to it that allows the framework to be expanded.
When I do an import of one of the header files e.g
#import "theAPI.h"
I get a header not found error. I know that this is one of the header files that are in the includes directory.
The steps I followed were in the XCode docs, I'm not sure what I am missing. If anyone had any suggestions on what could be going wrong here I would really appreciate it. Thanks!
Sounds like the problem is that xcode can't find your header files.
Double check your header search path.. if xcode can find it then it should auto-complete your #import statement for you.
You can also try to add the include directory into the library search path then you should be able to include headers like this:
#import <theAPI.h>

Xcode file not found

I am facing an error of file not found.
I have added all necessary files, but it gives file not found for a file.
#import "MagickWand.h"
for above file it gives error.
#import "FrameSection.h"
#import "FreeCropIphone5.h"
#import "DoodleView.h"
Please help me.
Clean the build folder by pressing ⌘ + ⇧ + k. It may help you to rectify the error caused.
There can be many cases that cause this error. This is one of the option to clear that error.
NOTE
As According to this kind of problem the reason may be sometime due to cyclic import. means like you have a file with the name first.h and you importing second.h and in second.h you importing first.h and you not including first.h.
Try these steps hope this will help you.
target of project -> Build Phases -> Compile Sources ->
delete the [found filename that cause the error in program].m
Add it back again in you project.
Clean Your iOS project And then Build Again.
I dragged folder in XCode, it started appearing blue and files in that folder wasn't accessible in Project anywhere although they does exists in blue folder.
Solution:
I simply deleted that folder reference from project, created "New Group" and added files in it, its started working correctly.
I was facing this error after a merge from the repository (git). The final solution was:
Delete the files from the xcode project navigator (only deleting references).
Add them again to the project (dragging from finder into the project navigator).
Hope it helps!
Check that your corresponding frameworks are included in your bundle.
For that, access to your project settings, select your target, and under Build Phases, check on the "Link binaries with libraries" section that your frameworks are here.
Use the search bar in the Target -> Build Phases window to make sure the missing file's .m is listed under the Compile Sources and the .h file is listed under the Copy Files. If it's not there, add it.
I was able to fix this problem by adding the missing .h file.

Resources