Search in sources :

Example 6 with NSArray

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

the class ProvisioningProfileTest method createProfile.

@SuppressWarnings("unchecked")
private ProvisioningProfile createProfile(String name, String appIdName, String appIdPrefix, String appId, boolean getTaskAllow, String provisionedDevice, String fingerprint) throws Exception {
    NSDictionary entitlements = new NSDictionary();
    entitlements.put("application-identifier", appId);
    entitlements.put("get-task-allow", new NSNumber(getTaskAllow));
    NSDictionary dict = new NSDictionary();
    dict.put("UUID", UUID.randomUUID().toString());
    dict.put("Name", name);
    dict.put("AppIDName", appIdName);
    dict.put("ApplicationIdentifierPrefix", new NSArray(new NSString(appIdPrefix)));
    dict.put("CreationDate", new NSDate(new Date()));
    dict.put("ExpirationDate", new NSDate(new Date()));
    dict.put("Entitlements", entitlements);
    dict.put("DeveloperCertificates", new NSArray());
    if (provisionedDevice != null) {
        NSArray devices = new NSArray(1);
        devices.setValue(0, new NSString(provisionedDevice));
        dict.put("ProvisionedDevices", devices);
    }
    ProvisioningProfile profile = new ProvisioningProfile(new File(""), dict);
    Field f = ProvisioningProfile.class.getDeclaredField("certFingerprints");
    f.setAccessible(true);
    List<String> certFingerprints = (List<String>) f.get(profile);
    certFingerprints.add(fingerprint);
    return profile;
}
Also used : NSNumber(com.dd.plist.NSNumber) Field(java.lang.reflect.Field) NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) List(java.util.List) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString) File(java.io.File) NSDate(com.dd.plist.NSDate) Date(java.util.Date) NSDate(com.dd.plist.NSDate)

Example 7 with NSArray

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

the class InfoPListTest method testParsePropertyList.

@Test
public void testParsePropertyList() throws Exception {
    File file = File.createTempFile(InfoPListTest.class.getSimpleName(), ".tmp");
    byte[] data = IOUtils.toByteArray(getClass().getResourceAsStream("InfoPListTest.Info.plist.xml"));
    FileUtils.writeByteArrayToFile(file, data);
    Properties props = new Properties();
    props.setProperty("prop1", "value1");
    props.setProperty("prop2", "value2");
    props.setProperty("prop3", "value3");
    props.setProperty("prop4", "value4");
    NSDictionary dict = (NSDictionary) InfoPList.parsePropertyList(file, props, true);
    assertEquals(new NSString("value1"), dict.objectForKey("Prop1"));
    assertEquals(new NSString("value2foobar"), dict.objectForKey("Prop2"));
    assertEquals(new NSString("foobarvalue3"), dict.objectForKey("Prop3"));
    assertEquals(new NSString("foovalue4bar"), dict.objectForKey("Prop4"));
    assertEquals(new NSString("foovalue1value2bar"), dict.objectForKey("Prop5"));
    assertEquals(new NSString("foovalue1woovalue2bar"), dict.objectForKey("Prop6"));
    assertEquals(new NSString("value1woovalue2"), dict.objectForKey("Prop7"));
    assertEquals(new NSString("${unknown}"), dict.objectForKey("Prop8"));
    assertEquals(Arrays.asList(new NSString("value1"), new NSString("value2")), Arrays.asList(((NSArray) dict.objectForKey("List")).getArray()));
}
Also used : NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) Properties(java.util.Properties) File(java.io.File) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Example 8 with NSArray

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

the class InstallationProxyClientTest method testBrowse.

@Test
public void testBrowse() throws Exception {
    NSArray array = client.browse();
    NSDictionary safari = null;
    for (int i = 0; i < array.count(); i++) {
        NSDictionary dict = (NSDictionary) array.objectAtIndex(i);
        NSObject v = dict.objectForKey("CFBundleIdentifier");
        if (v != null && "com.apple.mobilesafari".equals(v.toString())) {
            safari = dict;
        }
    }
    assertNotNull(safari);
}
Also used : NSObject(com.dd.plist.NSObject) NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) Test(org.junit.Test)

Example 9 with NSArray

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

the class AppleSdkDiscovery method buildSdkFromPath.

