Search in sources :

Example 56 with NSDictionary

use of com.dd.plist.NSDictionary 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 57 with NSDictionary

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

the class AppleBundleIntegrationTest method verifyAndParsePlist.

private NSDictionary verifyAndParsePlist(Path path) throws Exception {
    assertTrue(Files.exists(path));
    String resultContents = filesystem.readFileIfItExists(path).get();
    NSDictionary resultPlist = (NSDictionary) PropertyListParser.parse(resultContents.getBytes(Charsets.UTF_8));
    return resultPlist;
}
Also used : NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 58 with NSDictionary

use of com.dd.plist.NSDictionary 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 59 with NSDictionary

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

the class IOSTarget method getOrCreateEntitlementsPList.

private File getOrCreateEntitlementsPList(boolean getTaskAllow, String bundleId) throws IOException {
    try {
        File destFile = new File(config.getTmpDir(), "Entitlements.plist");
        NSDictionary dict = null;
        if (entitlementsPList != null) {
            dict = (NSDictionary) PropertyListParser.parse(entitlementsPList);
        } else {
            dict = (NSDictionary) PropertyListParser.parse(IOUtils.toByteArray(getClass().getResourceAsStream("/Entitlements.plist")));
        }
        if (provisioningProfile != null) {
            NSDictionary profileEntitlements = provisioningProfile.getEntitlements();
            for (String key : profileEntitlements.allKeys()) {
                if (dict.objectForKey(key) == null) {
                    dict.put(key, profileEntitlements.objectForKey(key));
                }
            }
            dict.put("application-identifier", provisioningProfile.getAppIdPrefix() + "." + bundleId);
        }
        dict.put("get-task-allow", getTaskAllow);
        PropertyListParser.saveAsXML(dict, destFile);
        return destFile;
    } catch (IOException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) IOException(java.io.IOException) File(java.io.File) CompilerException(org.robovm.compiler.CompilerException) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException)

Example 60 with NSDictionary

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

the class SDK method create.

public static SDK create(File root) throws Exception {
    File sdkSettingsFile = new File(root, "SDKSettings.plist");
    File sdkSysVersionFile = new File(root, "System/Library/CoreServices/SystemVersion.plist");
    File platformVersionFile = new File(root, "../../../version.plist");
    File platformInfoFile = new File(root, "../../../Info.plist");
    if (sdkSettingsFile.exists() && platformInfoFile.exists()) {
        NSDictionary sdkSettingsDict = (NSDictionary) PropertyListParser.parse(sdkSettingsFile);
        NSDictionary sdkSysVersionDict = (NSDictionary) PropertyListParser.parse(sdkSysVersionFile);
        NSDictionary platformInfoDict = (NSDictionary) PropertyListParser.parse(platformInfoFile);
        SDK sdk = new SDK();
        sdk.root = root;
        sdk.displayName = toString(sdkSettingsDict.objectForKey("DisplayName"));
        sdk.minimalDisplayName = toString(sdkSettingsDict.objectForKey("MinimalDisplayName"));
        sdk.canonicalName = toString(sdkSettingsDict.objectForKey("CanonicalName"));
        sdk.version = toString(sdkSettingsDict.objectForKey("Version"));
        sdk.defaultProperties = (NSDictionary) sdkSettingsDict.objectForKey("DefaultProperties");
        sdk.build = toString(sdkSysVersionDict.objectForKey("ProductBuildVersion"));
        if (platformVersionFile.exists()) {
            NSDictionary platformVersionDict = (NSDictionary) PropertyListParser.parse(platformVersionFile);
            sdk.platformBuild = toString(platformVersionDict.objectForKey("ProductBuildVersion"));
        } else {
            // iOS 9 and above, there's no version.plist file anymore
            // however, the ProductBuildVersion in SystemVersion.plist
            // seems to always be the same as the ProductBuildVersion
            // in the now missing version.plist file
            sdk.platformBuild = sdk.build;
        }
        NSDictionary additionalInfo = (NSDictionary) platformInfoDict.objectForKey("AdditionalInfo");
        sdk.platformVersion = toString(additionalInfo.objectForKey("DTPlatformVersion"));
        sdk.platformName = toString(additionalInfo.objectForKey("DTPlatformName"));
        String[] parts = StringUtils.split(sdk.version, ".");
        sdk.major = Integer.parseInt(parts[0]);
        sdk.minor = parts.length >= 2 ? Integer.parseInt(parts[1]) : 0;
        sdk.revision = parts.length >= 3 ? Integer.parseInt(parts[2]) : 0;
        return sdk;
    }
    throw new IllegalArgumentException(root.getAbsolutePath() + " is not an SDK root path");
}
Also used : NSDictionary(com.dd.plist.NSDictionary) File(java.io.File)

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