IpaUtil { public static synchronized boolean changePlistContent(File originFile, File aimFile, String softwarePackageUrl, String displayImageUrl, String fullSizeImageUrl, String bundleIdentifierValue, String bundleVersionValue, String titleValue) { if (!originFile.exists()) { logger.warn("changePlistContent file not exist, file path: {}", originFile.getPath()); return false; } try (InputStream in = new FileInputStream(originFile)) { NSDictionary rootDict = (NSDictionary) PropertyListParser.parse(in); NSArray itemsArray = ((NSArray) rootDict.get("items")); NSDictionary itemsDic = (NSDictionary) (itemsArray.getArray()[0]); NSArray assetsArray = (NSArray) itemsDic.get("assets"); for (NSObject eachItem : assetsArray.getArray()) { NSDictionary eachDic = (NSDictionary) eachItem; String kindValue = eachDic.get("kind").toString(); if (kindValue.equals("software-package")) { eachDic.put("url", softwarePackageUrl); } else if (kindValue.equals("display-image")) { eachDic.put("url", displayImageUrl); } else if (kindValue.equals("full-size-image")) { eachDic.put("url", fullSizeImageUrl); } } NSDictionary metaDataDic = (NSDictionary) itemsDic.get("metadata"); metaDataDic.put("bundle-identifier", bundleIdentifierValue); metaDataDic.put("bundle-version", bundleVersionValue); metaDataDic.put("title", titleValue); PropertyListParser.saveAsXML(rootDict, aimFile); } catch (Exception e) { logger.error("changePlistContent, Exception: [{}]", e); return false; } return true; }  @SuppressWarnings("unchecked") static Map<String, Object> parsePListToMap(InputStream in); @SuppressWarnings("unchecked") static Map<String, Object> parseMobileProvisionToMap(InputStream in); static String getFileContentByExecuteShell(String fileName); static IpaParseRes parseIpa(File file); static void parseAndStoreFile(File file, List<String> iconList, String path); static synchronized boolean changePlistContent(File originFile, File aimFile, String softwarePackageUrl, String displayImageUrl, String fullSizeImageUrl,
                                                          String bundleIdentifierValue, String bundleVersionValue, String titleValue); static Map<String, Object> generateDirByIpa(File ipaOriginFile, String ipaOriginFileName, String domain, String name); static ByteArrayOutputStream cloneInputStream(InputStream inputStream);  }
@Test public void changePlistContent() throws Exception { String urlPrefix = "https: String name = "ReDx001"; String version = "12345"; String versionName = name + version; urlPrefix = urlPrefix + "/" + versionName + "/"; String softwarePackageUrl = urlPrefix + "test.ipa"; String displayImageUrl = urlPrefix + "Icon-57.png"; String fullSizeImageUrl = urlPrefix + "Icon-512.png"; String bundleIdentifierValue = "com.monkey.bean"; String bundleVersionValue = "1.0.0.0"; String titleValue = "测试标题"; InputStream stream = IpaUtil.class.getClassLoader().getResourceAsStream("manifest.plist"); File originFile = new File("/temp/manifest.plist"); FileUtils.copyInputStreamToFile(stream, originFile); stream.close(); String newFileParentPath = originFile.getParent() + File.separator + version; File parentDir = new File(newFileParentPath); if (!parentDir.exists()) { boolean createDir = parentDir.mkdir(); if (!createDir) { System.err.println("parentDir create failed: " + parentDir); return; } } File aimFile = new File(newFileParentPath + File.separator + originFile.getName()); IpaUtil.changePlistContent(originFile, aimFile, softwarePackageUrl, displayImageUrl, fullSizeImageUrl, bundleIdentifierValue, bundleVersionValue, titleValue); }