com.dd.plist.NSArray Java Examples

The following examples show how to use com.dd.plist.NSArray. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlistReader.java    From cyberduck with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Collection<S> readCollection(final Local file) throws AccessDeniedException {
    final Collection<S> c = new Collection<S>();
    final NSArray list = (NSArray) this.parse(file.getInputStream());
    if(null == list) {
        log.error(String.format("Invalid bookmark file %s", file));
        return c;
    }
    for(int i = 0; i < list.count(); i++) {
        NSObject next = list.objectAtIndex(i);
        if(next instanceof NSDictionary) {
            final NSDictionary dict = (NSDictionary) next;
            final S object = this.deserialize(dict);
            if(null == object) {
                continue;
            }
            c.add(object);
        }
    }
    return c;
}
 
Example #2
Source File: PlistWriter.java    From cyberduck with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void write(final Collection<S> collection, final Local file) throws AccessDeniedException {
    final NSArray list = new NSArray(collection.size());
    int i = 0;
    for(S bookmark : collection) {
        list.setValue(i, bookmark.<NSDictionary>serialize(SerializerFactory.get()));
        i++;
    }
    final String content = list.toXMLPropertyList();
    try (final OutputStream out = file.getOutputStream(false)) {
        IOUtils.write(content, out, StandardCharsets.UTF_8);
    }
    catch(IOException e) {
        throw new AccessDeniedException(String.format("Cannot create file %s", file.getAbsolute()), e);
    }
}
 
Example #3
Source File: PlistProcessStepTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@Test
public void testHandlesNonDictionaryPlists() throws Exception {
  FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();

  PlistProcessStep plistProcessStep =
      new PlistProcessStep(
          projectFilesystem,
          INPUT_PATH,
          Optional.empty(),
          OUTPUT_PATH,
          ImmutableMap.of(),
          ImmutableMap.of("Key1", new NSString("OverrideValue")),
          PlistProcessStep.OutputFormat.XML);

  NSArray array = new NSArray(new NSString("Value1"), new NSString("Value2"));
  projectFilesystem.writeContentsToPath(array.toXMLPropertyList(), INPUT_PATH);

  ExecutionContext executionContext = TestExecutionContext.newInstance();
  int errorCode = plistProcessStep.execute(executionContext).getExitCode();
  assertThat(errorCode, equalTo(0));

  assertThat(
      projectFilesystem.readFileIfItExists(OUTPUT_PATH),
      equalTo(Optional.of(array.toXMLPropertyList())));
}
 
Example #4
Source File: PBXProjectTest.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testAddFrameworkWithWeak() throws Exception{
	PBXProject project = new PBXProject(pbxFile);
	String testPath = "libsqlite3.dylib";
	PBXFile file = new PBXFile(testPath);
	file.setWeak(true);
	project.addFramework(file);

	NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes());
	NSDictionary objects = (NSDictionary)dict.objectForKey("objects");
	
	NSDictionary buildFile = (NSDictionary)objects.objectForKey(file.getUuid());
	assertNotNull(buildFile);
	NSString isa = (NSString) buildFile.get("isa");
	assertEquals("PBXBuildFile",isa.getContent());
	NSString fRef = (NSString) buildFile.get("fileRef");
	assertEquals(file.getFileRef(), fRef.getContent());
	NSDictionary settings = (NSDictionary) buildFile.get("settings");
	NSArray attributes = (NSArray) settings.get("ATTRIBUTES");
	assertTrue(attributes.containsObject(NSObject.wrap("Weak")));
}
 
Example #5
Source File: XcodeNativeTargetProjectWriter.java    From buck with Apache License 2.0 6 votes vote down vote up
private void addFileReferenceToHeadersBuildPhase(
    PBXFileReference fileReference,
    PBXHeadersBuildPhase headersBuildPhase,
    HeaderVisibility visibility,
    boolean frameworkHeadersEnabled,
    Optional<ProductType> productType) {
  PBXBuildFile buildFile = objectFactory.createBuildFile(fileReference);
  if (visibility != HeaderVisibility.PRIVATE) {
    productType.ifPresent(
        type -> {
          if (frameworkHeadersEnabled
              && (type == ProductTypes.FRAMEWORK || type == ProductTypes.STATIC_FRAMEWORK)) {
            headersBuildPhase.getFiles().add(buildFile);
          }
        });

    NSDictionary settings = new NSDictionary();
    settings.put(
        "ATTRIBUTES",
        new NSArray(new NSString(AppleHeaderVisibilities.toXcodeAttribute(visibility))));
    buildFile.setSettings(Optional.of(settings));
  } else {
    buildFile.setSettings(Optional.empty());
  }
}
 
