当前位置:网站首页>App Clip 苹果小程序开发须知
App Clip 苹果小程序开发须知
2022-08-11 11:00:00 【51CTO】
前言
在 Xcode 工程中,你可以为你的 App 添加一个 app clip target, 利用 Xcode ,app clip 可以与你的 app 共享代码与资源,并可以编译,调试,运行在真机或者模拟器环境。但是,在实际使用过程中,开发者必须在自己的服务器上做好验证 app clip 的有效性的手段。
添加一个 App Clip Target
- 利用 Xcode 创建一个 iOS 工程
- 利用 App Clip template 为该 iOS 工程创建一个新的 Target
- 输入 App clip 的名称,以及为 app clip 选择合适的选项并点击完成
通过以上步骤,Xcode 会自动为你创建你所需的文件,为你的 app clip 的 Target 生成如下内容:
- 一个用于你 app clip 编译,运行,测试的 scheme
- 新的 capability
- Parent Application Identifiers Entitlement.
- App clip 的 bundleID
- 供你测试 App clip 的环境变量 _XCAppClipURL
- 支持设备调试
当创建完成后,在模拟器或者真机上运行 app clip, 看是否报错。
添加 Associated Domains Entitlement
- App clip 可以通过用户传入的一个 URL(例如:扫码)来唤起
- 用户可通过 app clip 传递给主 app 一个 URL 的方式安装完整应用
要支持以上俩种调用方式,必须在 app 和 app clip 中加入 Associated Domains Entitlement:
- 打开工程设置,在 Associated Domains capability 中加入 the Associated Domains Entitlement
- 使用以下样式将其 domain 添加到 Associated Domains capability 功能中:appclips:.
添加代码与资源
为 App clip 编写代码逻辑和添加 asset 资源与正常开发 iOS App 没有什么区别,但是为了工程的可维护性,App clip 与完整的应用程序应该尽可能多的分享代码:
- 如果你创建了一个新的 app, 并且带有 app clip 功能, 那么开发请遵循基于代码模块化的最佳实践,例如, 创建可重复使用的组件。
- 如果为现有的 app 添加 app clip,建议先花点时间将代码重构为模块化,与 app clip 共享,避免代码重复
- 在完整的应用程序与 app clip 中,Assets 资源共享
使用 Active Compilation Conditions
在 app clip 和完整应用之间共享代码时,可能会遇到无法在 app clip 中使用某些代码的情况。在这些情况下,请设置 Active Compilation Conditions ,在其中可以声明排除代码的条件。
在 app clip 的工程设置中找到 Active Compilation Conditions ,并为其添加一个值,例如:APPCLIP,然后在共享的代码中加入判读,示例如下:
服务器配置
在系统弹出 app clip 或允许 app clip 调用之前,系统会验证 app clip 的配置和调用的URL。如果无法执行验证,则不会显示app clip,也不会启动。为了使系统能够验证您的 app clip,您需要对你的 Web 服务器和 Xcode 项目进行配置:
- 为你的服务器添加一个 Apple App Site Association 文件
- 在 Apple App Site Association 文件中添加一个键值对,key 为 appclips,例如:
- 打开 Xcode ,为 app 和 app clip 中的 Associated Domains Entitlement 配置服务器域名
在 App Store Connect 中注册 App Clip
系统使用您在 App Store Connect 中配置的 URL 来启动您的 app clip。因此,识别启动 app clip 的URL,在启动时对其进行响应并在 App Store Connect 中注册它们对于创建 app clip 至关重要。
发布 App Clip
准备发布 app clip 时,请将其作为 app archive 的一部分提交。请注意,必须通过App Store 审核,才能发布。
结尾
好了,今天的讲解就到这里,感兴趣的朋友可以关注我的技术公众号,每周都有优质技术文章推送,微信扫一扫下方二维码即可关注:
边栏推荐
- 使用.NET简单实现一个Redis的高性能克隆版(七-完结)
- Are there any foreign application cases for domestic databases?
- chrome设置为深色模式(包括整个网页)
- Incredible, thanks to this Android interview question, I have won offers from many Internet companies
- 2. 类与对象——封装
- Getting Started with Chrome Plug-in Development - Nanny Level Raiders
- Ali Ermian: Do you know how to tune the JVM?
- 爆料!前华为微服务专家纯手打500页落地架构实战笔记,已开源
- Calculate the sum of an element of an array
- HTM5学习:第一阶段02
猜你喜欢
中小企业如何实施MES管理系统
解决 Pocess finished with exit code 1 Class not found 和 Command line is too long. Shorten the command
运动健康服务场景事件订阅,让应用推送“更懂用户”
The ceiling-level microservice boss summed up this 451-page note to tell you that microservices should be learned this way
Word小技巧之图表实现自动编号和更新
[Building a 2D rasterized map using SLAM technology]
从零开始配置 vim(11)——插件管理
如何给女朋友解释什么是缓存穿透、缓存击穿、缓存雪崩?
数据库导出的csv文件纯数字被转为科学计数法
Qihua stores the future and interprets the origin of distributed
随机推荐
[Study Notes] Dual Theorem of Linear Programming
云原生 · 镜像详解
B端产品需求分析与优先级判断
Configuring vim(12) from scratch - theme configuration
关于数据权限的设计
二、第二章变量
阿里云 Hologres助力好未来网校实时数仓降本增效
【2022】【Thesis Notes】Ultra-thin THz deflection based on laser direct writing graphene oxide paper——
Flexmonster 数据透视表和图表组件
The ceiling-level microservice boss summed up this 451-page note to tell you that microservices should be learned this way
HTM5学习:第一阶段02
使用.NET简单实现一个Redis的高性能克隆版(七-完结)
全新FIDE 编译简单评测
字符函数和字符串函数的进阶
【Mysql系列】03_系统设计
Incredible, thanks to this Android interview question, I have won offers from many Internet companies
How long does it take to train a neural network, neural network training takes too long
在这个数字化的时代,如何做好用户体验与应用性能管理
学习二叉树
[Central Task Scheduling System - Communication Development]