Search in sources :

Example 26 with NSString

use of com.dd.plist.NSString 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 27 with NSString

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

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 28 with NSString

use of com.dd.plist.NSString 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 29 with NSString

use of com.dd.plist.NSString 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 30 with NSString

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

the class AppLauncher method mountDeveloperImage.

private void mountDeveloperImage(LockdowndClient lockdowndClient) throws Exception {
    // Find the DeveloperDiskImage.dmg path that best matches the current device. Here's what
    // the paths look like:
    // Platforms/iPhoneOS.platform/DeviceSupport/5.0/DeveloperDiskImage.dmg
    // Platforms/iPhoneOS.platform/DeviceSupport/6.0/DeveloperDiskImage.dmg
    // Platforms/iPhoneOS.platform/DeviceSupport/6.1/DeveloperDiskImage.dmg
    // Platforms/iPhoneOS.platform/DeviceSupport/7.0/DeveloperDiskImage.dmg
    // Platforms/iPhoneOS.platform/DeviceSupport/7.0 (11A465)/DeveloperDiskImage.dmg
    // Platforms/iPhoneOS.platform/DeviceSupport/7.0.3 (11B508)/DeveloperDiskImage.dmg
    // E.g. 7.0.2
    String productVersion = lockdowndClient.getValue(null, "ProductVersion").toString();
    // E.g. 11B508
    String buildVersion = lockdowndClient.getValue(null, "BuildVersion").toString();
    File deviceSupport = new File(getXcodePath(), "Platforms/iPhoneOS.platform/DeviceSupport");
    log("Looking up developer disk image for iOS version %s (%s) in %s", productVersion, buildVersion, deviceSupport);
    File devImage = findDeveloperImage(deviceSupport, productVersion, buildVersion);
    File devImageSig = new File(devImage.getParentFile(), devImage.getName() + ".signature");
    byte[] devImageSigBytes = Files.readAllBytes(devImageSig.toPath());
    LockdowndServiceDescriptor mimService = lockdowndClient.startService(MobileImageMounterClient.SERVICE_NAME);
    try (MobileImageMounterClient mimClient = new MobileImageMounterClient(device, mimService)) {
        log("Copying developer disk image %s to device", devImage);
        int majorVersion = Integer.parseInt(getProductVersionParts(productVersion)[0]);
        if (majorVersion >= 7) {
            // Use new upload method
            mimClient.uploadImage(devImage, null, devImageSigBytes);
        } else {
            LockdowndServiceDescriptor afcService = lockdowndClient.startService(AfcClient.SERVICE_NAME);
            try (AfcClient afcClient = new AfcClient(device, afcService)) {
                afcClient.makeDirectory("/PublicStaging");
                afcClient.fileCopy(devImage, "/PublicStaging/staging.dimage");
            }
        }
        log("Mounting developer disk image");
        NSDictionary result = mimClient.mountImage("/PublicStaging/staging.dimage", devImageSigBytes, null);
        NSString status = (NSString) result.objectForKey("Status");
        if (status == null || !"Complete".equals(status.toString())) {
            throw new IOException("Failed to mount " + devImage.getAbsolutePath() + " on the device.");
        }
    }
}
Also used : AfcClient(org.robovm.libimobiledevice.AfcClient) LockdowndServiceDescriptor(org.robovm.libimobiledevice.LockdowndServiceDescriptor) MobileImageMounterClient(org.robovm.libimobiledevice.MobileImageMounterClient) NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) ZipFile(java.util.zip.ZipFile) File(java.io.File) NSString(com.dd.plist.NSString)

Aggregations

NSString (com.dd.plist.NSString)31 NSDictionary (com.dd.plist.NSDictionary)22 NSArray (com.dd.plist.NSArray)18 Test (org.junit.Test)10 NSObject (com.dd.plist.NSObject)8 IOException (java.io.IOException)8 File (java.io.File)6 NSNumber (com.dd.plist.NSNumber)5 Path (java.nio.file.Path)5 PBXBuildFile (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile)4 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)4 Date (java.util.Date)4 PBXSourcesBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXSourcesBuildPhase)3 ExecutionContext (com.facebook.buck.step.ExecutionContext)3 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)3 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 NSDate (com.dd.plist.NSDate)2 PBXProject (com.facebook.buck.apple.xcode.xcodeproj.PBXProject)2 SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)2