Example #6
Source File: PBXProjectTest.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testAddToLibrarySearchPaths() throws Exception{
	PBXProject project = new PBXProject(pbxFile);
	String testPath = "my/files/abcd.h";
	PBXFile file = new PBXFile(testPath);
	project.addToLibrarySearchPaths(file);
	
	NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes());
	NSDictionary objects = (NSDictionary)dict.objectForKey("objects");
	HashMap<String, NSObject> hashmap =  objects.getHashMap();	
	Collection<NSObject> values = hashmap.values();
	for (NSObject nsObject : values) {
		NSDictionary obj = (NSDictionary) nsObject;
		NSString isa = (NSString) obj.objectForKey("isa");
		if(isa != null && isa.getContent().equals("XCBuildConfiguration")){
			NSDictionary buildSettings = (NSDictionary) obj.objectForKey("buildSettings");
			assertTrue(buildSettings.containsKey("LIBRARY_SEARCH_PATHS"));
			NSArray searchPaths = (NSArray) buildSettings.get("LIBRARY_SEARCH_PATHS"); 
			assertEquals("$(SRCROOT)/Test_Application/my/files", ((NSString)searchPaths.objectAtIndex(1)).getContent());
		}
	}

}
 
Example #7
Source File: PBXProject.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
private void addToPbxBuildFileSection(PBXFile pbxfile) throws PBXProjectException {
	NSDictionary obj = new NSDictionary();
	obj.put("isa" , "PBXBuildFile");
	obj.put("fileRef", pbxfile.getFileRef());
	if (pbxfile.hasSettings()){
		NSDictionary settings = new NSDictionary();
		if(pbxfile.isWeak()){
			NSArray attribs = new NSArray(NSObject.wrap("Weak"));
			settings.put("ATTRIBUTES", attribs);
		}
		if(pbxfile.getCompilerFlags() != null ){
			settings.put("COMPILER_FLAGS", NSObject.wrap(pbxfile.getCompilerFlags()));
		}
		obj.put("settings", settings);
	}
	getObjects().put(pbxfile.getUuid(), obj);
}
 
Example #8
Source File: PBXBuildPhasesTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testShellScriptBuildPhase() {
  String phaseName = "Test Phase Name";
  String input = "$(SRCROOT)/test.md";
  String output = "$(SRCROOT)/test.html";
  String inputFileList = "$(SRCROOT)/test-extra-inputs.xcfilelist";
  String outputFileList = "$(SRCROOT)/test-extra-outputs.xcfilelist";
  String script = "echo 'test'";

  PBXShellScriptBuildPhase buildPhase = new PBXShellScriptBuildPhase();
  buildPhase.setRunOnlyForDeploymentPostprocessing(Optional.of(Boolean.TRUE));
  buildPhase.setName(Optional.of(phaseName));
  buildPhase.getInputPaths().add(input);
  buildPhase.getOutputPaths().add(output);
  buildPhase.getInputFileListPaths().add(inputFileList);
  buildPhase.getOutputFileListPaths().add(outputFileList);
  buildPhase.setShellScript(script);
  target.getBuildPhases().add(buildPhase);

  NSDictionary projPlist = serializer.toPlist();
  NSDictionary phaseDict = getObjectForGID(buildPhase.getGlobalID(), projPlist);

  assertEquals(new NSString(phaseName), phaseDict.get("name"));
  assertEquals(new NSString("1"), phaseDict.get("runOnlyForDeploymentPostprocessing"));
  assertEquals(new NSArray(new NSString(input)), phaseDict.get("inputPaths"));
  assertEquals(new NSArray(new NSString(output)), phaseDict.get("outputPaths"));
  assertEquals(new NSArray(new NSString(inputFileList)), phaseDict.get("inputFileListPaths"));
  assertEquals(new NSArray(new NSString(outputFileList)), phaseDict.get("outputFileListPaths"));
  assertEquals(new NSString(script), phaseDict.get("shellScript"));
}
 
