AppExtension总结

  • 提高app的定制化程度,为app提供了更多个功能支持
  • 统一的调度,常用的独立的功能以更轻量级的扩展实现,方便系统管理和调度
  • 系统某些特殊不开放的功能定制化,如自定义键盘

运行原理

  • 在其它App中通过UIActivityViewController可以对应注册到系统的扩展应用
  • 扩展引用唤起后会开启一个运行循环,由系统控制
  • 扩展只能通过系统指定的api和文件共享与应用进行交互

系统所支持的扩展

  • 通过系统提供的模版(/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/)[/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/],它支持如下扩展,在Xcode中可以直接通过模版创建
Action Extension.xctemplate
Audio Unit Extension.xctemplate
Authentication Services Extension.xctemplate
AutoFill Credential Provider Extension.xctemplate
Broadcast Setup UI Extension.xctemplate
Broadcast Upload Extension.xctemplate
Call Directory Extension.xctemplate
ClassKit Context Provider Extension.xctemplate
Content Blocker Extension.xctemplate
Custom Keyboard Extension.xctemplate
File Provider Extension.xctemplate
File Provider UI Extension.xctemplate
Intents Extension.xctemplate
Intents UI Extension.xctemplate
Message Filter Extension.xctemplate
Network Extension.xctemplate
Notification Content Extension.xctemplate
Notification Service Extension.xctemplate
Photo Editing Extension.xctemplate
Quick Look Preview Extension.xctemplate
Share Extension.xctemplate
Spotlight Index Extension.xctemplate
Sticker Pack Base Extension.xctemplate
Sticker Pack Extension Component.xctemplate
Sticker Pack Extension.xctemplate
Thumbnail Extension.xctemplate
Today Extension.xctemplate
Unwanted Communication Reporting Extension.xctemplate
iMessage Extension Component.xctemplate
iMessage Extension.xctemplate
iOS App Extension Base.xctemplate

模版内容

  • Share Location为例,分别包含了SwiftOC
├── MainInterface.storyboard
├── ShareViewController.h
├── ShareViewController.m
├── ShareViewController.swift
├── TemplateIcon.png
├── TemplateIcon@2x.png
└── TemplateInfo.plist
  • 定义
  • 配置BundleId
  • 运行: 依赖一个Containing App
posted @ 2020-11-03 18:40  阿甘左  阅读(297)  评论(0编辑  收藏  举报