why can't I Import UIKit in my swift file? - swift

I can Import UIKit in other files in my project but not in this one why?

If Firebase or FirebaseAuth use
#_exported import UIKit
it will import UIKit for you, and therefore you won't be able to import UIKit because it will already be imported. For more information consider what this website says about #_exported:
"If you want to import an external module for your whole module you can use the
#_exported keyword before your import. From now the imported module will be
available everywhere"
It also says you should probably not use #_exported because it is a private swift attribute.
If this is the case, then UIKit should already be imported, and you should be able to use it without explicitly importing it.

Related

Should I remove import statement from .swift file if I'm not using it?

The project I'm working on has several import statements at the top of the .swift file...
ex.
import RxSwift
import Realm
import UIKit
If I'm not using Realm within that file, is it "bad" to import Realm?
When I say "bad", what I mean is...
Will the performance of the app suffer
is it bad practice
I can't find any documentation for this online. It's very likely that it's out there and I haven't found it yet. Any links to documentation on this topic are appreciated.

How to import flutter (not dart) collections library?

I'm able to import
import 'dart:collection';
But that's not the same as the library with an API here:
https://api.flutter.dev/flutter/package-collection_collection/package-collection_collection-library.html
I can't seem to figure out the correct uri for import this library, and can't find any thing on the web or the api about this.
import 'package:collection/collection.dart';

Import another package along with a SPM Library

Imagine this scenario when your App project uses two custom libraries
.xcworkspace
|- App.xcodeproj
|- LibraryA.xcodeproj
|- LibraryB.xcodeproj
And since in this case we are working with Xcode frameworks one could add the following to the LibraryB header file:
#import <LibraryA/MyLibraryA.h>
and now not only there is no need to import LibraryA in the source od LibraryB, but also every time you import LibraryB inside your App source files, the LibraryA gets imported along with it, which can be very convenient.
The same applies to the default Foundation import one can find in an Xcode framework header:
#import <Foundation/Foundation.h>
Now with SPM, I need to manually import Foundation everywhere I use it.
Q: Is this possible to achieve the same result when using SPM packages exclusively?
I haven't found any resources on this matter. Thanks!
To expose import to your whole package you can use #_exported attribute inside of any of your swift file:
#_exported import Foundation
More info about this in next discussion: https://forums.swift.org/t/package-manager-exported-dependencies/11615

how to avoid duplicate import and component declarations in VueJS

I'm using Quasar and the PWA starter kit, with VueJS.
I want to know how to declare once a set of components used throughout many pages in a Vue app.
I seem to need to have a huge import declaration in every page
I tried to import once in main.js but there is a conflicting
import Quasar from 'quasar'
so I can't add to that or change it to
import {
Quasar,
QCard,
.... etc
} from 'quasar'
as the {} seems to break the import.
Also can't import twice (duplicate import error).
What is the way to import components once for a whole app?
Or get at the Vue object so it can be used in another way to import inside a different component?
You can import specific components to register globally in the main.js file when you register the Quasar plugin.
For example, in you want to be able to use the <q-btn> and <q-icon> components anywhere in your application you could do this:
import Quasar, { QBtn, QIcon } from 'quasar'
Vue.use(Quasar, {
components: { QBtn, QIcon }
})
Here's the documentation.

how to import bugsense in Swift

i can find its old implementation that is
#import <BugSense-iOS/BugSenseController.h>
and
[BugSenseController sharedControllerWithBugSenseAPIKey:#"123456" userDictionary:nil sendImmediately:YES]
and i am working in the Swfit Language
Import doesn't support dash (-)
can anyone update me how to import it in Swift, i also checked it on their bugsense documentation but couldn't find any updates
Create an ObjC bridging header help you to import it. First add the framework to your app directory and Xcode will ask you to create the bridging header.
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html