搭建IOS应用测试分发平台
本帖已被设为精华帖!,
苹果有太多限制,在测试中拿到包不是易事。
 目前流行的有如下几种:
1.使用iTunes将iPa同步到手机中;
2.使用itms-services协议进行下载分发;
3.使用第三方工具进行下载分发,如:蒲公英,fir…
现在就以2来说说如何自己来实现分发。
流程如下:
用Xcode打包IPA版本
 搭建本地Web服务器
 开启HTTPS
 编写好对应的.plist文件
 上传ipa、.plist、ca证书到Web服务器,配置好index.html
 在手机上用Safari打开链接,完成下载
首先是要搞定证书。
 我们得解决证书的问题。可以参考iOS 证书申请和使用详解
 如果搞不定,可以找开发帮忙。
 把生成的证书放到server上。
用flask 搭建web service, 比较简单。
 将证书放到upload中,添上如下代码,可以上传下载证书了。
@app.route('/upload', methods=['POST'])
def upload():
  uploaded_files = request.files.getlist("file[]")
  filenames = []
  for file in uploaded_files:
    if file and allowed_file(file.filename):
      filename = secure_filename(file.filename)
           file.save(os.path.join(app.config['UPLOAD_FOLDER'],filename))
      filenames.append(filename)
  return render_template('upload.html', filenames=filenames)
@app.route('/down_loads')
def down_loads():
    if request.method=="GET":
        if os.listdir(os.path.join('uploads')):
            files = os.listdir(os.path.join('uploads'))
            return render_template('down_loads.html',files=files)
        abort(404)
编写plist文件
 原理是通过Safari解析链接中的”itms-services://“来实现的。
 链接指向plist,plist指向IPA。
 例如:
<a title="iPhone" href="itms-services://?action=download-manifest&url=https://192.168.**.***/install.plist">Download</a>
Safari会去读取install.plist中的信息,如:iOS应用的名称、版本、安装地址等.(这些信息,打包的时候就知道,如果不知道,可以把ipa解压,从解压的info.plist里面去获取,填到自己创建的install.plist里面)
<?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://192.168.**.***/test.ipa</string>
                </dict>
            </array>
            <key>metadata</key>
            <dict>
                <key>bundle-identifier</key>
                <string>必须和bundleidentifier一样</string>
                <key>bundle-version</key>
                <string>版本号</string>
                <key>kind</key>
                <string>software</string>
                <key>releaseNotes</key>
                <string>(可以随意填)</string>
                <key>title</key>
                <string>App名称</string>
            </dict>
        </dict>
    </array>
</dict>
</plist>
添加配置信息
 我们把刚刚建好的plist文件(这里取名为install.plist)、ipa包、ca证书放到Web服务器的文件目录下,然后修改index.html中的内容。
 (index.html内容):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>应用名字</title>
</head>
<body>
<h1 style="font-size:40pt">iOS应用OTA安装<h1/>
<h1 style="font-size:40pt">
<a title="iPhone" href="itms-services://?action=download-manifest&url=https://192.168.**.***/install.plist">Iphone Download</a>
<h1/>
<a title="iPhone" href="https://192.168.**.***/ca.crt">ssl 证书安装</a>
<h1/>
</body>
</html>
我们用iphone打开浏览器,输入本地服务器的地址,然后再点击Download,哈哈,是不是已经弹出对话框询问需要安装了??
 Oops, 弹出的框是”Cannot connect to ***”
 怎么办? 服务器没有配置https.
 我们用openssl来生成
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout ***.key -out ***.crt
代码中添加:
from flask import Flask
from OpenSSL import SSL
import os
context = SSL.Context(SSL.SSLv23_METHOD)
cer = os.path.join(os.path.dirname(__file__), 'resources/***.crt')
key = os.path.join(os.path.dirname(__file__), 'resources/***.key')
if __name__ == '__main__':
    context = (cer, key)
    app.run( host='0.0.0.0', port=5000, debug = True, ssl_context=context)
解决了SSL问题,重新启动服务,就可以下载了。
 然后扩展一下web service 功能(如二维码),做美观一下。
* 注:本文来自网络投稿,不代表本站立场,如若侵犯版权,请及时知会删除