Example #9
Source File: ProvisioningProfileStoreTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrefixOverride() throws Exception {
  ProvisioningProfileMetadata expected =
      makeTestMetadata(
          "AAAAAAAAAA.*", new Date(Long.MAX_VALUE), "00000000-0000-0000-0000-000000000000");

  ProvisioningProfileStore profiles =
      createStorefromProvisioningProfiles(
          ImmutableList.of(
              expected,
              makeTestMetadata(
                  "BBBBBBBBBB.com.facebook.test",
                  new Date(Long.MAX_VALUE),
                  "00000000-0000-0000-0000-000000000000")));

  NSString[] fakeKeychainAccessGroups = {new NSString("AAAAAAAAAA.*")};
  ImmutableMap<String, NSObject> fakeEntitlements =
      ImmutableMap.of("keychain-access-groups", new NSArray(fakeKeychainAccessGroups));

  Optional<ProvisioningProfileMetadata> actual =
      profiles.getBestProvisioningProfile(
          "com.facebook.test",
          ApplePlatform.IPHONEOS,
          Optional.of(fakeEntitlements),
          ProvisioningProfileStore.MATCH_ANY_IDENTITY,
          new StringBuffer());

  assertThat(actual.get(), is(equalTo(expected)));
}
 
Example #10
Source File: XcodeprojSerializer.java    From buck with Apache License 2.0 5 votes vote down vote up
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));
  }
  Objects.requireNonNull(currentObject).put(name, array);
}
 
Example #11
Source File: PBXShellScriptBuildPhase.java    From buck with Apache License 2.0 5 votes vote down vote up
/** Converts List of Strings into NSArray of NSStrings */
protected NSArray serializeStringList(List<String> list) {
  NSArray result = new NSArray(list.size());
  for (int i = 0; i < list.size(); i++) {
    result.setValue(i, new NSString(list.get(i)));
  }
  return result;
}
 
Example #12
Source File: ProvisioningProfileStore.java    From buck with Apache License 2.0 5 votes vote down vote up
private String getStringFromNSObject(@Nullable NSObject obj) {
  if (obj == null) {
    return "(not set)" + System.lineSeparator();
  } else if (obj instanceof NSArray) {
    return ((NSArray) obj).toASCIIPropertyList();
  } else if (obj instanceof NSDictionary) {
    return ((NSDictionary) obj).toASCIIPropertyList();
  } else {
    return obj.toString() + System.lineSeparator();
  }
}
 
Example #13
Source File: ProvisioningProfileStore.java    From buck with Apache License 2.0 5 votes vote down vote up
private static boolean matchesOrArrayIsSubsetOf(@Nullable NSObject lhs, @Nullable NSObject rhs) {
  if (lhs == null) {
    return (rhs == null);
  }

  if (lhs instanceof NSArray && rhs instanceof NSArray) {
    List<NSObject> lhsList = Arrays.asList(((NSArray) lhs).getArray());
    List<NSObject> rhsList = Arrays.asList(((NSArray) rhs).getArray());
    return rhsList.containsAll(lhsList);
  }

  return lhs.equals(rhs);
}
 
Example #14
Source File: ProvisioningProfileMetadata.java    From buck with Apache License 2.0 5 votes vote down vote up
/**
 * Takes an ImmutableMap representing an entitlements file, returns the application prefix if it
 * can be inferred from keys in the entitlement. Otherwise, it returns empty.
 */
public static Optional<String> prefixFromEntitlements(
    ImmutableMap<String, NSObject> entitlements) {
  try {
    NSArray keychainAccessGroups = ((NSArray) entitlements.get("keychain-access-groups"));
    Objects.requireNonNull(keychainAccessGroups);
    String appID = keychainAccessGroups.objectAtIndex(0).toString();
    return Optional.of(splitAppID(appID).getFirst());
  } catch (RuntimeException e) {
    return Optional.empty();
  }
}
 
Example #15
Source File: NewNativeTargetProjectMutator.java    From buck with Apache License 2.0 5 votes vote down vote up
private void addSourcePathToHeadersBuildPhase(
    SourcePath headerPath,
    PBXGroup headersGroup,
    PBXHeadersBuildPhase headersBuildPhase,
    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) {

    if (this.frameworkHeadersEnabled
        && (this.productType == ProductTypes.FRAMEWORK
            || this.productType == ProductTypes.STATIC_FRAMEWORK)) {
      headersBuildPhase.getFiles().add(buildFile);
    }

    NSDictionary settings = new NSDictionary();
    settings.put(
        "ATTRIBUTES",
        new NSArray(new NSString(AppleHeaderVisibilities.toXcodeAttribute(visibility))));
    buildFile.setSettings(Optional.of(settings));
  } else {
    buildFile.setSettings(Optional.empty());
  }
}
 
