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.
Related
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>
I've looked through a number posts and cannot find a solution to this problem.
I installed the MMLanScan Objective C library into in my pod file successfully.
Then I created a bridging header file in my project directory
#ifndef BridingHeader_h
#define BridingHeader_h
#import "MMLANScanner.h"
#import "LANProperties.h"
#import "PingOperation.h"
#import "MMLANScanner.h"
#import "MACOperation.h"
#import "MacFinder.h"
#import "MMDevice.h"
#endif
I also set the header file path in my project's compiler settings
But when I build my app, I get two compile time errors
error 1:
MMLANScanner.h file not found
error 2:
Failed to emit precompiled header `/Users/my user name/Library/Developer/Xcode/Derived Data/My Project Name...
Both these errors disappear when I delete my imports from the bridging header file.
Any clues how to compile this library would be appreciated.
edit
So the required .h files appear to be in my pod directory, so not sure why I get these errors
So the solution was as simple as adding the relative folder path to the header file imports
#ifndef BridingHeader_h
#define BridingHeader_h
#import "MMLanScan/MMLANScanner.h"
#import "MMLanScan/LANProperties.h"
#import "MMLanScan/PingOperation.h"
#import "MMLanScan/MMLANScanner.h"
#import "MMLanScan/MACOperation.h"
#import "MMLanScan/MacFinder.h"
#import "MMLanScan/MMDevice.h"
#endif
not
#ifndef BridingHeader_h
#define BridingHeader_h
#import "MMLANScanner.h"
#import "LANProperties.h"
#import "PingOperation.h"
#import "MMLANScanner.h"
#import "MACOperation.h"
#import "MacFinder.h"
#import "MMDevice.h"
#endif
When reproducing step by step this this original example of RCTMapboxGL (5.1.0) I run into an error with the linker. This happens to me every time I try to use RCTMapboxGL.
I tried both the:
Manual installation process for iOS
Xcode console:
Installation process with CocoaPods
Xcode console:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_RCTMapboxAnnotation", referenced from:
objc-class-ref in libRCTMapboxGL.a(RCTMapboxGL.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The missing symbol RCTMapboxAnnotation is in ../node_modules/react-native-mapbox-gl/ios/RCTMapboxGL.xcodeproj, which is already added to my project as a reference.
Other Linker Flags in Xcode Build Settings
My solution was fixing all React import statements across the MapboxGL library.
Turning them into global imports in the form #import <React/MissingClass.h> solved the problem:
e.g. #import RCTView.h to #import <React/RCTView.h>
(9 files in total):
RCTMapboxAnnotation.m:
#import "RCTMapboxAnnotation.h"
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
#import <React/RCTBridge.h>
#import <React/RCTUtils.h>
RCTMapboxAnnotation.h:
#import "RCTMapboxAnnotation.h"
#import <MapBox/MapBox.h>
#import <UIKit/UIKit.h>
#import <React/RCTConvert+MapKit.h>
#import <React/RCTComponent.h>
#import "RCTMapboxGL.h"
RCTMapboxAnnotationManager.m:
#import "RCTMapboxAnnotationManager.h"
#import <React/RCTUIManager.h>
#import <React/RCTConvert+CoreLocation.h>
#import <React/UIView+React.h>
#import "RCTMapboxAnnotation.h"
RCTMapboxAnnotationManager.h:
#import <React/RCTViewManager.h>
RCTMapboxGL.h:
#import <Mapbox/Mapbox.h>
#import <React/RCTView.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTBridgeModule.h>
RCTMapboxGL.m:
#import "RCTMapboxGL.h"
#import <React/RCTBridgeModule.h>
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
#import <React/RCTLog.h>
#import "RCTMapboxGLConversions.h"
#import "RCTMapboxAnnotation.h"
RCTMapboxGLManager.h:
#import <React/RCTViewManager.h>
RCTMapboxGLManager.m:
#import "RCTMapboxGLManager.h"
#import "RCTMapboxGL.h"
#import <Mapbox/Mapbox.h>
#import <React/RCTConvert+CoreLocation.h>
#import <React/RCTConvert+MapKit.h>
#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
#import <React/RCTUIManager.h>
#import "RCTMapboxGLConversions.h"
#import "MGLPolygon+RCTAdditions.h"
#import "MGLPolyline+RCTAdditions.h"
RCTMapboxGLConversions.m:
#import <Foundation/Foundation.h>
#import <React/RCTConvert+CoreLocation.h>
#import <React/RCTConvert+MapKit.h>
#import "RCTMapboxGL.h"
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>
In my main LESS stylesheet where I #import all my LESS files, I also import a helper file that just indicates some things like breakpoints, etcout ...
//#import url(reset.less);
#import url(variables.less);
#import url(mixins.less);
#import url(base.less);
... etc ...
#import url(mediaqueries.less);
//#import url(indicator.less);
... note the last #import.
Is there a way to only import the last file when the base URL is that of my local, so I don't have to keep commenting out that import rule before compiling?