Search in sources :

Example 21 with NSArray

use of com.dd.plist.NSArray 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");
    }
}
Also used : NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) File(java.io.File) NoSuchElementException(java.util.NoSuchElementException) CompilerException(org.robovm.compiler.CompilerException) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException)

Example 22 with NSArray

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

the class AppLauncher method getAppPath.

private String getAppPath(LockdowndClient lockdowndClient, String appId) throws IOException {
    LockdowndServiceDescriptor instService = lockdowndClient.startService(InstallationProxyClient.SERVICE_NAME);
    try (InstallationProxyClient instClient = new InstallationProxyClient(device, instService)) {
        NSArray apps = instClient.browse();
        for (int i = 0; i < apps.count(); i++) {
            NSDictionary appInfo = (NSDictionary) apps.objectAtIndex(i);
            NSString bundleId = (NSString) appInfo.objectForKey("CFBundleIdentifier");
            if (bundleId != null && appId.equals(bundleId.toString())) {
                NSString path = (NSString) appInfo.objectForKey("Path");
                NSDictionary entitlements = (NSDictionary) appInfo.objectForKey("Entitlements");
                if (entitlements == null || entitlements.objectForKey("get-task-allow") == null || !entitlements.objectForKey("get-task-allow").equals(new NSNumber(true))) {
                    throw new RuntimeException("App with id '" + appId + "' does not " + "have the 'get-task-allow' entitlement and cannot be debugged");
                }
                if (path == null) {
                    throw new RuntimeException("Path for app with id '" + appId + "' not found");
                }
                return path.toString();
            }
        }
        throw new RuntimeException("No app with id '" + appId + "' found on device");
    }
}
Also used : NSNumber(com.dd.plist.NSNumber) LockdowndServiceDescriptor(org.robovm.libimobiledevice.LockdowndServiceDescriptor) NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) InstallationProxyClient(org.robovm.libimobiledevice.InstallationProxyClient) NSString(com.dd.plist.NSString)

Example 23 with NSArray

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

the class InstallationProxyClient method browse.

/**
     * Lists installed applications of the specified type.
     *
     * @param type the type of applications to list. Either 
     *        {@link ApplicationType#User} or {@link ApplicationType#System}
     *        applications. Pass <code>null</code> to list all.
     * @return an {@link NSArray} of {@link NSDictionary}s holding information
     *         about the installed applications.
     */
public NSArray browse(Options.ApplicationType type) throws IOException {
    PlistRefOut plistOut = new PlistRefOut();
    PlistRef clientOpts = new Options().applicationType(type).toPlistRef();
    try {
        checkResult(LibIMobileDevice.instproxy_browse(getRef(), clientOpts, plistOut));
        PlistRef plist = plistOut.getValue();
        return (NSArray) PlistUtil.toJavaPlist(plist);
    } finally {
        plistOut.delete();
        LibIMobileDevice.plist_free(clientOpts);
    }
}
Also used : PlistRefOut(org.robovm.libimobiledevice.binding.PlistRefOut) PlistRef(org.robovm.libimobiledevice.binding.PlistRef) NSArray(com.dd.plist.NSArray)

Example 24 with NSArray

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

the class PBXShellScriptBuildPhase method serializeInto.

@Override
public void serializeInto(XcodeprojSerializer s) {
    super.serializeInto(s);
    NSArray inputPathsArray = new NSArray(inputPaths.size());
    for (int i = 0; i < inputPaths.size(); i++) {
        inputPathsArray.setValue(i, new NSString(inputPaths.get(i)));
    }
    s.addField("inputPaths", inputPathsArray);
    NSArray outputPathsArray = new NSArray(outputPaths.size());
    for (int i = 0; i < outputPaths.size(); i++) {
        outputPathsArray.setValue(i, new NSString(outputPaths.get(i)));
    }
    s.addField("outputPaths", outputPathsArray);
    NSString shellPathString;
    if (shellPath == null) {
        shellPathString = DEFAULT_SHELL_PATH;
    } else {
        shellPathString = new NSString(shellPath);
    }
    s.addField("shellPath", shellPathString);
    NSString shellScriptString;
    if (shellScript == null) {
        shellScriptString = DEFAULT_SHELL_SCRIPT;
    } else {
        shellScriptString = new NSString(shellScript);
    }
    s.addField("shellScript", shellScriptString);
}
Also used : NSArray(com.dd.plist.NSArray) NSString(com.dd.plist.NSString)

Example 25 with NSArray

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

the class XcodeprojSerializer method addField.

public void addField(String name, List<? extends PBXObject> objectList) {
    NSArray array = new NSArray(objectList.size());
    for (int i = 0; i < objectList.size(); i++) {
        String gid = serializeObject(objectList.get(i));
        array.setValue(i, new NSString(gid));
    }
    currentObject.put(name, array);
}
Also used : NSArray(com.dd.plist.NSArray) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString)

Aggregations

NSArray (com.dd.plist.NSArray)25 NSString (com.dd.plist.NSString)21 NSDictionary (com.dd.plist.NSDictionary)12 NSObject (com.dd.plist.NSObject)7 NSNumber (com.dd.plist.NSNumber)5 IOException (java.io.IOException)5 Test (org.junit.Test)5 File (java.io.File)4 Date (java.util.Date)4 NSDate (com.dd.plist.NSDate)2 PBXBuildFile (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile)2 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 BufferedInputStream (java.io.BufferedInputStream)2 NSData (com.dd.plist.NSData)1 PropertyListFormatException (com.dd.plist.PropertyListFormatException)1 PBXFrameworksBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXFrameworksBuildPhase)1 PBXNativeTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXNativeTarget)1 PBXProject (com.facebook.buck.apple.xcode.xcodeproj.PBXProject)1