Example #16
Source File: PBXProject.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private void addToPbxGroup(String groupName, PBXFile pbxfile) throws PBXProjectException {
	NSDictionary group = getGroupByName(groupName);
	NSArray children = (NSArray) group.objectForKey("children");
	NSObject[] childs = children.getArray();
	NSObject[] newChilds = new NSObject[childs.length +1];
	System.arraycopy(childs, 0, newChilds, 0, childs.length);
	newChilds[newChilds.length-1] = new NSString(pbxfile.getFileRef());
	NSArray newArray = new NSArray(newChilds);
	group.remove("children");
	group.put("children", newArray);
	
}
 
Example #17
Source File: PBXProject.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private void addToBuildPhase(String phaseName, PBXFile pbxfile) throws PBXProjectException {
	NSDictionary phase = getPhaseByName(phaseName);
	NSArray files = (NSArray) phase.objectForKey("files");
	NSObject[] current = files.getArray();
	NSObject[] newArray = new NSObject[ current.length +1 ];
	System.arraycopy(current, 0, newArray, 0, current.length);
	newArray[newArray.length-1] = new NSString(pbxfile.getUuid());
	NSArray newNSArray = new NSArray(newArray);
	phase.remove("files");
	phase.put("files", newNSArray);
}
 
Example #18
Source File: PBXProjectTest.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testAddHeader() throws Exception{
	PBXProject project = new PBXProject(pbxFile);
	String testPath = "file.h";
	PBXFile file = new PBXFile(testPath);
	project.addHeaderFile(file);
	
	NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes());
	NSDictionary objects = (NSDictionary)dict.objectForKey("objects");
	
	//Added the PBXFileReference object correctly?
	NSDictionary fileRef = (NSDictionary) objects.objectForKey(file.getFileRef());
	assertNotNull(fileRef);
	NSString isa = (NSString)fileRef.get("isa");
	assertEquals("PBXFileReference",isa.getContent());
	NSString path = (NSString)fileRef.get("path");
	assertEquals(testPath, path.getContent());
	NSString lastType = (NSString)fileRef.get("lastKnownFileType");
	assertEquals("sourcecode.c.h", lastType.getContent());
	NSString sourceTree = (NSString)fileRef.get("sourceTree");
	assertEquals(DEFAULT_GROUP, sourceTree.getContent());
	NSString name = (NSString) fileRef.get("name");
	assertEquals("file.h", name.getContent());
	NSString encoding = (NSString) fileRef.get("fileEncoding");
	assertEquals("4", encoding.getContent());

	//Added to the Plugins PBXGroup group?
	NSDictionary group = getGroupByName(objects, "Plugins");
	NSArray children = (NSArray) group.objectForKey("children");
	assertTrue(children.containsObject(new NSString(file.getFileRef())));
	
}
 
Example #19
Source File: PBXProjectTest.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testAddResourceWithPlugin() throws Exception{
	PBXProject project = new PBXProject(pbxFile);
	String testPath = "assets.bundle";
	PBXFile file = new PBXFile(testPath);
	file.setPlugin(true);
	project.addResourceFile(file);
	
	NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes());
	NSDictionary objects = (NSDictionary)dict.objectForKey("objects");
	
	//Added the PBXFileReference object correctly?
	NSDictionary fileRef = (NSDictionary) objects.objectForKey(file.getFileRef());
	assertNotNull(fileRef);
	NSString isa = (NSString)fileRef.get("isa");
	assertEquals("PBXFileReference",isa.getContent());
	NSString path = (NSString)fileRef.get("path");
	assertEquals("assets.bundle", path.getContent());
	NSString lastType = (NSString)fileRef.get("lastKnownFileType");
	assertEquals("\"wrapper.plug-in\"", lastType.getContent());
	NSString sourceTree = (NSString)fileRef.get("sourceTree");
	assertEquals(DEFAULT_GROUP, sourceTree.getContent());
	NSString name = (NSString) fileRef.get("name");
	assertEquals("assets.bundle", name.getContent());
	assertFalse(fileRef.containsKey("fileEncoding"));


	//Added to the Plugins PBXGroup group?
	NSDictionary group = getGroupByName(objects, "Plugins");
	NSArray children = (NSArray) group.objectForKey("children");
	assertTrue(children.containsObject(new NSString(file.getFileRef())));
	
	//Added to the PBXSourcesBuildPhase
	NSDictionary phase = getPhase(objects, "PBXResourcesBuildPhase");
	NSArray files = (NSArray) phase.get("files");
	assertTrue(files.containsObject(new NSString(file.getUuid())));


}
 
