Search in sources :

Example 51 with NSDictionary

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));
    }
}
Also used : NSDictionary(com.dd.plist.NSDictionary) PBXProject(com.facebook.buck.apple.xcode.xcodeproj.PBXProject) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Example 52 with NSDictionary

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;
}
Also used : NSDictionary(com.dd.plist.NSDictionary) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) UnflavoredBuildTarget(com.facebook.buck.model.UnflavoredBuildTarget) PBXCopyFilesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase) PBXFileReference(com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference) HashSet(java.util.HashSet)

Example 53 with NSDictionary

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());
}
Also used : NSNumber(com.dd.plist.NSNumber) NSObject(com.dd.plist.NSObject) BufferedInputStream(java.io.BufferedInputStream) NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) IOException(java.io.IOException) IOException(java.io.IOException)

Example 54 with NSDictionary

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();
}
Also used : NSObject(com.dd.plist.NSObject) NSDictionary(com.dd.plist.NSDictionary) Nullable(javax.annotation.Nullable)

Example 55 with NSDictionary

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);
}
Also used : NSObject(com.dd.plist.NSObject) NSDictionary(com.dd.plist.NSDictionary)

Aggregations

NSDictionary (com.dd.plist.NSDictionary)69 NSString (com.dd.plist.NSString)31 NSObject (com.dd.plist.NSObject)22 IOException (java.io.IOException)16 Test (org.junit.Test)15 File (java.io.File)14 NSArray (com.dd.plist.NSArray)12 Path (java.nio.file.Path)11 InputStream (java.io.InputStream)8 NSNumber (com.dd.plist.NSNumber)7 PBXBuildFile (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile)6 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)6 ImmutableMap (com.google.common.collect.ImmutableMap)6 BufferedInputStream (java.io.BufferedInputStream)6 SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)4 NoSuchFileException (java.nio.file.NoSuchFileException)4 PBXBuildFile (org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile)4 PBXFileReference (org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference)4 XcodeProjectFile (org.gradle.ide.xcode.tasks.internal.XcodeProjectFile)4 PropertyListFormatException (com.dd.plist.PropertyListFormatException)3