private static boolean buildSdkFromPath(Path sdkDir, AppleSdk.Builder sdkBuilder, ImmutableMap<String, AppleToolchain> xcodeToolchains, Optional<AppleToolchain> defaultToolchain, AppleConfig appleConfig) throws IOException {
    try (InputStream sdkSettingsPlist = Files.newInputStream(sdkDir.resolve("SDKSettings.plist"));
        BufferedInputStream bufferedSdkSettingsPlist = new BufferedInputStream(sdkSettingsPlist)) {
        NSDictionary sdkSettings;
        try {
            sdkSettings = (NSDictionary) PropertyListParser.parse(bufferedSdkSettingsPlist);
        } catch (PropertyListFormatException | ParseException | SAXException e) {
            LOG.error(e, "Malformatted SDKSettings.plist. Skipping SDK path %s.", sdkDir);
            return false;
        } catch (ParserConfigurationException e) {
            throw new IOException(e);
        }
        String name = sdkSettings.objectForKey("CanonicalName").toString();
        String version = sdkSettings.objectForKey("Version").toString();
        NSDictionary defaultProperties = (NSDictionary) sdkSettings.objectForKey("DefaultProperties");
        Optional<ImmutableList<String>> toolchains = appleConfig.getToolchainsOverrideForSDKName(name);
        boolean foundToolchain = false;
        if (!toolchains.isPresent()) {
            NSArray settingsToolchains = (NSArray) sdkSettings.objectForKey("Toolchains");
            if (settingsToolchains != null) {
                toolchains = Optional.of(Arrays.stream(settingsToolchains.getArray()).map(Object::toString).collect(MoreCollectors.toImmutableList()));
            }
        }
        if (toolchains.isPresent()) {
            for (String toolchainId : toolchains.get()) {
                AppleToolchain toolchain = xcodeToolchains.get(toolchainId);
                if (toolchain != null) {
                    foundToolchain = true;
                    sdkBuilder.addToolchains(toolchain);
                } else {
                    LOG.debug("Specified toolchain %s not found for SDK path %s", toolchainId, sdkDir);
                }
            }
        }
        if (!foundToolchain && defaultToolchain.isPresent()) {
            foundToolchain = true;
            sdkBuilder.addToolchains(defaultToolchain.get());
        }
        if (!foundToolchain) {
            LOG.warn("No toolchains found and no default toolchain. Skipping SDK path %s.", sdkDir);
            return false;
        } else {
            NSString platformName = (NSString) defaultProperties.objectForKey("PLATFORM_NAME");
            ApplePlatform applePlatform = ApplePlatform.of(platformName.toString());
            sdkBuilder.setName(name).setVersion(version).setApplePlatform(applePlatform);
            ImmutableList<String> architectures = validArchitecturesForPlatform(applePlatform, sdkDir);
            sdkBuilder.addAllArchitectures(architectures);
            return true;
        }
    } catch (NoSuchFileException e) {
        LOG.warn(e, "Skipping SDK at path %s, no SDKSettings.plist found", sdkDir);
        return false;
    }
}
Also used : NSArray(com.dd.plist.NSArray) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) NSDictionary(com.dd.plist.NSDictionary) ImmutableList(com.google.common.collect.ImmutableList) NoSuchFileException(java.nio.file.NoSuchFileException) IOException(java.io.IOException) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString) SAXException(org.xml.sax.SAXException) PropertyListFormatException(com.dd.plist.PropertyListFormatException) BufferedInputStream(java.io.BufferedInputStream) ParseException(java.text.ParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 10 with NSArray

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

the class NewNativeTargetProjectMutator method addSourcePathToHeadersBuildPhase.

private void addSourcePathToHeadersBuildPhase(SourcePath headerPath, PBXGroup headersGroup, HeaderVisibility visibility) {
    PBXFileReference fileReference = headersGroup.getOrCreateFileReferenceBySourceTreePath(new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputPathToSourcePath(headerPath), Optional.empty()));
    PBXBuildFile buildFile = new PBXBuildFile(fileReference);
    if (visibility != HeaderVisibility.PRIVATE) {
        NSDictionary settings = new NSDictionary();
        settings.put("ATTRIBUTES", new NSArray(new NSString(AppleHeaderVisibilities.toXcodeAttribute(visibility))));
        buildFile.setSettings(Optional.of(settings));
    } else {
        buildFile.setSettings(Optional.empty());
    }
}
Also used : SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) NSString(com.dd.plist.NSString) PBXFileReference(com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)

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