创建项目
【HBuilderX】-【文件】-【新建】-【项目】
运行调试
真机运行
https://uniapp.dcloud.net.cn/tutorial/run/run-app.html
模拟器运行
https://uniapp.dcloud.net.cn/tutorial/run/installSimulator.html
APK打包
说明
离线打包参考官网,以下仅说明云打包
【发行】-【原生APP-云打包】
无证书:使用公共测试证书进行打包
有证书:填入包名、别名、密钥、证书文件
生成证书
Andriod: https://ask.dcloud.net.cn/article/35777
IOS:https://ask.dcloud.net.cn/article/152
多端登录授权
说明
网址详见:https://uniapp.dcloud.net.cn/tutorial/app-oauth.html
HTML5的API详见:https://www.html5plus.org/doc/zh_cn/oauth.html#plus.oauth.AuthOptions
微信授权流程
准备:微信开放平台账号、应用运行流程图、icon(2828、108108)、获取安卓签名(需要有证书,APK打包安装到手机,在网页最下方解压文件,安装到手机,输入包名,获取签名)
网址详见:https://uniapp.dcloud.net.cn/tutorial/app-oauth-weixin.html
微信开发文档:https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_Login/Development_Guide.html
UNIAPP踩坑指南
-
安卓
uni.showModal
模态弹窗样式难看?
解决:手撕一个插件https://ext.dcloud.net.cn/plugin?id=17678拓展问题:
- 内容自适应高度?
- 路由跳转自动关闭弹窗?
解决:安卓监听返回plus.key.addEventListener('backbutton', this.handleBackButton)
- ios侧滑关闭弹窗不会自动关闭?
解决:添加ios侧滑监听事件currentPage.addEventListener('popGesture', this.handleBackButton)
(currentPage获取参考文档,事件监听参考文档)
-
使用
uni.scanCode
时发现无法限制条码类型,使用scanType实际还是能扫出来其他的码?
解决:手撕一个插件https://ext.dcloud.net.cn/plugin?id=17679拓展问题:
- 使用
plus.webview.create
创建webview,使用plus.barcode.create
创建barcode后,点击扫码将卡顿1s后再进入?
解决: 可以用setTimeout
异步调用创建barcode - ios点击返回按钮会返回上上层?
解决:将titleNView
中的autoBackButton
设为false
,再在buttons
中添加返回按钮,自定义事件 - ios关闭webview时,上层页面会跳转两次?
解决:在扫码关闭后先不调用webview.close()
事件,改为调用webview.hide()
事件,同时监听hide
事件,参考如下:
webView.addEventListener('hide', () => { // 此处异步,避免快速连续跳转,可能会页面白屏 setTimeout(() => { this.webView.close() }, 80) })
- 使用
IOS踩坑指南
scroll-view
滑动时,页面短暂白屏,经查看应该设置scroll-into-view
这个属性导致的
解决:动态绑定scroll-Y
,在设置前禁止滚动,设置后再开启滚动,类似如下:
scrollY.value = false;
nextTick(() => {
scrollIntoView.value = `...`;
scrollY.value = true;
});
2. scroll-view
中使用fixed
布局无法穿透的问题,在H5和安卓都是正常的,但是在ios真机中,嵌套的fixed
组件会被父组件遮挡,且设置z-index
无效。
解决:在社区能看到开发者说因为scroll-view设置了-webkit-overflow-scrolling: touch
,那么设置如下即可:
.uni-scroll-view {
-webkit-overflow-scrolling: auto;
}
IOS 发布
登录
https://appstoreconnect.apple.com/
准备(以下为必填项)
- iosApp
-
各个尺寸屏幕图(可以是示例图,而非真实截图)
- 生成ios各个尺寸图可以用uniapp先运行到浏览器,
f12
打开控制台,改成移动端模式,并调整上方尺寸。(5.5英寸为310*552
、6.5英寸为310*672
)
此时,在控制台ctrl+shift+p
,输入capture
,点击capture full size screenshot
。
截图成功后,用windows画图工具
打开,调整大小。
此时看下面的尺寸对不对,高度稍高就裁剪一下即可。
- 生成ios各个尺寸图可以用uniapp先运行到浏览器,
-
描述、 关键词、技术支持网址、版本、版权
-
如果需要登录则提供登录信息、联系信息
-
- App信息
- 名称
- 类别、内容版权、年龄分级
- App隐私
- 隐私政策网址
- 如果使用uniapp并勾选了IDFA,需设置产品隐私,参考https://uniapp.dcloud.net.cn/tutorial/app-ios-idfa.html
- 价格与销售范围
- 设置价格
分发TestFlight
TestFlight测试分为两种形式:内部测试和外部测试。
建立群组后可以添加构建版本,添加测试员。
内部群组
这里建议对内部人员勾选自动分发。
测试员必须为团队人员,如果非团队人员,要在【用户和访问】中进行添加。添加后团队成员会受到邮箱,接受邀请后即成为团队成员。此时再回到这里邀请即可。
外部群组
建立群组后,添加构建版本,此时构建版本需要审核(一天左右),审核通过以后会有公开链接,再设置下测试员数量。
添加新测试员可以不为团队成员,直接填写电子邮件即可,或者直接将公开链接发送给测试人。测试者将会收到邀请,并在TestFlight获取该测试版本。
之后每次在这个群组增加新的构建版本时,他们都会再次收到消息,不需要再手动分发。
审核被拒参考原因
2.1.0 Performance: App Completeness
Issue Description
The app exhibited one or more bugs that would negatively impact App Store users.
Bug description: error message showing after tap on photo.
Review device details:
- Device type: iPad (8th generation)
- OS version: iOS 17.4.1
Next Steps
Test the app on supported devices to identify and resolve bugs and stability issues before submitting for review.
If you are unable to reproduce the bug, try the following:
- For new apps, uninstall all previous versions of your app from a device, then install and follow the steps to reproduce.
- For app updates, install the new version as an update to the previous version, then follow the steps to reproduce.
此处是因为使用了相册模块,但打包并未勾选。可在manifest.json
里调整
5.1.1 - Legal - Privacy - Data Collection and Storage
Issue Description
One or more purpose strings in the app do not sufficiently explain the use of protected resources. Purpose strings must clearly and completely describe the app's use of data and, in most cases, provide an example of how the data will be used.
Examples of unclear purpose strings:
- "App would like to access your Contacts"
- "App needs microphone access"
Next Steps
Update the camera purpose string to explain how the app will use the requested information and provide an example of how the data will be used. See the attached screenshot.
此处是因为未明确写明各个隐私权限使用原因,可在manifest.json
里调整。