App Extension(e.g Widget aka Today, Photo Editing...)
Containing App
- app which contains an extension or super app
Host App
- app which calls App Extension
and starts extension's lifecycle
For example systems Photos app can be Host App
for Photo Editing Extension
like Photoshop Extension which is a part of Photoshop App(Containing App
)
App Extension
- available from iOS v8 - it is a packaged bundle
which uses different process than Containing App
and can communicate with Containing App
through App Groups and with Host App
through IPC. It has .appex
file extension and is located in PlugIns
folder. Something similar to CXTests[About]
Application packaged bundle
SpeedWidgetExtension.appex - Application Extension packaged bundle
Communication of App Extension
and Containing App
- Share data - use
App Group
[About]
- Share code
Target Membership
- the simplest way or for pre iOS v8 which allows you to add files into every target. It increases a footprint of package because this file will be duplicated for every target
Framework
- module for grouping/reusing code
Embedded framework
aka Dynamic framework
- the most appropriate way to share common code base. Please turn on APPLICATION_EXTENSION_API_ONLY
[About] for the framework. Please note that for using Embedded framework
you should embed it only in Containing App
(and don't add this framework in App Extension
. If you include this framework additionally to App Extension
it will have the same framework inside App Extension
bundle(additionally to Containing App
) - framework will be duplicated). It is possible to use single framework for both Containing App
and App Extension
because of @prath
[About]
//App Extension
LD_RUNPATH_SEARCH_PATHS = @executable_path/../../Frameworks
//It means that App Extension can uses Dynamic framework from Containing app
Static Framework
- link the code to executable binary. You can link library only for Containing App
Limitations:
- Widget Extension UI should be written on pure SwiftUI
- Widget Extension not easy to debug on a real device
- Widget Extension is updated when it is possible(not exactly when you specify it)
[iOS Extension Widget(Today) gray background]
[iOS extensions]
[iOS App Group]
[Vocabulary]