ios-自建网页在浏览器安装ipa包
ios-自建网页在浏览器安装ipa包
前篇
- IOS系统在Safari安装ipa文件 - https://www.cnblogs.com/nnnnnn/p/11102017.html
开发模式下, 打出来的 ipa 安装测试, 可以直接连真机 run, 也可以 第三方托管 ipa 服务, 如: fir , 不过貌似要实名认证, 麻烦.
so, 自己建个文件下载服务.
前置条件
- 下载 ipa 包的设备的 uuid 已加入 苹果测试设备列表
- web 服务, 文件服务.
搭建 文件服务
起个文件服务, 这里以 tomcat 为例
加入 MIME 配置, tomcat 的话在 conf/web.xml 中加入
1
2
3
4
5
6
7
8<mime-mapping>
<extension>mobileprovision</extension>
<mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
<extension>plist</extension>
<mime-type>application/XML</mime-type>
</mime-mapping>新建一个 plist 文件, 如: rummy.plist
这个文件和 ipa 都丢到 文件服务
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>https://aaa.bbb.cn:32443/dl/rummy.ipa</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.aaa.bbb</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>rummy-ios.ipa</string>
</dict>
</dict>
</array>
</dict>
</plist>- url: 能下载 ipa 的地址
- title: 下载时弹窗提示.
- bundle-identifier: 就是包名, 在 iOS 16+ 要求正确填下, 否则无法安装
- 其他的 value 值随意填, 不需要准确的信息
新建一个 html 文件, 如: index.html
这个网页丢带 web 服务
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20<!DOCTYPE html>
<html>
<head>
<title>iOS</title>
<style type="text/css">
.wp {
display: flex;
justify-content: center;
align-items: center;
}
</style>
</head>
<body>
<div class="wp">
<div class="box">
<a href="itms-services://?action=download-manifest&url=https://aaa.bbb.cn:32443/dl/rummy.plist" class="button"> <font size="20">Install APP</font> </a>
</div>
</div>
</body>
</html>- url: 能下载到刚才创建的 plist 文件的地址
done. 测试, 打开 web 服务: https://aaa.bbb.cn:32443/
内网搭建
其实内网搭建 https 文件服务, ipa 包还是得丢带外网 https 中, 因为这个必须是受信任才能安装 ipa
生成内网 https 证书.
使用 mkcert 工具 (https://github.com/FiloSottile/mkcert/releases/)
生成 pem
1
2$ .\mkcert-v1.4.3-windows-amd64.exe -install
$ .\mkcert-v1.4.3-windows-amd64.exe 192.168.1.200- 192.168.1.200 就是 web 服务机子的 ip, 会生成两个文件
192.168.1.200-key.pem
和192.168.1.200.pem
- 192.168.1.200 就是 web 服务机子的 ip, 会生成两个文件
因为这里使用的是 tomcat, 所以需要使用 openssl 转换一下证书
1
2
3
4$ openssl pkcs12 -export -inkey ./192.168.1.200-key.pem -in ./192.168.1.200.pem -name test -out test.pfx
// 会要求输入密码
Enter Export Password: 123456- 会生成一个
test.pfx
文件
- 会生成一个
tomcat 配置 https.
修改
conf/server.xml
1
2
3
4
5
6
7<Service name="rummy_web">
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000" maxThreads="150"
scheme="https" secure="true" SSLEnabled="true" clientAuth="false" sslProtocol="TLS"
keystoreFile="C:/Users/wilker/Desktop/mkcert/test.pfx" keystoreType="PKCS12" keystorePass="123456" />
</Service>- keystoreFile 是转换后的证书
- keystorePass 是转换时输入的密码
done. 打开网页 https://192.168.1.200:8443/
然后 [搭建 文件服务](#搭建 文件服务) 中 除了 ipa 包 都可丢带内网, ipa 包必须丢到外网 https 中
踩坑
iOS 16+ usb 安装正常, 网页下载 ipa 无法安装
打开了开发者模式也无法安装 (打开开发者模式: https://blog.51cto.com/u_15755990/5826277)
- 原因是网页上的 plist 文件配置的 bundle-identifier 值没有配置正确, 必须要求是 ipa 包的包名
- 参考: https://ask.dcloud.net.cn/question/153226