I see a demo using some class(RACCommand) without importing header file. It just
pod install
And then
#import <Foundation/Foundation.h>
#property(nonatomic,strong)RACCommand *fetchHotReplyCommand;
It works!
However, when I tried to copy his code, I need to import RACCommand.h.
#import <Foundation/Foundation.h>
#import "RACCommand.h"
#property(nonatomic,strong)RACCommand *fetchHotReplyCommand;
How does the demo work without importing the header?
Related
I have 50+ .scss files in 5 folders and use webpack plugin to import all files from folder.
// index.scss
#import "default/*.scss";
#import "vendors";
#import "components/*.scss";
#import "modals/*.scss";
#import "pages/*.scss";
This plugin work well with #import, but can`t understand #use. I think to extend plugin, but think if there is any other solution.
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:
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
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."
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.