Project Frameworks - codepath/ios_guides GitHub Wiki
Overview
A framework is bundle of code letting you add functionality to your app. Apple's frameworks let you add features like maps and the user's location. Other developers' frameworks like Parse let you easily synchronize data to the cloud.
This page covers the basics of adding Apple's iOS frameworks to your project. By the end of it you will understand how to use frameworks' methods and classes in your project.
Popular Apple frameworks
- MapKit.framework - add maps to your app
- CoreLocation.framework - get the user's location
- ContactsUI.framework - let user choose from their contacts (replaces the deprecated AddressBookUI framework, deprecated in iOS 9)
- MessageUI.framework - let user send native SMS or emails from inside your app
Adding Frameworks to Project
For Apple's own frameworks (MapKit, CoreLocation, MessageUI, ContactsUI, etc.), modern Xcode auto-links them when you import the module — the compiler embeds a link directive in the object file and the linker picks it up automatically. This behavior is controlled by two build settings that both default to on in new projects: CLANG_ENABLE_MODULES and CLANG_MODULES_AUTOLINK (surfaced in Build Settings as Enable Modules (C and Objective-C) and Link Frameworks Automatically). In most cases, adding import Foo to your Swift file is enough — you should not need to touch Build Phases.
If you have disabled auto-linking, or you're wiring up a non-modular third-party library that ships as a plain .framework, add it manually: select your target, open the General tab, and add the framework under Frameworks, Libraries, and Embedded Content.

Using a linked Framework
import
In every swift file you need to access the framework's methods and classes, you'll need to import the framework. For example, to use MKMapView in your MapViewController, import MapKit.
import UIKit
import MapKit
import CoreLocation
import ContactsUI
import MessageUI
class MapViewController: UIViewController{
var mapView: MKMapView!
…
Now you can use Apple's frameworks!