Bridging header issues, Missing header files when run on device - objective-c

I have following lines on my Bridging-Header.h
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#import "FMDB.h"
#import "UAProgressView.h"
#import "ASValuePopUpView.h"
#import "ASValueTrackingSlider.h"
#import "JZMultiChoicesCircleButton.h"
#import "VYPlayIndicator.h"
#import <AVFoundation/AVFoundation.h>
It works great with no errors when I run it on the simulator.
But when I run it on the device, it highlights with error "'FMDB.h' file not found". If you remove the line "for testing purpose" the error goes to the next line and so on.
What could be the problem when I run it on the device????!!!

In Xcode, select your project target, build setting and search for 'objective-c bridging header'. make sure the path equals the path of your bridging header file

Related

Trouble testing Swift in Objective-C test

I am testing myObjCClass which uses a forward declaration to get a Swift class I'm using, I did this because I was getting "failed to emit precompiled header" if I imported the Bridging Header in the .h file. In forward declaration my bridging header import (-Swift.h) is in the .m file. When I try to test this I am able to test my Swift Class but not the classes that inherit from this. I have tried adding #import "MyProject-Swift.h" in my test but I will get the error file not found.
- Obj-C.h file:
// forward declaration
#class mySwiftClass;
- Obj-C.m file:
//import bridging
#import "MyProject-Swift.h"
- Obj-C-Tests.m file:
//import that fails
#import "MyProject-Swift.h"
How can I fix this? I just want to test the Swift classes I am using in my Objective-C code.
I have already tried making a new bridging header and importing the main target one into the new test target bridging header, that will give me another "failed to emit precompiled header" I have also tried to set the test target bridging header to the main targets bridging header.
The problem is that the -Swift.h bridging header file is generated automatically into the DerivedSources directory, which is not in the header search path of other targets.
Therefore, you need to add it:
Open the the test target settings
Navigate to Build settings -> Search Paths -> Header Search Paths
Add the value $CONFIGURATION_TEMP_DIR/Your-project-name.build/DerivedSources
Now the import (and everything) should work:

Cannot find protocol declaration when protocol is declared in its own .h file

I created a protocol
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
// Defines the protocol that must be implemented to be a delegate for UCMapviewController
#protocol UCMapviewDelegate <NSObject>
#required
- (void)pushMapviewRight;
#end
When I go to new file -> protocol, there is a prompt which asks for the target. I check my project. But when i click the protocol.h file in my project and look at file inspector, at "Target membership", my project is unchecked and I cannot check it.
I don't get this error when I put the protocol in the header file of one of my viewControllers (for example). Do I have to import the protocol somewhere else?
WHat is wrong? Help is greatly appreciated! thx
Header files don't go into a target, unless you're building a framework and want to copy the header file into the Headers folder in the framework. When building an app, only source files belong to the target.
You'll notice that if you select one of your other headers in your project, it will also not be in the target. Only the corresponding source file will be. This won't matter. If the header is in your project, you can #import it just fine.

Compiling in Xcode

I'm compiling a project that was copied from another application file by file from XCODE IDE.
After compilation I get the following error:
Error: could not read data from '/Users/heziflashner/Documents/#import <UIKit/UIKit.h>
#import "MapKit/MapKit.h"
#import "CoreLocation/UserLocationAddress/salesShare03/salesShare03/salesShare03-Info.plist':
The file “salesShare03-Info.plist” couldn’t be opened because there is no such file.
I'm trying to change the framework directory but with no success.
Any one can help?
For framework headers you must use:
#import <MapKit/MapKit.h>
The problem seems to be that you have a file making a reference to saleseShare03-Info.plist. Be sure you have that in your project tree, even try to remove it and then add it again. Else check your .xcodeproj file and check the settings. Copying a project this way is always tricky, good luck.

error: libxml/parser.h: No such file or directory

I'm attempting to use XML (Chapter 10 in Professional iPhone and iPad Database Application Programming), and I've run into a bit of trouble.
Under Header Search Paths in Build Settings I have this path:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/include/libxml2/
That's all fine and well, but then:
#import <libxml/parser.h>
#import <libxml/tree.h>
error: libxml/parser.h: No such file or directory
If I flip the imports:
#import <libxml/tree.h>
#import <libxml/parser.h>
error: libxml/tree.h: No such file or directory
Weird.
For now I have this:
#import <libxml/catalog.h> // Dirty hack
#import <libxml/parser.h>
#import <libxml/tree.h>
error: libxml/catalog.h: No such file or directory
But that's no good for a production app.
Try changing your header search path to ${SDK_DIR}/usr/include/libxml2.
As it turns out, it was a trivial fix. I closed the project to work on another, and when I reopened it, the error was gone. Not exactly what I would have expected, but hey, it works now.
"When in doubt, reboot."

Encountering One-off Issue Integrating Dropbox SDK?

I have downloaded the Dropbox API for Objective-C/iOS devices, and I am able to successfully build and run the DBRoulette application.
When I follow the README directions for including the API in my project, I have an enormous number of build errors, all appearing to be related to missing the Foundation header. (Eg. Can't find the interface declaration for NSObject, NSString, etc.)
Many of their header files don't include any other headers at all. Don't all .h files need to import Foundation.h if they extend NSObject? This doesn't seem to be the case, as the example project (DBRoulette) builds and runs fine without the Foundation header declarations, but my own application fails miserably.
I must be missing some sort of project setting, but I can't determine what it is.
Screenshot of One Failing Class
In their example app, they have
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
in their prefix header file (DBRoulette_Prefix.pch). This file is automatically prefixed to all source files in the project, so the appropriate headers are found. You can either put the #import directives in the source files themselves, or do what they did and edit the .pch file for your project.