天天看點

釋出測試版本,通過網頁線上安裝ipa和apk

        很多時候我們需要釋出一個測試版本,如果釋出為安裝包,讓測試人員自己安裝的話,很多時候是非常困難麻煩的,尤其是iOS版本,多數人并不知道除AppStore之外的安裝方式。

        通過網頁線上安裝可以達成自動化部署,終端測試使用者隻需要通過頁面下載下傳安裝即可。也可以免去發包給發行商的步驟,分享一個連結位址,他們點選連結即可完成安裝。

        Android版本很好處理,隻需要部署好一台靜态檔案伺服器,Android裝置都可以自己下載下傳安裝。這裡主要說明iOS的線上安裝方式。

        iOS線上安裝的步驟簡單來說就是部署一台https檔案伺服器(Nginx),生成好openssl證書,将app用AdHoc或者企業版本證書簽名。這樣使用者隻需要通過Safari通路頁面就可以安裝了。 這裡要說明一下,使用企業版本證書簽名的app是不能夠上傳到app store上面的,但是任何裝置都可以下載下傳安裝該app。 通過AdHoc簽名的app需要終端使用者裝置的udid加入到該簽名的.mobileprovision中才能安裝。沒有加入udid的使用者是不能夠安裝的。

       具體步驟如下:

1、部署一台https伺服器。這裡我們使用的是Nginx(也可以使用Apache的httpd)。注意必須要是https的伺服器,否則無法啟動iOS的安裝功能。

      安裝Nginx在linux上可以參考這裡,需要安裝一些依賴庫(如pcre)。

      openssl需要0.9.8的版本,不要1.0的版本。Nginx的編譯配置如下:

./configure --with-http_ssl_module --with-openssl=../openssl-0.9.8zh
make
make install
           

2、Nginx的配置如下(關鍵看https的部分)

user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  127.0.0.1;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /ios_test {
            	root   /mnt/langresser/download/;
            	index  index.html index.htm;
        }

	location /ipa_test {
		alias /mnt/langresser/download/;
		add_header Content-Dispositoin "attachment";
	}
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  127.0.0.1;
	ssl on;
        ssl_certificate      /usr/local/nginx/conf/server.crt;
        ssl_certificate_key  /usr/local/nginx/conf/server_nopwd.key;
	#autoindex on;
	#autoindex_exact_size off;    	

	location /ios {
            	root   /mnt/langresser/download/;
		index index.html index.htm;
	}

	location /ipa {
		alias /mnt/langresser/download/;
		add_header Content-Dispositoin "attachment";
	}

}
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    # }

}
           

3、ipa生成的時候會同時生成一個manifest.plist。這個要進行一些修改,主要是伺服器ip位址。例子如下:

<?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://127.0.0.1/ipa/thirtysix.ipa</string>
				</dict>
				<dict>
					<key>kind</key>
					<string>display-image</string>
					<key>url</key>
					<string>https://127.0.0.1/ipa/thirtysix57.png</string>
				</dict>
				<dict>
					<key>kind</key>
					<string>full-size-image</string>
					<key>url</key>
					<string>https://127.0.0.1/ipa/thirtysixfull.png</string>
				</dict>
			</array>
			<key>metadata</key>
			<dict>
				<key>bundle-identifier</key>
				<string>com.jzsj.thirtysix</string>
				<key>bundle-version</key>
				<string>1.0</string>
				<key>kind</key>
				<string>software</string>
				<key>title</key>
				<string>三十六計</string>
			</dict>
		</dict>
	</array>
</dict>
</plist>
           

4、一個測試頁面如下(index.html,配置在nginx中)

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>遊戲Demo</title>
</head>
<body>
<h1>1. iOS安裝 <a href="https://127.0.0.1/ipa/server.crt" target="_blank" rel="external nofollow" >證書</a><br/>(如果之前尚未安裝過此證書,請先安裝證書)</h1>
<br/>
<h1>2. iOS安裝 <a href="itms-services://?action=download-manifest&url=https://127.0.0.1/ipa/manifest.plist" target="_blank" rel="external nofollow" >遊戲包</a></h1>
<br/>
<h1>3. Android安裝 <a href="https://127.0.0.1/ipa/thirtysix.apk" target="_blank" rel="external nofollow" >遊戲包</a></h1>
</body>
</html>
           

5、經過如上配置,就部署完一個Nginx伺服器,使用者在Safari中通路對應的ip位址(注意要通過https來通路,不要直接輸入ip位址,因為預設是http)就可以看到index.html頁面。使用者先安裝并信任證書(https的證書),然後點選對應的連結可以調用作業系統的服務來自動下載下傳安裝應用。

繼續閱讀