Search in sources :

Example 6 with NSNumber

use of com.dd.plist.NSNumber in project buck by facebook.

the class AppleBundleIntegrationTest method simpleApplicationBundleWithDryRunCodeSigning.

@Test
public void simpleApplicationBundleWithDryRunCodeSigning() throws Exception {
    assumeTrue(Platform.detect() == Platform.MACOS);
    assumeTrue(FakeAppleDeveloperEnvironment.supportsCodeSigning());
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_application_bundle_with_codesigning", tmp);
    workspace.setUp();
    workspace.addBuckConfigLocalOption("apple", "dry_run_code_signing", "true");
    BuildTarget target = workspace.newBuildTarget("//:DemoAppWithFramework#iphoneos-arm64,no-debug");
    workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();
    Path appPath = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTarget.builder(target).addFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR).build(), "%s").resolve(target.getShortName() + ".app"));
    Path codeSignResultsPath = appPath.resolve("BUCK_code_sign_entitlements.plist");
    assertTrue(Files.exists(codeSignResultsPath));
    NSDictionary resultPlist = verifyAndParsePlist(appPath.resolve("BUCK_pp_dry_run.plist"));
    assertEquals(new NSString("com.example.DemoApp"), resultPlist.get("bundle-id"));
    assertEquals(new NSString("12345ABCDE"), resultPlist.get("team-identifier"));
    assertEquals(new NSString("00000000-0000-0000-0000-000000000000"), resultPlist.get("provisioning-profile-uuid"));
    // Codesigning main bundle
    resultPlist = verifyAndParsePlist(appPath.resolve("BUCK_code_sign_args.plist"));
    assertEquals(new NSNumber(true), resultPlist.get("use-entitlements"));
    // Codesigning embedded framework bundle
    resultPlist = verifyAndParsePlist(appPath.resolve("Frameworks/DemoFramework.framework/BUCK_code_sign_args.plist"));
    assertEquals(new NSNumber(false), resultPlist.get("use-entitlements"));
}
Also used : Path(java.nio.file.Path) NSNumber(com.dd.plist.NSNumber) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuildTarget(com.facebook.buck.model.BuildTarget) NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Example 7 with NSNumber

use of com.dd.plist.NSNumber 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 8 with NSNumber

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

the class RamDiskTools method setupRamDisk.

/**
     * Checks if a RAM disk is available and prunes it if necessary.
     */
public void setupRamDisk(Config config, File cacheDir, File tmpDir) {
    this.newCacheDir = cacheDir;
    this.newTmpDir = tmpDir;
    if (OS.getDefaultOS() != OS.macosx) {
        return;
    }
    File volume = new File(ROBOVM_RAM_DISK_PATH);
    if (!volume.exists()) {
        try {
            FileStore store = Files.getFileStore(new File(System.getProperty("user.home")).toPath());
            String plist = new Executor(Logger.NULL_LOGGER, "diskutil").args("info", "-plist", store.name()).execCapture();
            NSDictionary dict = (NSDictionary) PropertyListParser.parse(plist.getBytes("UTF-8"));
            NSObject value = dict.objectForKey("SolidState");
            if (value == null || (value instanceof NSNumber && !((NSNumber) value).boolValue())) {
                // @formatter:off
                config.getLogger().warn("RoboVM has detected that you are running on a slow HDD. Please consider mounting a RAM disk.\n" + "To create a 2GB RAM disk, run this in your terminal:\n" + "SIZE=2048 ; diskutil erasevolume HFS+ 'RoboVM RAM Disk' `hdiutil attach -nomount ram://$((SIZE * 2048))`\n" + "See http://docs.robovm.com/ for more info");
            // @formatter:on
            }
        } catch (Throwable t) {
            // nothing to do here, can't decide if we are on a SSD or HDD
            t.printStackTrace();
        }
        return;
    }
    try {
        FileStore store = Files.getFileStore(volume.toPath());
        if (store.getUsableSpace() < MIN_FREE_SPACE) {
            cleanRamDisk(store, volume, config);
            if (store.getUsableSpace() < MIN_FREE_SPACE) {
                config.getLogger().info("Couldn't free enough space on RAM disk, using hard drive");
                return;
            }
        }
        File newCacheDir = new File(volume, "cache");
        if (!newCacheDir.exists() && !newCacheDir.mkdirs()) {
            config.getLogger().info("Couldn't create cache directory on RAM disk, using hard drive");
            return;
        }
        File newTmpDir = new File(volume, "tmp");
        if (!newTmpDir.exists() && !newTmpDir.mkdirs()) {
            config.getLogger().info("Couldn't create tmp directory on RAM disk, using hard drive");
            return;
        }
        newTmpDir = new File(newTmpDir, tmpDir.getAbsolutePath());
        config.getLogger().info("Using RAM disk at %s for cache and tmp directory", ROBOVM_RAM_DISK_PATH);
        this.newCacheDir = newCacheDir;
        this.newTmpDir = newTmpDir;
    } catch (Throwable t) {
        config.getLogger().error("Couldn't setup RAM disk, using hard drive, %s", t.getMessage());
        this.newCacheDir = cacheDir;
        this.newTmpDir = tmpDir;
    }
}
Also used : NSNumber(com.dd.plist.NSNumber) FileStore(java.nio.file.FileStore) NSObject(com.dd.plist.NSObject) Executor(org.robovm.compiler.util.Executor) NSDictionary(com.dd.plist.NSDictionary) File(java.io.File)

Aggregations

NSNumber (com.dd.plist.NSNumber)8 NSDictionary (com.dd.plist.NSDictionary)7 NSArray (com.dd.plist.NSArray)5 NSObject (com.dd.plist.NSObject)5 NSString (com.dd.plist.NSString)5 File (java.io.File)3 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 Test (org.junit.Test)2 NSDate (com.dd.plist.NSDate)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 BufferedInputStream (java.io.BufferedInputStream)1 Field (java.lang.reflect.Field)1 FileStore (java.nio.file.FileStore)1 Date (java.util.Date)1 List (java.util.List)1 NoSuchElementException (java.util.NoSuchElementException)1 Matchers.hasXPath (org.hamcrest.Matchers.hasXPath)1