use of com.dd.plist.NSDictionary in project buck by facebook.
the class XcodeprojSerializerTest method testEmptyProject.
@Test
public void testEmptyProject() {
PBXProject project = new PBXProject("TestProject");
XcodeprojSerializer xcodeprojSerializer = new XcodeprojSerializer(new GidGenerator(ImmutableSet.of()), project);
NSDictionary rootObject = xcodeprojSerializer.toPlist();
assertEquals(project.getGlobalID(), ((NSString) rootObject.get("rootObject")).getContent());
NSDictionary objects = ((NSDictionary) rootObject.get("objects"));
NSDictionary projectObject = (NSDictionary) objects.get(project.getGlobalID());
String[] requiredKeys = { "mainGroup", "targets", "buildConfigurationList", "compatibilityVersion", "attributes" };
for (String key : requiredKeys) {
assertTrue(projectObject.containsKey(key));
}
}
use of com.dd.plist.NSDictionary in project buck by facebook.
the class ProjectGenerator method getSingleCopyFilesBuildPhase.
private PBXCopyFilesBuildPhase getSingleCopyFilesBuildPhase(CopyFilePhaseDestinationSpec destinationSpec, Iterable<TargetNode<?, ?>> targetNodes) {
PBXCopyFilesBuildPhase copyFilesBuildPhase = new PBXCopyFilesBuildPhase(destinationSpec);
HashSet<UnflavoredBuildTarget> frameworkTargets = new HashSet<UnflavoredBuildTarget>();
for (TargetNode<?, ?> targetNode : targetNodes) {
PBXFileReference fileReference = getLibraryFileReference(targetNode);
PBXBuildFile buildFile = new PBXBuildFile(fileReference);
if (fileReference.getExplicitFileType().equals(Optional.of("wrapper.framework"))) {
UnflavoredBuildTarget buildTarget = targetNode.getBuildTarget().getUnflavoredBuildTarget();
if (frameworkTargets.contains(buildTarget)) {
continue;
}
frameworkTargets.add(buildTarget);
NSDictionary settings = new NSDictionary();
settings.put("ATTRIBUTES", new String[] { "CodeSignOnCopy", "RemoveHeadersOnCopy" });
buildFile.setSettings(Optional.of(settings));
}
copyFilesBuildPhase.getFiles().add(buildFile);
}
return copyFilesBuildPhase;
}
use of com.dd.plist.NSDictionary in project buck by facebook.
the class AppleSimulatorProfileParsing method parseProfilePlistStream.
public static Optional<AppleSimulatorProfile> parseProfilePlistStream(InputStream inputStream) throws IOException {
NSDictionary profile;
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) {
try {
profile = (NSDictionary) PropertyListParser.parse(bufferedInputStream);
} catch (Exception e) {
throw new IOException(e);
}
}
NSObject supportedProductFamilyIDsObject = profile.objectForKey("supportedProductFamilyIDs");
if (!(supportedProductFamilyIDsObject instanceof NSArray)) {
LOG.warn("Invalid simulator profile.plist (supportedProductFamilyIDs missing or not an array)");
return Optional.empty();
}
NSArray supportedProductFamilyIDs = (NSArray) supportedProductFamilyIDsObject;
AppleSimulatorProfile.Builder profileBuilder = AppleSimulatorProfile.builder();
for (NSObject supportedProductFamilyID : supportedProductFamilyIDs.getArray()) {
if (supportedProductFamilyID instanceof NSNumber) {
profileBuilder.addSupportedProductFamilyIDs(((NSNumber) supportedProductFamilyID).intValue());
} else {
LOG.warn("Invalid simulator profile.plist (supportedProductFamilyIDs contains non-number %s)", supportedProductFamilyID);
return Optional.empty();
}
}
NSObject supportedArchsObject = profile.objectForKey("supportedArchs");
if (!(supportedArchsObject instanceof NSArray)) {
LOG.warn("Invalid simulator profile.plist (supportedArchs missing or not an array)");
return Optional.empty();
}
NSArray supportedArchs = (NSArray) supportedArchsObject;
for (NSObject supportedArch : supportedArchs.getArray()) {
profileBuilder.addSupportedArchitectures(supportedArch.toString());
}
return Optional.of(profileBuilder.build());
}
use of com.dd.plist.NSDictionary in project buck by facebook.
the class XcodeprojSerializer method serializeObject.
/**
* Serialize a {@link PBXObject} and its recursive descendants into the object dictionary.
*
* @return the GID of the serialized object
*
* @see PBXObject#serializeInto
*/
@Nullable
private String serializeObject(PBXObject obj) {
if (obj.getGlobalID() == null) {
obj.setGlobalID(obj.generateGid(gidGenerator));
LOG.verbose("Set new object GID: %s", obj);
} else {
// Check that the object has already been serialized.
NSObject object = objects.get(obj.getGlobalID());
if (object != null) {
LOG.verbose("Object %s found, returning existing object %s", obj, object);
return obj.getGlobalID();
} else {
LOG.verbose("Object already had GID set: %s", obj);
}
}
// Save the existing object being deserialized.
NSDictionary stack = currentObject;
currentObject = new NSDictionary();
currentObject.put("isa", obj.isa());
obj.serializeInto(this);
objects.put(obj.getGlobalID(), currentObject);
// Restore the existing object being deserialized.
currentObject = stack;
return obj.getGlobalID();
}
use of com.dd.plist.NSDictionary in project buck by facebook.
the class SDKSettings method parseDefaultPropertiesFromPlist.
/**
* Parses the contents of the provided SDKSettings.plist input stream
* and extracts the dictionary of DefaultProperties values.
*/
public static void parseDefaultPropertiesFromPlist(InputStream sdkSettingsPlist, ImmutableMap.Builder<String, String> defaultPropertiesBuilder) throws Exception {
NSObject sdkSettings = PropertyListParser.parse(sdkSettingsPlist);
if (!(sdkSettings instanceof NSDictionary)) {
throw new RuntimeException("Unexpected SDKSettings.plist contents (expected NSDictionary, got " + sdkSettings + ")");
}
getDefaultPropertiesFromNSDictionary((NSDictionary) sdkSettings, defaultPropertiesBuilder);
}
Aggregations