Host app
•An app that a user employs to choose an app
extension is called a host app
Host
app
Today.app
Today
Chrome.app
Share/Action
Dropbox.app
Document Provider
Photo.app
Photo Editing
•an app that contains one or more extensions is
called a containing app
Containing app
Containing
app
extension extension extension
•an app that contains one or more extensions is
called a containing app
Containing app
App extension
•an app extension lets you extend custom
functionality and content beyond
App
extension
App extension
•an app extension lets you extend custom
functionality and content beyond
Today Extension
Today Extension
Today Extension
Today Extension
Today Extension
Dropbox
TodayView
Today.app
How an App Extension
Communicates
Dropbox
TodayView
Today.app
Database
How an App Extension
Communicates
Dropbox.app
Dropbox
TodayView
Today.app
Open URL
Database
How an App Extension
Communicates
Open URLShared
Resources
App
extension
Host
app
Containing
app
How an App Extension
Communicates
Share Extension
Share Extension
Share Extension
Share Extension
Share Extension
App
extension
Host
app
Containing
app
Pocket AddToPocket Chrome
Server
App
extension
Host
app
AddToPocket Chrome
Accessed via Apple
frameworks code
App
extension
Host
app
System
Framework
App
extension
Host
app
AddToPocket Chrome
UIActivityViewControllerSLComposeServiceViewController
Accessed via Apple
frameworks code
Extension Type Host App host app use
Today Today.app NotificationCenter.framework
Share any app UIActivityViewController
Action any app UIActivityViewController
Photo Editing Photo.app
PhotosUI.framework
Photos.framework
Document Provider any app UIDocumentPickerViewController
Custom Keyboard any app
Host
app
Extension Type Enter point
Today
UIViewController
<NCWidgetProviding>
Share SLComposeServiceViewController
Action SLComposeServiceViewController UI and non-UI variants
Photo Editing
UIViewController
<PHContentEditingController>
Document ProviderUIDocumentPickerViewController UI and non-UI variants
Custom Keyboard UIInputViewController
App
extension
App
extension
Host
app
Containing
app
Pocket AddToPocket Chrome
Server
App
extension
Containing
app
Pocket AddToPocket
Different process
•Isolated address space
•Executes independently
•System optimizes
separately
Run Separately
•Containing app is still most important
•Extension cannot without containing app
•Don't have full use of system resources
•Make it seamless
•Make it useful
Demo
Demo
•a light bulb
•sample code
•Wifi Environment
App Extension
•Create an app extension by adding a new target
to an app
•Add necessary libraries to extension target
•ViewController
viewController’s life cycle
•initWithCoder:
•viewDidLoad
•widgetMarginInsetsForProposedMarginInsets:
•widgetPerformUpdateWithCompletionHandler:
•viewWillAppear:
•viewDidAppear:
•widgetMarginInsetsForProposedMarginInsets
User Interface
•UIView
•UIButton
•UILabel
•UITextField
•UIScrollView
Some APIs are Unavailable
to App Extensions
•Access a sharedApplication object
•Use any API marked in header files with the NS_EXTENSION_UNAVAILABLE macro,
or similar unavailability macro, or any API in an unavailable framework
•Access the camera or microphone on an iOS device
•Perform long-running background tasks
•The specifics of this limitation vary by platform, as described in the extension point
chapters in this document.
•(An app extension can initiate uploads or downloads using an NSURLSession
object, with results of those operations reported to the containing app.)
•Receive data using AirDrop
•(An app extension can send data using AirDrop in the same way an app does: by
employing the UIActivityViewController class.)
App Store
•NOTE ABOUT 64-BIT ARCHITECTURE
•An app extension target must include the arm64 (iOS) or x86_64 architecture
(OS X) in its Architectures build settings or it will be rejected by the App
Store. Xcode includes the appropriate 64-bit architecture with its “Standard
architectures” setting when you create a new app extension target.
•If your containing app target links to an embedded framework, the app must
also include 64-bit architecture or it will be rejected by the App Store.