Search in sources :

Example 66 with NSDictionary

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

the class Callbacks method callInstproxyCallback.

static void callInstproxyCallback(String operation, byte[] statusPlistBin, int id) throws Exception {
    StatusCallback callback = null;
    synchronized (Callbacks.class) {
        callback = instProxyStatusCallbacks.get(id);
    }
    if (callback != null) {
        boolean done = false;
        try {
            NSDictionary dict = (NSDictionary) PropertyListParser.parse(statusPlistBin);
            NSObject status = dict.objectForKey("Status");
            NSObject percentComplete = dict.objectForKey("PercentComplete");
            NSObject error = dict.objectForKey("Error");
            if (error != null) {
                done = true;
                callback.error(error.toString());
            } else {
                if ("Complete".equals(status.toString())) {
                    done = true;
                    callback.success();
                } else {
                    callback.progress(status.toString(), ((NSNumber) percentComplete).intValue());
                }
            }
        } catch (Throwable t) {
            t.printStackTrace();
        } finally {
            if (done) {
                synchronized (Callbacks.class) {
                    instProxyStatusCallbacks.remove(id);
                }
            }
        }
    }
}
Also used : NSObject(com.dd.plist.NSObject) NSDictionary(com.dd.plist.NSDictionary) StatusCallback(org.robovm.libimobiledevice.InstallationProxyClient.StatusCallback)

Example 67 with NSDictionary

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

the class GenerateXcodeProjectFileTask method toXCTestPbxTarget.

private PBXTarget toXCTestPbxTarget(XcodeTarget xcodeTarget) {
    PBXShellScriptBuildPhase hackBuildPhase = new PBXShellScriptBuildPhase();
    hackBuildPhase.setShellPath("/bin/sh");
    hackBuildPhase.setShellScript("# Script to generate specific Swift files Xcode expects when running tests.\n" + "set -eu\n" + "ARCH_ARRAY=($ARCHS)\n" + "SUFFIXES=(swiftdoc swiftmodule h)\n" + "for ARCH in \"${ARCH_ARRAY[@]}\"\n" + "do\n" + "  for SUFFIX in \"${SUFFIXES[@]}\"\n" + "  do\n" + "    touch \"$OBJECT_FILE_DIR_normal/$ARCH/$PRODUCT_NAME.$SUFFIX\"\n" + "  done\n" + "done");
    PBXSourcesBuildPhase sourcesBuildPhase = new PBXSourcesBuildPhase();
    for (File file : xcodeTarget.getSources()) {
        PBXFileReference fileReference = pathToFileReference.get(file.getAbsolutePath());
        sourcesBuildPhase.getFiles().add(new PBXBuildFile(fileReference));
    }
    PBXShellScriptBuildPhase gradleBuildPhase = new PBXShellScriptBuildPhase();
    gradleBuildPhase.setShellPath("/bin/sh");
    gradleBuildPhase.setShellScript("exec \"" + xcodeTarget.getGradleCommand() + "\" " + buildGradleArgs(xcodeTarget) + " < /dev/null");
    PBXNativeTarget target = new PBXNativeTarget(xcodeTarget.getName(), xcodeTarget.getProductType());
    target.setProductName(xcodeTarget.getProductName());
    target.setGlobalID(xcodeTarget.getId());
    // Note the order in which the build phase are added is important
    target.getBuildPhases().add(hackBuildPhase);
    target.getBuildPhases().add(sourcesBuildPhase);
    target.getBuildPhases().add(gradleBuildPhase);
    File outputFile = xcodeTarget.getDebugOutputFile().get().getAsFile();
    target.setProductReference(new PBXFileReference(outputFile.getName(), outputFile.getAbsolutePath(), PBXReference.SourceTree.ABSOLUTE));
    NSDictionary debugSettings = target.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(BUILD_DEBUG).getBuildSettings();
    NSDictionary releaseSettings = target.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(BUILD_RELEASE).getBuildSettings();
    NSDictionary testRunnerSettings = target.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(TEST_DEBUG).getBuildSettings();
    if (!xcodeTarget.getCompileModules().isEmpty()) {
        debugSettings.put("SWIFT_INCLUDE_PATHS", toSpaceSeparatedList(parentDirs(xcodeTarget.getCompileModules())));
        releaseSettings.put("SWIFT_INCLUDE_PATHS", toSpaceSeparatedList(parentDirs(xcodeTarget.getCompileModules())));
        testRunnerSettings.put("SWIFT_INCLUDE_PATHS", toSpaceSeparatedList(parentDirs(xcodeTarget.getCompileModules())));
    }
    testRunnerSettings.put("SWIFT_VERSION", toXcodeSwiftVersion(xcodeTarget.getSwiftSourceCompatibility()));
    testRunnerSettings.put("PRODUCT_NAME", target.getProductName());
    testRunnerSettings.put("OTHER_LDFLAGS", "-help");
    testRunnerSettings.put("OTHER_CFLAGS", "-help");
    testRunnerSettings.put("OTHER_SWIFT_FLAGS", "-help");
    testRunnerSettings.put("SWIFT_INSTALL_OBJC_HEADER", "NO");
    testRunnerSettings.put("SWIFT_OBJC_INTERFACE_HEADER_NAME", "$(PRODUCT_NAME).h");
    debugSettings.put("PRODUCT_NAME", target.getProductName());
    debugSettings.put("SWIFT_VERSION", toXcodeSwiftVersion(xcodeTarget.getSwiftSourceCompatibility()));
    releaseSettings.put("PRODUCT_NAME", target.getProductName());
    releaseSettings.put("SWIFT_VERSION", toXcodeSwiftVersion(xcodeTarget.getSwiftSourceCompatibility()));
    return target;
}
Also used : PBXShellScriptBuildPhase(org.gradle.ide.xcode.internal.xcodeproj.PBXShellScriptBuildPhase) PBXNativeTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXNativeTarget) NSDictionary(com.dd.plist.NSDictionary) PBXBuildFile(org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile) XcodeProjectFile(org.gradle.ide.xcode.tasks.internal.XcodeProjectFile) PBXBuildFile(org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile) File(java.io.File) PBXFileReference(org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference) PBXSourcesBuildPhase(org.gradle.ide.xcode.internal.xcodeproj.PBXSourcesBuildPhase)

