public boolean createPlist(String title, String path, String bundleId, String fileUrl, String versionCode) throws Exception {
Log.info("开始创建plist文件");
boolean success = true;
File file = new File(path);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
throw NetException.BusinessException("创建plist文件目录异常", e);
}
}
String plist = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
+ "<plist version=\"1.0\">\n" + "<dict>\n"
+ "<key>items</key>\n"
+ "<array>\n"
+ "<dict>\n"
+ "<key>assets</key>\n"
+ "<array>\n"
+ "<dict>\n"
+ "<key>kind</key>\n"
+ "<string>software-package</string>\n"
+ "<key>url</key>\n"
// 之前所上传的ipa文件路径(必须是https,否则无法下载!)
+ "<string>" + downloadUrlHost + fileUrl + "</string>\n"
+ "</dict>\n"
+ "</array>\n"
+ "<key>metadata</key>\n"
+ "<dict>\n"
+ "<key>bundle-identifier</key>\n"
// 这个是开发者账号用户名,也可以为空,为空安装时看不到图标,完成之后可以看到
+ "<string>" + bundleId + "</string>\n"
+ "<key>bundle-version</key>\n"
// 版本号
+ "<string>"+ versionCode +"</string>\n"
+ "<key>kind</key>\n"
+ "<string>software</string>\n"
+ "<key>subtitle</key>\n"
+ "<string>下载</string>\n"
+ "<key>title</key>\n"
// 一定要有title,否则无法正常下载
+ "<string>"+ title +"</string>\n"
+ "</dict>\n"
+ "</dict>\n"
+ "</array>\n"
+ "</dict>\n"
+ "</plist>";
try {
FileOutputStream output = new FileOutputStream(file);
OutputStreamWriter writer;
writer = new OutputStreamWriter(output, "UTF-8");
writer.write(plist);
writer.close();
output.close();
} catch (Exception e) {
throw NetException.BusinessException("创建plist文件异常", e);
}
Log.info("成功创建plist文件");
return success;
}
Java: 生成plist文件
最新推荐文章于 2021-02-15 19:15:10 发布