Example #20
Source File: PBXProjectTest.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isFileEntryFoundOnPluginsGroup(PBXFile file,
		NSDictionary objects) throws PBXProjectException {
	NSDictionary group = getGroupByName(objects, "Plugins");
	NSArray children = (NSArray) group.objectForKey("children");
	boolean groupFound = false;
	NSObject[] childs = children.getArray();
	for (int i = 0; i < childs.length; i++) {
		NSString str = (NSString)childs[i];
		if(str.getContent().equals(file.getFileRef())){
			groupFound = true;
			break;
		}
	}
	return groupFound;
}
 
Example #21
Source File: ColorParser.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
private static long getColorFromOXPArray(NSArray colorArray) {
	NSObject[] array = colorArray.getArray();
	float r = array.length > 0 ? ((NSNumber) array[0]).floatValue() : 0;
	float g = array.length > 1 ? ((NSNumber) array[1]).floatValue() : 0;
	float b = array.length > 2 ? ((NSNumber) array[2]).floatValue() : 0;
	float a = array.length > 3 ? ((NSNumber) array[3]).floatValue() : 1;
	
	if (r <= 1.0f && g <= 1.0f && b <= 1.0f && a <= 1.0f) {
		return AliteColors.convertRgba(r, g, b, a);
	} 
	a = array.length > 3 ? ((NSNumber) array[3]).floatValue() : 255.0f;
	return AliteColors.convertRgba(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
}
 
Example #22
Source File: ColorParser.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
public static long getColorFromOXP(NSObject colorDef) {
	if (colorDef instanceof NSDictionary) {
		return getColorFromOXPDict((NSDictionary) colorDef);
	} else if (colorDef instanceof NSString) {
		return getColorFromOXPString((NSString) colorDef);
	} else if (colorDef instanceof NSArray) {
		return getColorFromOXPArray((NSArray) colorDef);
	}
	AliteLog.e("Unknown color definition", "ColorDef is unknown: " + colorDef);
	return 0;
}
 
Example #23
Source File: EscrowedKeys.java    From InflatableDonkey with MIT License 5 votes vote down vote up
static NSDictionary pcsRecord(NSDictionary records) {
    NSArray metadataList = PListsLegacy.getAs(records, "metadataList", NSArray.class);
    return Stream.of(metadataList.getArray())
            .filter(EscrowedKeys::isPCSRecord)
            .map(nsObject -> (NSDictionary) nsObject)
            .findFirst()
            .orElseThrow(() -> new IllegalArgumentException("no escrow PCS record found: InflatableDonkey doesn't support iOS8 or earlier backups"));
}
 
Example #24
Source File: PlistSerializer.java    From cyberduck with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setStringListForKey(final Collection<String> value, final String key) {
    final NSArray list = new NSArray(value.size());
    int i = 0;
    for(String serializable : value) {
        list.setValue(i, serializable);
        i++;
    }
    dict.put(key, list);
}
 
Example #25
Source File: PlistSerializer.java    From cyberduck with GNU General Public License v3.0 5 votes vote down vote up
@Override
public <T extends Serializable> void setListForKey(final Collection<T> value, final String key) {
    final NSArray list = new NSArray(value.size());
    int i = 0;
    for(Serializable serializable : value) {
        list.setValue(i, serializable.<NSDictionary>serialize(SerializerFactory.get()));
        i++;
    }
    dict.put(key, list);
}
 
Example #26
Source File: PlistDeserializer.java    From cyberduck with GNU General Public License v3.0 5 votes vote down vote up
@Override
public <T> List<T> listForKey(final String key) {
    final NSObject value = dict.objectForKey(key);
    if(null == value) {
        return null;
    }
    if(value instanceof NSArray) {
        final NSArray array = (NSArray) value;
        final List<T> list = new ArrayList<T>();
        for(int i = 0; i < array.count(); i++) {
            final NSObject next = array.objectAtIndex(i);
            if(next instanceof NSDictionary) {
                list.add((T) next);
            }
            else if(next instanceof NSString) {
                list.add((T) next.toString());
            }
            else {
                log.warn(String.format("Ignore content of type %s", next));
            }

        }
        return list;
    }
    log.warn(String.format("Unexpected value type for serialized key %s", key));
    return null;
}
 
Example #27
Source File: AppleBundle.java    From buck with Apache License 2.0 4 votes vote down vote up
private ImmutableMap<String, NSObject> getInfoPlistAdditionalKeys() {
  ImmutableMap.Builder<String, NSObject> keys = ImmutableMap.builder();

  switch (platform.getType()) {
    case MAC:
      if (needsAppInfoPlistKeysOnMac()) {
        keys.put("NSHighResolutionCapable", new NSNumber(true));
        keys.put("NSSupportsAutomaticGraphicsSwitching", new NSNumber(true));
      }
      keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("MacOSX")));
      break;
    case IOS_DEVICE:
      keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneOS")));
      break;
    case IOS_SIMULATOR:
      keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneSimulator")));
      break;
    case WATCH_DEVICE:
      if (!isLegacyWatchApp()) {
        keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("WatchOS")));
      }
      break;
    case WATCH_SIMULATOR:
      if (!isLegacyWatchApp()) {
        keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("WatchSimulator")));
      }
      break;
    case TV_DEVICE:
    case TV_SIMULATOR:
    case UNKNOWN:
      break;
  }

  keys.put("DTPlatformName", new NSString(platform.getName()));
  keys.put("DTPlatformVersion", new NSString(sdkVersion));
  keys.put("DTSDKName", new NSString(sdkName + sdkVersion));
  keys.put("MinimumOSVersion", new NSString(minOSVersion));
  if (platformBuildVersion.isPresent()) {
    keys.put("DTPlatformBuild", new NSString(platformBuildVersion.get()));
    keys.put("DTSDKBuild", new NSString(platformBuildVersion.get()));
  }

  if (xcodeBuildVersion.isPresent()) {
    keys.put("DTXcodeBuild", new NSString(xcodeBuildVersion.get()));
  }

  if (xcodeVersion.isPresent()) {
    keys.put("DTXcode", new NSString(xcodeVersion.get()));
  }

  return keys.build();
}
 
