use of com.dd.plist.NSDictionary in project buck by facebook.
the class AppleBundleIntegrationTest method simpleApplicationBundleWithDryRunCodeSigning.
@Test
public void simpleApplicationBundleWithDryRunCodeSigning() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
assumeTrue(FakeAppleDeveloperEnvironment.supportsCodeSigning());
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_application_bundle_with_codesigning", tmp);
workspace.setUp();
workspace.addBuckConfigLocalOption("apple", "dry_run_code_signing", "true");
BuildTarget target = workspace.newBuildTarget("//:DemoAppWithFramework#iphoneos-arm64,no-debug");
workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
Path appPath = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTarget.builder(target).addFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR).build(), "%s").resolve(target.getShortName() + ".app"));
Path codeSignResultsPath = appPath.resolve("BUCK_code_sign_entitlements.plist");
assertTrue(Files.exists(codeSignResultsPath));
NSDictionary resultPlist = verifyAndParsePlist(appPath.resolve("BUCK_pp_dry_run.plist"));
assertEquals(new NSString("com.example.DemoApp"), resultPlist.get("bundle-id"));
assertEquals(new NSString("12345ABCDE"), resultPlist.get("team-identifier"));
assertEquals(new NSString("00000000-0000-0000-0000-000000000000"), resultPlist.get("provisioning-profile-uuid"));
// Codesigning main bundle
resultPlist = verifyAndParsePlist(appPath.resolve("BUCK_code_sign_args.plist"));
assertEquals(new NSNumber(true), resultPlist.get("use-entitlements"));
// Codesigning embedded framework bundle
resultPlist = verifyAndParsePlist(appPath.resolve("Frameworks/DemoFramework.framework/BUCK_code_sign_args.plist"));
assertEquals(new NSNumber(false), resultPlist.get("use-entitlements"));
}
use of com.dd.plist.NSDictionary in project buck by facebook.
the class AppleBundleIntegrationTest method verifyAndParsePlist.
private NSDictionary verifyAndParsePlist(Path path) throws Exception {
assertTrue(Files.exists(path));
String resultContents = filesystem.readFileIfItExists(path).get();
NSDictionary resultPlist = (NSDictionary) PropertyListParser.parse(resultContents.getBytes(Charsets.UTF_8));
return resultPlist;
}
use of com.dd.plist.NSDictionary in project robovm by robovm.
the class IOSTarget method customizeInfoPList.
protected void customizeInfoPList(NSDictionary dict) {
if (isSimulatorArch(arch)) {
dict.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneSimulator")));
} else {
dict.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneOS")));
dict.put("DTPlatformVersion", sdk.getPlatformVersion());
dict.put("DTPlatformBuild", sdk.getPlatformBuild());
dict.put("DTSDKBuild", sdk.getBuild());
// them from the installed Xcode.
try {
File versionPListFile = new File(new File(ToolchainUtil.findXcodePath()).getParentFile(), "version.plist");
NSDictionary versionPList = (NSDictionary) PropertyListParser.parse(versionPListFile);
File xcodeInfoPListFile = new File(new File(ToolchainUtil.findXcodePath()).getParentFile(), "Info.plist");
NSDictionary xcodeInfoPList = (NSDictionary) PropertyListParser.parse(xcodeInfoPListFile);
NSString dtXcodeBuild = (NSString) versionPList.objectForKey("ProductBuildVersion");
if (dtXcodeBuild == null) {
throw new NoSuchElementException("No ProductBuildVersion in " + versionPListFile.getAbsolutePath());
}
NSString dtXcode = (NSString) xcodeInfoPList.objectForKey("DTXcode");
if (dtXcode == null) {
throw new NoSuchElementException("No DTXcode in " + xcodeInfoPListFile.getAbsolutePath());
}
putIfAbsent(dict, "DTXcode", dtXcode.toString());
putIfAbsent(dict, "DTXcodeBuild", dtXcodeBuild.toString());
} catch (Exception e) {
config.getLogger().warn("Failed to read DTXcodeBuild/DTXcode from current Xcode install. Will use fake values. (%s: %s)", e.getClass().getName(), e.getMessage());
}
// Fake Xcode 6.1.1 values if the above fails.
putIfAbsent(dict, "DTXcode", "0611");
putIfAbsent(dict, "DTXcodeBuild", "6A2008a");
}
}
use of com.dd.plist.NSDictionary in project robovm by robovm.
the class IOSTarget method getOrCreateEntitlementsPList.
private File getOrCreateEntitlementsPList(boolean getTaskAllow, String bundleId) throws IOException {
try {
File destFile = new File(config.getTmpDir(), "Entitlements.plist");
NSDictionary dict = null;
if (entitlementsPList != null) {
dict = (NSDictionary) PropertyListParser.parse(entitlementsPList);
} else {
dict = (NSDictionary) PropertyListParser.parse(IOUtils.toByteArray(getClass().getResourceAsStream("/Entitlements.plist")));
}
if (provisioningProfile != null) {
NSDictionary profileEntitlements = provisioningProfile.getEntitlements();
for (String key : profileEntitlements.allKeys()) {
if (dict.objectForKey(key) == null) {
dict.put(key, profileEntitlements.objectForKey(key));
}
}
dict.put("application-identifier", provisioningProfile.getAppIdPrefix() + "." + bundleId);
}
dict.put("get-task-allow", getTaskAllow);
PropertyListParser.saveAsXML(dict, destFile);
return destFile;
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.dd.plist.NSDictionary in project robovm by robovm.
the class SDK method create.
public static SDK create(File root) throws Exception {
File sdkSettingsFile = new File(root, "SDKSettings.plist");
File sdkSysVersionFile = new File(root, "System/Library/CoreServices/SystemVersion.plist");
File platformVersionFile = new File(root, "../../../version.plist");
File platformInfoFile = new File(root, "../../../Info.plist");
if (sdkSettingsFile.exists() && platformInfoFile.exists()) {
NSDictionary sdkSettingsDict = (NSDictionary) PropertyListParser.parse(sdkSettingsFile);
NSDictionary sdkSysVersionDict = (NSDictionary) PropertyListParser.parse(sdkSysVersionFile);
NSDictionary platformInfoDict = (NSDictionary) PropertyListParser.parse(platformInfoFile);
SDK sdk = new SDK();
sdk.root = root;
sdk.displayName = toString(sdkSettingsDict.objectForKey("DisplayName"));
sdk.minimalDisplayName = toString(sdkSettingsDict.objectForKey("MinimalDisplayName"));
sdk.canonicalName = toString(sdkSettingsDict.objectForKey("CanonicalName"));
sdk.version = toString(sdkSettingsDict.objectForKey("Version"));
sdk.defaultProperties = (NSDictionary) sdkSettingsDict.objectForKey("DefaultProperties");
sdk.build = toString(sdkSysVersionDict.objectForKey("ProductBuildVersion"));
if (platformVersionFile.exists()) {
NSDictionary platformVersionDict = (NSDictionary) PropertyListParser.parse(platformVersionFile);
sdk.platformBuild = toString(platformVersionDict.objectForKey("ProductBuildVersion"));
} else {
// iOS 9 and above, there's no version.plist file anymore
// however, the ProductBuildVersion in SystemVersion.plist
// seems to always be the same as the ProductBuildVersion
// in the now missing version.plist file
sdk.platformBuild = sdk.build;
}
NSDictionary additionalInfo = (NSDictionary) platformInfoDict.objectForKey("AdditionalInfo");
sdk.platformVersion = toString(additionalInfo.objectForKey("DTPlatformVersion"));
sdk.platformName = toString(additionalInfo.objectForKey("DTPlatformName"));
String[] parts = StringUtils.split(sdk.version, ".");
sdk.major = Integer.parseInt(parts[0]);
sdk.minor = parts.length >= 2 ? Integer.parseInt(parts[1]) : 0;
sdk.revision = parts.length >= 3 ? Integer.parseInt(parts[2]) : 0;
return sdk;
}
throw new IllegalArgumentException(root.getAbsolutePath() + " is not an SDK root path");
}
Aggregations