Search in sources :

Example 31 with NSDictionary

use of com.dd.plist.NSDictionary in project gradle by gradle.

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
 */
private String serializeObject(PBXObject obj) {
    if (obj.getGlobalID() == null) {
        obj.setGlobalID(obj.generateGid(gidGenerator));
        LOG.trace("Set new object GID: {}", obj);
    } else {
        // Check that the object has already been serialized.
        NSObject object = objects.get(obj.getGlobalID());
        if (object != null) {
            LOG.trace("Object {} found, returning existing object {}", obj, object);
            return obj.getGlobalID();
        } else {
            LOG.trace("Object already had GID set: {}", 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)

Example 32 with NSDictionary

use of com.dd.plist.NSDictionary in project gradle by gradle.

the class GenerateXcodeProjectFileTask method toToolAndLibraryPbxTarget.

private PBXTarget toToolAndLibraryPbxTarget(XcodeTarget xcodeTarget) {
    PBXLegacyTarget target = new PBXLegacyTarget(xcodeTarget.getName(), xcodeTarget.getProductType());
    target.setProductName(xcodeTarget.getProductName());
    target.setBuildToolPath(xcodeTarget.getGradleCommand());
    target.setBuildArgumentsString(buildGradleArgs(xcodeTarget));
    target.setGlobalID(xcodeTarget.getId());
    File outputFile = xcodeTarget.getDebugOutputFile().get().getAsFile();
    target.setProductReference(new PBXFileReference(outputFile.getName(), outputFile.getAbsolutePath(), PBXReference.SourceTree.ABSOLUTE));
    xcodeTarget.getBinaries().forEach(xcodeBinary -> {
        NSDictionary settings = target.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(xcodeBinary.getBuildConfigurationName()).getBuildSettings();
        File binaryOutputFile = xcodeBinary.getOutputFile().get().getAsFile();
        settings.put("CONFIGURATION_BUILD_DIR", new NSString(binaryOutputFile.getParentFile().getAbsolutePath()));
        settings.put("PRODUCT_NAME", target.getProductName());
        settings.put("SWIFT_VERSION", toXcodeSwiftVersion(xcodeTarget.getSwiftSourceCompatibility()));
        settings.put("ARCHS", toXcodeArchitecture(xcodeBinary.getArchitectureName()));
        settings.put("VALID_ARCHS", xcodeTarget.getBinaries().stream().map(XcodeBinary::getArchitectureName).map(GenerateXcodeProjectFileTask::toXcodeArchitecture).distinct().collect(Collectors.joining(" ")));
    });
    return target;
}
Also used : XcodeBinary(org.gradle.ide.xcode.internal.XcodeBinary) PBXLegacyTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXLegacyTarget) NSDictionary(com.dd.plist.NSDictionary) XcodeProjectFile(org.gradle.ide.xcode.tasks.internal.XcodeProjectFile) PBXBuildFile(org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile) File(java.io.File) NSString(com.dd.plist.NSString) PBXFileReference(org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference)

Example 33 with NSDictionary

use of com.dd.plist.NSDictionary in project gradle by gradle.

the class GenerateXcodeProjectFileTask method toIndexPbxTarget.

private PBXTarget toIndexPbxTarget(XcodeTarget xcodeTarget) {
    PBXNativeTarget target = new PBXNativeTarget("[INDEXING ONLY] " + xcodeTarget.getName(), PBXTarget.ProductType.INDEXER);
    target.setProductName(xcodeTarget.getProductName());
    target.getBuildPhases().add(newSourceBuildPhase(xcodeTarget.getSources()));
    xcodeTarget.getBinaries().forEach(configureBuildSettings(xcodeTarget, target));
    // Create unbuildable build configuration so the indexer can keep functioning
    if (xcodeTarget.getBinaries().isEmpty()) {
        NSDictionary settings = newBuildSettings(xcodeTarget);
        target.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(UNBUILDABLE_BUILD_CONFIGURATION_NAME).setBuildSettings(settings);
    }
    return target;
}
Also used : PBXNativeTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXNativeTarget) NSDictionary(com.dd.plist.NSDictionary)

Example 34 with NSDictionary

use of com.dd.plist.NSDictionary in project gradle by gradle.

the class PBXProject method serializeInto.

@Override
public void serializeInto(XcodeprojSerializer s) {
    super.serializeInto(s);
    s.addField("mainGroup", mainGroup);
    Collections.sort(targets, Ordering.natural().onResultOf(new Function<PBXTarget, String>() {

        @Override
        public String apply(PBXTarget input) {
            return input.getName();
        }
    }));
    s.addField("targets", targets);
    s.addField("buildConfigurationList", buildConfigurationList);
    s.addField("compatibilityVersion", compatibilityVersion);
    NSDictionary d = new NSDictionary();
    d.put("LastUpgradeCheck", "0610");
    s.addField("attributes", d);
}
Also used : Function(com.google.common.base.Function) NSDictionary(com.dd.plist.NSDictionary)

Example 35 with NSDictionary

use of com.dd.plist.NSDictionary in project gradle by gradle.

the class GenerateXcodeProjectFileTask method newBuildSettings.

private NSDictionary newBuildSettings(XcodeTarget xcodeTarget) {
    NSDictionary result = new NSDictionary();
    result.put("SWIFT_VERSION", toXcodeSwiftVersion(xcodeTarget.getSwiftSourceCompatibility()));
    // Mandatory
    result.put("PRODUCT_NAME", xcodeTarget.getProductName());
    if (!xcodeTarget.getHeaderSearchPaths().isEmpty()) {
        result.put("HEADER_SEARCH_PATHS", toSpaceSeparatedList(xcodeTarget.getHeaderSearchPaths()));
    }
    if (!xcodeTarget.getCompileModules().isEmpty()) {
        result.put("SWIFT_INCLUDE_PATHS", toSpaceSeparatedList(parentDirs(xcodeTarget.getCompileModules())));
    }
    return result;
}
Also used : NSDictionary(com.dd.plist.NSDictionary)

Aggregations

NSDictionary (com.dd.plist.NSDictionary)70 NSString (com.dd.plist.NSString)33 NSObject (com.dd.plist.NSObject)22 IOException (java.io.IOException)16 Test (org.junit.Test)15 File (java.io.File)13 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 PropertyListFormatException (com.dd.plist.PropertyListFormatException)3 ExecutionContext (com.facebook.buck.step.ExecutionContext)3 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)3 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)3