Reputation: 61880
Linked frameworks and libraries in my project written in Swift:
Suppose I have two files in my project: AppDelegate.swift
and ViewController.swift
My import statements in AppDelegate.swift
:
import UIKit
import Foundation
import CoreData
import MapKit
So simply here I can use for example: NSManagedObject
and MKMapView
classes.
In ViewController.swift
I do not have any import statements, but I can use there NSManagedObject
opposite to MKMapView
. Why?
Shouldn't be in Swift that one framework imported in one file should be visible to other files? Why CoreData
is visible to all, but MapKit
is not?
I also use Project-Bridging-Header.h
in my project with following import statements:
@import AFNetworking;
@import Crashlytics;
@import Fabric;
@import FBSDKCoreKit;
@import FBSDKLoginKit;
@import MagicalRecord;
@import MTBBarcodeScanner;
@import QRCode;
@import SVProgressHUD;
Upvotes: 2
Views: 78
Reputation: 61880
Every class created in different module can be accessed outside only via import
statement. Frameworks are different modules. If you need to access framework you need to import it for every file where you gonna use it.
Bridging-Header.h
file distributes other modules/frameworks to every file in module where such header exists.
if module A import module B, and you need to access both of them in module C, it is enough to import just module A in your C module.
Upvotes: 1