Example #28
Source File: PropertyListResponseHandler.java    From InflatableDonkey with MIT License 4 votes vote down vote up
public static PropertyListResponseHandler<NSArray> array() {
    return ARRAY;
}
 
Example #29
Source File: ProvisioningProfileStoreTest.java    From buck with Apache License 2.0 4 votes vote down vote up
@Test
public void testDiagnostics() {
  NSString[] fakeKeychainAccessGroups = {new NSString("AAAAAAAAAA.*")};
  NSArray fakeKeychainAccessGroupsArray = new NSArray(fakeKeychainAccessGroups);

  ImmutableMap<String, NSObject> fakeDevelopmentEntitlements =
      ImmutableMap.of(
          "keychain-access-groups",
          fakeKeychainAccessGroupsArray,
          "aps-environment",
          new NSString("development"),
          "com.apple.security.application-groups",
          new NSArray(new NSString("foobar"), new NSString("bar")));

  ProvisioningProfileStore profiles =
      createStorefromProvisioningProfiles(
          ImmutableList.of(
              makeTestMetadata(
                  "AAAAAAAAAA.com.facebook.test",
                  new Date(Long.MAX_VALUE),
                  "00000000-0000-0000-0000-000000000000",
                  fakeDevelopmentEntitlements)));

  StringBuffer diagnosticsBuffer = new StringBuffer();
  Optional<ProvisioningProfileMetadata> actual =
      profiles.getBestProvisioningProfile(
          "com.facebook.test",
          ApplePlatform.IPHONEOS,
          Optional.of(
              ImmutableMap.of(
                  "keychain-access-groups",
                  fakeKeychainAccessGroupsArray,
                  "aps-environment",
                  new NSString("production"),
                  "com.apple.security.application-groups",
                  new NSArray(new NSString("foo"), new NSString("bar")))),
          ProvisioningProfileStore.MATCH_ANY_IDENTITY,
          diagnosticsBuffer);
  String diagnostics = diagnosticsBuffer.toString();
  assertThat(
      diagnostics,
      containsString(
          "mismatched entitlement aps-environment;"
              + System.lineSeparator()
              + "value is: development"
              + System.lineSeparator()
              + "but expected: production"));
  assertThat(
      diagnostics,
      containsString(
          "mismatched entitlement com.apple.security.application-groups;"
              + System.lineSeparator()
              + "value is: (\"foobar\", \"bar\")"
              + System.lineSeparator()
              + "but expected: (\"foo\", \"bar\")"));
  assertFalse(actual.isPresent());
}