I am getting this error "Use of '#import' when modules are disabled" when importing Firebase.
#import "GameKit/GKLocalPlayer.h"
#import "GameKit/GKScore.h"
#import "GameKit/GKAchievement.h"
#import Firebase;
#implementation AppController
#synthesize viewController;
How can I import this properly?
You could enable modules in your project's (or target's) build settings and leave it as #import Firebase; or you could import using #import <Firebase/Firebase.h>
Related
I have a current VueJS project and in attempting to add a bootstrap modal I am running into an issue where importing the bootstrap scss breaks/overrides the css of the project. How can I include Bootstrap css without overriding my current css?
I'm importing bootstrap into the top of my app.js file
import Vue from 'vue';
import { BootstrapVue } from 'bootstrap-vue'
Vue.use(BootstrapVue)
import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.min.css';
Importing bootstrap.min.css imports ALL of bootstraps styles so it will override any existing styles in your project. In your case, you only want styles for one module (Modal) and not the entire library.
The easiest way would be to only import the files you need, which in this case would be modal, instead of the entire library https://getbootstrap.com/docs/4.4/getting-started/theming/#importing
Just went through this so I can provide the specific code as of bootstrap-vue v.2.5.0. This is from the docs, but as mentioned, it will take a little digging to uncover where all the paths are so I've included them all here.
create a _custom.scss file (I put mine in src/assets/):
// required:
#import "./node_modules/bootstrap/scss/functions";
#import "./node_modules/bootstrap/scss/variables";
#import "./node_modules/bootstrap/scss/mixins";
// optional
#import "./node_modules/bootstrap/scss/root";
#import "./node_modules/bootstrap/scss/reboot";
// #import "./node_modules/bootstrap/scss/type";
#import "./node_modules/bootstrap/scss/images";
// #import "./node_modules/bootstrap/scss/code";
#import "./node_modules/bootstrap/scss/grid";
// #import "./node_modules/bootstrap/scss/tables";
#import "./node_modules/bootstrap/scss/forms";
#import "./node_modules/bootstrap/scss/buttons";
#import "./node_modules/bootstrap/scss/transitions";
#import "./node_modules/bootstrap/scss/dropdown";
#import "./node_modules/bootstrap/scss/button-group";
#import "./node_modules/bootstrap/scss/input-group";
// #import "./node_modules/bootstrap/scss/custom-forms";
#import "./node_modules/bootstrap/scss/nav";
#import "./node_modules/bootstrap/scss/navbar";
#import "./node_modules/bootstrap/scss/card";
// #import "./node_modules/bootstrap/scss/breadcrumb";
// #import "./node_modules/bootstrap/scss/pagination";
// #import "./node_modules/bootstrap/scss/badge";
// #import "./node_modules/bootstrap/scss/jumbotron";
#import "./node_modules/bootstrap/scss/alert";
// #import "./node_modules/bootstrap/scss/progress";
// #import "./node_modules/bootstrap/scss/media";
#import "./node_modules/bootstrap/scss/list-group";
// #import "./node_modules/bootstrap/scss/close";
// #import "./node_modules/bootstrap/scss/toasts";
// #import "./node_modules/bootstrap/scss/modal";
// #import "./node_modules/bootstrap/scss/tooltip";
// #import "./node_modules/bootstrap/scss/popover";
// #import "./node_modules/bootstrap/scss/carousel";
// #import "./node_modules/bootstrap/scss/spinners";
#import "./node_modules/bootstrap/scss/utilities";
// #import "./node_modules/bootstrap/scss/print";
#import './node_modules/bootstrap-vue/src/variables';
#import './node_modules/bootstrap-vue/src/utilities';
#import "./node_modules/bootstrap-vue/src/components/card/index";
#import "./node_modules/bootstrap-vue/src/components/dropdown/index";
// #import "./node_modules/bootstrap-vue/src/components/form-checkbox/index";
// #import "./node_modules/bootstrap-vue/src/components/form-file/index";
#import "./node_modules/bootstrap-vue/src/components/form-input/index";
// #import "./node_modules/bootstrap-vue/src/components/form-radio/index";
// #import "./node_modules/bootstrap-vue/src/components/form-tags/index";
#import "./node_modules/bootstrap-vue/src/components/input-group/index";
// #import "./node_modules/bootstrap-vue/src/components/modal/index";
#import "./node_modules/bootstrap-vue/src/components/nav/index";
#import "./node_modules/bootstrap-vue/src/components/navbar/index";
// #import "./node_modules/bootstrap-vue/src/components/pagination/index";
// #import "./node_modules/bootstrap-vue/src/components/pagination-nav/index";
// #import "./node_modules/bootstrap-vue/src/components/popover/index";
// #import "./node_modules/bootstrap-vue/src/components/table/index";
// #import "./node_modules/bootstrap-vue/src/components/toast/index";
// #import "./node_modules/bootstrap-vue/src/components/tooltip/index";
As you can see, I commented out what I wasn't using. Then simply:
// in main.js:
import "./assets/_custom.scss";
Do not forget to include node-sass and sass-loader to use scss in Vue:
npm install --save-dev node-sass sass-loader
Note: You may need to adjust the SCSS import paths based on your build environment.
I'
m using XLPagerTabStrip pod in my project,
i have a bridging header for other purposes to integrate from swift to objective c myproject-swift.h
i cant build the project and this error always pops:
Cannot find interface declaration for
'ButtonBarPagerTabStripViewController', superclass of
'ParentViewController'
This is my Controller
import Foundation
import UIKit
import XLPagerTabStrip
class ParentViewController: ButtonBarPagerTabStripViewController {
override func viewDidLoad() {
tabStripStyle()
super.viewDidLoad()
containerView.isScrollEnabled = false
}
}
I have seen this issue everywhere posted but its not yet answered here: 'Cannot find interface declaration' in auto-generated Swift bridging header
Bugs in swift SR-805 SR-5398
You needed to import the -Swift.h for for both the framework and the app target
For Example :
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <Foundation/Foundation.h>
#import "XLPagerTabStrip-Swift.h"
#import "RealmSwift-Swift.h"
...... // Add all frameworks, subclasses, and dependance ios frameworks
#import "MyProject-Swift.h"
You can read this article How to import file header and check paths
I had error "Cannot find interface declaration for 'CLLocation', superclass of 'MYLocation'
for below code
#interface MYLocation : CLLocation // code in MyProject-Swift.h
when I just imported
#import <MyProject/MyProject-Swift.h>
after importing below both, the error is gone.
#import <CoreLocation/CoreLocation.h>
#import <MyProject/MyProject-Swift.h>
My .h file:
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "GameData.h"
#import "PROBattleScene.h"
#interface PROBattleAI : NSObject {
BattleType type;
PROBattleScene *scene;
}
-(id)initWithType:(BattleType)_type andBattleInformation:(NSMutableDictionary*)_information andScene:(PROBattleScene*)_scene;
-(void)dealloc;
#end
But on the line PROBattleScene *scene; I get the unknown type name error from Xcode.
I tried the answer here: xcode unknown type name but I am already doing that (and doesn't work).
Why is that happening? I am already importing my PROBattleScene.h file, why isn't it being recognized?
EDIT: And the contents of PROBattleScene.h as requested:
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "GameData.h"
#import "SimpleAudioEngine.h"
#import "PROBattleBackground.h"
#import "PROBattleAI.h"
#interface PROBattleScene : CCLayer {
NSMutableDictionary *battleInformation;
NSMutableArray *localPlayerPartyData;
PROBattleBackground *background;
CCNode *base;
PROBattleAI *enemyAI;
}
+(CCScene*)scene;
-(id)init;
-(void)loadBattleInformation;
-(void)loadBGM;
-(void)loadBackground;
-(void)loadBase;
-(void)loadEnemyAI;
-(void)beginBattle;
#end
You have a circular dependency. PROBattleAI imports PROBattleScene which imports PROBattleAI which imports PROBattleScene < zomg infinite loop >
Use #class PROBattleWhatever in your headers as much as possible. Only import headers for protocol definitions or superclasses.
EDIT Ok, the above wording was totally bad...and misleading. Here is what (I believe) happens in detail. Your PROBattleAI imports PROBattleScene, which then imports PROBattleAI, which then imports PROBattleScene for a second time (all before it gets to any of the code in either file). The import will ignore PROBattleScene this time because it has already been imported and you will get the undefined type error since the file was skipped.
there are two protocols, each in its own file:
// PMAService.h
#import <Foundation/Foundation.h>
#import "PMAPost.h"
#import "PMAServiceProcessingDelegate.h"
#protocol PMAService <NSObject>
-(void)setupService;
-(BOOL)processPost:(PMAPost *)post withDelegate:(id<PMAServiceProcessingDelegate>)delegate;
#end
// PMAServiceProcessingDelegate.h
#import <Foundation/Foundation.h>
#import "PMAPost.h"
#import "PMAService.h"
#protocol PMAServiceProcessingDelegate <NSObject>
-(void)successfullyProcessedPost:(PMAPost *)post by:(id<PMAService>)service;
-(void)notProcessedPost:(PMAPost *)post by:(id<PMAService>)service withError:(NSError *)error;
#end
each of the protocols needs the opposite for a method declaration. as soon as i create the import in each of the files, the compiler is not able to compile anymore since it tells me that it cannot find one of the protocols.
error messages for PMAService.h (for the #import statement of PMAServiceProcessingDelegate.h)
'PMAServiceProcessingDelegate.h' file not found
error messages for PMAServiceProcessingDelegate.h (one for each method declaration):
Cannot find declaration for 'PMAService'
Cannot find declaration for 'PMAService'
is there something i missed out? isn't it allowed to import protocols like this?
You have a circular dependency that you can solve using a forward declaration:
// PMAService.h
#import <Foundation/Foundation.h>
#import "PMAPost.h"
#protocol PMAServiceProcessingDelegate;
#protocol PMAService <NSObject>
-(void)setupService;
-(BOOL)processPost:(PMAPost *)post withDelegate:(id<PMAServiceProcessingDelegate>)delegate;
#end
I need to develop an application which has a interface which implements methods of 3 protocols.
Assume protocol A extends protocol B and protocol C, and interface implements protocol A.
This is how my code looks,
// This is in MyClass.h file
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "protocol_A"
#interface MyClass : NSObject <protocol_A>
{
}
#end
//This is MyClass.m file
#import "MyClass.h"
#implementation myClass
-(void)methodinA
{
NSLog(#"I'm in protocol_A");
}
}
-(void)methodinB
{
NSLog(#"I'm in protocol_B");
}
-(void)methodinC
{
NSLog(#"I'm in protocol_C");
}
#end
//This is protocol_A.h file
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "protocol_B.h"
#import "protocol_C.h"
#protocol protocol_A <protocol_B, protocol_C>
-(void)methodinA;
#end
//This is in protocol_B.h file
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#protocol protocol_B
-(void)methodinB;
#end
//This is in protocol_C.h file
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#protocol protocol_C
-(void)methodinC;
#end
i'm getting an exception , and my app is getting crashed...
***Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MyClass 0X323nm31>setvalue:forundefinedKey:]:this class is not key value coding-compilant for the key window'.
Plz Tel me how to solve this problem??
So where you're getting this from (and the reason you're getting it 3 times) is you've got a mistake in your protocol definitions. You have:
//This is in protocol_C.h file
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#protocol protocol_C
{
}
-(void)methodinC;
#end
You can't declare class members in a protocol: only methods. Because of this, you don't need (and, as you've discovered) can't have the curly braces in the protocol definition. As such, you need this for your protocol definitions:
//This is in protocol_C.h file
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#protocol protocol_C
-(void)methodinC;
#end
Removing those should solve your issue.
When making new files, I always go through Xcode's new-class-files process, as it frequently gives you lots of convenient stuff. Here is the contents of a new protocol_D declaration fresh from Xcode:
#import <Cocoa/Cocoa.h>
#protocol protocol_D
#end
Hope this helps!
TL;DR: Protocol definitions can't have curly-braces anywhere in them.
Protocols generally go in a .h file; always go in a .h file if you plan on using them anywhere.
Just like everything else, you need to #import the .h file that contains the definition of the protocol before you use it.
So, in MyClass.h (it really should be capitalized -- Classes are always capitalized in Objective-C), #import the various protocol .h files.
Your protocol_A.h file declares conformance to protocol_B and protocol_C, yet you haven't imported the headers for protocol_B and protocol_C. This means that you are declaring conformance to protocols that as far as the compiler is concerned, don't exist in protocol_A.h. You need to import the headers:
In protocol_A.h:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "protocol_B.h" //note these new imports
#import "protocol_C.h"
#protocol protocol_A <protocol_B, protocol_C>
-(void)methodinA;
#end
Also see Apple's Communicating with Objects, which discusses delegates, protocols, and selectors. Though its listed under Mac OS X, most (if not all) appears to apply to iOS also.