Example 68 with NSDictionary

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

the class GenerateXcodeProjectFileTask method configure.

@Override
protected void configure(XcodeProjectFile projectFile) {
    PBXProject project = new PBXProject(getProject().getPath());
    project.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(BUILD_DEBUG);
    project.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(BUILD_RELEASE);
    addToGroup(project.getMainGroup(), xcodeProject.getGroups().getSources(), "Sources");
    addToGroup(project.getMainGroup(), xcodeProject.getGroups().getHeaders(), "Headers");
    addToGroup(project.getMainGroup(), xcodeProject.getGroups().getTests(), "Tests");
    addToGroup(project.getMainGroup(), xcodeProject.getGroups().getRoot());
    for (XcodeTarget xcodeTarget : xcodeProject.getTargets()) {
        project.getTargets().add(toGradlePbxTarget(xcodeTarget));
        project.getTargets().add(toIndexPbxTarget(xcodeTarget));
        if (xcodeTarget.isUnitTest()) {
            // Creates XCTest configuration only if XCTest are present.
            project.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(TEST_DEBUG);
        } else {
            File debugOutputFile = xcodeTarget.getDebugOutputFile().get().getAsFile();
            PBXFileReference fileReference = new PBXFileReference(debugOutputFile.getName(), debugOutputFile.getAbsolutePath(), PBXReference.SourceTree.ABSOLUTE);
            fileReference.setExplicitFileType(Optional.of(xcodeTarget.getOutputFileType()));
            project.getMainGroup().getOrCreateChildGroupByName(PRODUCTS_GROUP_NAME).getChildren().add(fileReference);
        }
    }
    XcodeprojSerializer serializer = new XcodeprojSerializer(gidGenerator, project);
    final NSDictionary rootObject = serializer.toPlist();
    projectFile.transformAction(new Action<NSDictionary>() {

        @Override
        public void execute(NSDictionary dict) {
            dict.clear();
            dict.putAll(rootObject);
        }
    });
}
Also used : XcodeprojSerializer(org.gradle.ide.xcode.internal.xcodeproj.XcodeprojSerializer) NSDictionary(com.dd.plist.NSDictionary) XcodeTarget(org.gradle.ide.xcode.internal.XcodeTarget) PBXProject(org.gradle.ide.xcode.internal.xcodeproj.PBXProject) XcodeProjectFile(org.gradle.ide.xcode.tasks.internal.XcodeProjectFile) PBXBuildFile(org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile) File(java.io.File) PBXFileReference(org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference)

Example 69 with NSDictionary

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

the class XcodeprojSerializer method toPlist.

/**
 * Generate a plist serialization of project bound to this serializer.
 */
public NSDictionary toPlist() {
    serializeObject(rootObject);
    NSDictionary root = new NSDictionary();
    root.put("archiveVersion", "1");
    root.put("classes", new NSDictionary());
    root.put("objectVersion", "46");
    root.put("objects", objects);
    root.put("rootObject", rootObject.getGlobalID());
    return root;
}
Also used : 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