com.dd.plist.NSString Java Examples

The following examples show how to use com.dd.plist.NSString. 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: 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 #2
Source File: ProvisioningProfileCopyStepTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@Test
public void testApplicationIdentifierIsInInfoPlist() throws Exception {
  assumeTrue(Platform.detect() == Platform.MACOS);
  Path infoPlistPath = testdataDir.resolve("Info.plist");
  ProvisioningProfileCopyStep step =
      new ProvisioningProfileCopyStep(
          projectFilesystem,
          infoPlistPath,
          ApplePlatform.IPHONEOS,
          Optional.empty(),
          Optional.empty(),
          ProvisioningProfileStoreFactory.fromSearchPath(
              new DefaultProcessExecutor(new TestConsole()), FAKE_READ_COMMAND, testdataDir),
          outputFile,
          xcentFile,
          codeSignIdentitiesSupplier,
          Optional.empty());
  step.execute(executionContext);

  byte[] infoPlistContents = projectFilesystem.getFileBytes(infoPlistPath);
  NSDictionary infoPlist = (NSDictionary) PropertyListParser.parse(infoPlistContents);
  assertEquals(
      infoPlist.get("ApplicationIdentifier"), new NSString("ABCDE12345.com.example.TestApp"));
}
 
Example #3
Source File: ProvisioningProfileCopyStepTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@Test
public void testApplicationIdentifierIsValid() throws Exception {
  assumeTrue(Platform.detect() == Platform.MACOS);
  ProvisioningProfileCopyStep step =
      new ProvisioningProfileCopyStep(
          projectFilesystem,
          testdataDir.resolve("Info.plist"),
          ApplePlatform.IPHONEOS,
          Optional.of("00000000-0000-0000-0000-000000000000"),
          Optional.of(entitlementsFile),
          ProvisioningProfileStoreFactory.fromSearchPath(
              new DefaultProcessExecutor(new TestConsole()), FAKE_READ_COMMAND, testdataDir),
          outputFile,
          xcentFile,
          codeSignIdentitiesSupplier,
          Optional.empty());
  step.execute(executionContext);

  Optional<String> xcentContents = projectFilesystem.readFileIfItExists(xcentFile);
  assertTrue(xcentContents.isPresent());
  NSDictionary xcentPlist =
      (NSDictionary) PropertyListParser.parse(xcentContents.get().getBytes());
  assertEquals(
      xcentPlist.get("application-identifier"), new NSString("ABCDE12345.com.example.TestApp"));
}
 
Example #4
Source File: XcodeprojSerializerTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmptyProject() {
  PBXProject project = new PBXProject("TestProject", AbstractPBXObjectFactory.DefaultFactory());
  XcodeprojSerializer xcodeprojSerializer = new XcodeprojSerializer(new GidGenerator(), 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));
  }
}
 
Example #5
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 #6
Source File: WorkspaceGeneratorTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@Test
public void workspaceEnabledForLegacyBuildSystem() throws Exception {
  AppleConfig appleConfig =
      FakeBuckConfig.builder()
          .setSections("[apple]", "use_modern_build_system = false")
          .build()
          .getView(AppleConfig.class);

  WorkspaceGenerator generator =
      new WorkspaceGenerator(projectFilesystem, "ws", Paths.get("."), appleConfig);

  Path workspacePath = generator.writeWorkspace();
  Optional<String> settings =
      projectFilesystem.readFileIfItExists(
          workspacePath.resolve("xcshareddata/WorkspaceSettings.xcsettings"));
  assertThat(settings.isPresent(), equalTo(true));
  NSObject object = PropertyListParser.parse(settings.get().getBytes(Charsets.UTF_8));
  assertThat(object, instanceOf(NSDictionary.class));
  NSObject buildSystemType = ((NSDictionary) object).get("BuildSystemType");
  assertThat(buildSystemType, instanceOf(NSString.class));
  assertThat(buildSystemType, equalTo(new NSString("Original")));
}
 
Example #7
Source File: ProvisioningProfileCopyStep.java    From buck with Apache License 2.0 6 votes vote down vote up
private ImmutableMap<String, NSObject> getInfoPlistAdditionalKeys(
    String bundleID, ProvisioningProfileMetadata bestProfile) throws IOException {
  ImmutableMap.Builder<String, NSObject> keys = ImmutableMap.builder();

  // Get bundle type and restrict additional keys based on it
  String bundleType =
      AppleInfoPlistParsing.getBundleTypeFromPlistStream(
              infoPlist, filesystem.getInputStreamForRelativePath(infoPlist))
          .get();
  if ("APPL".equalsIgnoreCase(bundleType.toString())) {
    // Skip additional keys for watchOS bundles (property keys whitelist)
    Optional<Boolean> isWatchOSApp =
        AppleInfoPlistParsing.isWatchOSAppFromPlistStream(
            infoPlist, filesystem.getInputStreamForRelativePath(infoPlist));
    if (!isWatchOSApp.isPresent() || !isWatchOSApp.get()) {
      // Construct AppID using the Provisioning Profile info (app prefix)
      String appID = bestProfile.getAppID().getFirst() + "." + bundleID;
      keys.put("ApplicationIdentifier", new NSString(appID));
    }
  }

  return keys.build();
}
 
Example #8
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 #9
Source File: PBXProject.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
public String getProductName() throws PBXProjectException {
	HashMap<String, NSObject> hashmap =  getObjects().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");
			if( buildSettings.containsKey("PRODUCT_NAME")){
				NSString name = (NSString) buildSettings.get("PRODUCT_NAME");
				return name.getContent().replace('"', ' ').trim();
			}
		}
	}
	return null;
}
 
Example #10
Source File: PBXProject.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
private NSString searchPathForFile(PBXFile pbxfile) throws PBXProjectException {
	String filepath = FilenameUtils.getFullPathNoEndSeparator(pbxfile.getPath());
	if(filepath.equals(".")){
		filepath = "";
	}else{
		filepath = "/"+filepath;
	}
	NSDictionary group = getGroupByName("Plugins");
	
	if(pbxfile.isPlugin() && group.containsKey("path")){
		NSString groupPath = (NSString)group.objectForKey("path");
		return NSObject.wrap("$(SRCROOT)/" + groupPath.getContent().replace('"', ' ').trim());
    }
	else{
		return NSObject.wrap("$(SRCROOT)/"+ getProductName() + filepath );
	}
}
 
Example #11
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 #12
Source File: PBXProjectTest.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testAddPluginFile() throws Exception{
	PBXProject project = new PBXProject(pbxFile);
	String testPath = "my/files/abc.h";
	PBXFile file = new PBXFile(testPath);
	project.addPluginFile(file);
	
	
	NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes());
	NSDictionary objects = (NSDictionary)dict.objectForKey("objects");
	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(HEADER_FILE, lastType.getContent());
	NSString encoding = (NSString)fileRef.get("fileEncoding");
	assertEquals("4", encoding.getContent());
	NSString sourceTree = (NSString)fileRef.get("sourceTree");
	assertEquals(DEFAULT_GROUP, sourceTree.getContent());
	
	assertTrue("No entry found on the Plugins group",isFileEntryFoundOnPluginsGroup(file, objects));
	
}
 
Example #13
Source File: InflatableData.java    From InflatableDonkey with MIT License 6 votes vote down vote up
public static Optional<InflatableData> from(byte[] bs) {
    InflatableData data;
    try {
        NSDictionary parse = (NSDictionary) PropertyListParser.parse(bs);
        byte[] escrowedKeys = ((NSData) parse.get("escrowedKeys")).bytes();
        UUID deviceUuid = UUID.fromString(((NSString) parse.get("deviceUuid")).getContent());
        String deviceHardWareId = ((NSString) parse.get("deviceHardWareId")).getContent();
        data = new InflatableData(escrowedKeys, deviceUuid, deviceHardWareId);

    } catch (ClassCastException | IllegalArgumentException | IOException | NullPointerException
            | PropertyListFormatException | ParseException | ParserConfigurationException | SAXException ex) {
        logger.warn("-- from() - exception: ", ex);
        data = null;
    }
    return Optional.ofNullable(data);
}
 
Example #14
Source File: EscrowOperationsRecover.java    From InflatableDonkey with MIT License 6 votes vote down vote up
static NSDictionary recover(
        HttpClient httpClient,
        EscrowProxyRequestFactory requests,
        SRPClient srpClient,
        NSDictionary srpInitResponse) throws IOException {

    validateSrpInitResponse(srpInitResponse);

    String dsid = PListsLegacy.getAs(srpInitResponse, "dsid", NSString.class).getContent();
    String respBlob = PListsLegacy.getAs(srpInitResponse, "respBlob", NSString.class).getContent();

    BlobA4 blob = blobA4(respBlob);

    byte[] m1 = calculateM1(srpClient, blob, dsid);
    byte[] uid = blob.uid();
    byte[] tag = blob.tag();

    return recover(httpClient, requests, uid, tag, m1);
}
 
Example #15
Source File: PlistProcessStepTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testAdditionDoesNotReplaceExistingKey() throws Exception {
  FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();

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

  NSDictionary dict = new NSDictionary();
  dict.put("Key1", "Value1");
  dict.put("Key2", "Value2");
  projectFilesystem.writeContentsToPath(dict.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(dict.toXMLPropertyList())));
}
 
Example #16
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 #17
Source File: EscrowedKeys.java    From InflatableDonkey with MIT License 5 votes vote down vote up
static byte[] escrowedKeys(NSDictionary record, ServiceKeySet backupBagPassword) {
    String metadataBase64 = PListsLegacy.getAs(record, "metadata", NSString.class).getContent();
    byte[] metadata = Base64.getDecoder().decode(metadataBase64);

    byte[] data = ProtectedRecord.unlockData(metadata, backupBagPassword::key);
    logger.debug("-- escrowedKeys() - decrypted metadata: {}", Hex.toHexString(data));
    return data;
}
 
Example #18
Source File: PBXProject.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private NSDictionary getPhaseByName(String name) throws PBXProjectException{
	NSDictionary objects = getObjects();
	HashMap<String, NSObject> map = objects.getHashMap();
	Collection<NSObject> values = map.values();
	for (NSObject nsObject : values) {
		NSDictionary obj = (NSDictionary)nsObject;
		NSString isa = (NSString) obj.objectForKey("isa");
		if(isa != null && isa.getContent().equals(name)){
			return obj;
		}
	}
	return null;
}
 
Example #19
Source File: PBXProject.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private NSDictionary getGroupByName(String name) throws PBXProjectException{
	NSDictionary objects = getObjects();
	HashMap<String, NSObject> map = objects.getHashMap();
	Collection<NSObject> values = map.values();
	for (NSObject nsObject : values) {
		NSDictionary obj = (NSDictionary)nsObject;
		NSString isa = (NSString) obj.objectForKey("isa");
		NSString nameString = (NSString) obj.objectForKey("name");
		if(isa != null && isa.getContent().equals("PBXGroup") && nameString != null && name.equals(nameString.getContent())){
			return obj;
		}
	}
	return null;
}
 
Example #20
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 #21
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 #22
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 #23
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 #24
Source File: PlistProcessStepTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testOverrideReplacesExistingKey() 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);

  NSDictionary dict = new NSDictionary();
  dict.put("Key1", "Value1");
  dict.put("Key2", "Value2");
  projectFilesystem.writeContentsToPath(dict.toXMLPropertyList(), INPUT_PATH);

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

  dict.put("Key1", "OverrideValue");
  assertThat(
      projectFilesystem.readFileIfItExists(OUTPUT_PATH),
      equalTo(Optional.of(dict.toXMLPropertyList())));
}
 
Example #25
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 #26
Source File: IOSDebugTransport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Get string contained in NSObject hierarchy.
 *
 * @param obj Root object.
 * @param path Path to string value.
 *
 * @return String value, or null if not fount or if data type is not string.
 */
static String stringInNSObject(NSObject obj, String... path) {
    NSObject res = findInNSObject(obj, path);
    if (res instanceof NSString) {
        return ((NSString) res).toString();
    } else {
        return null;
    }
}
 
Example #27
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 #28
Source File: PBXBuildPhasesTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testCopyFilesBuildPhaseWithNameAndDepoymentPostprocessing() {
  String copyPhaseName = "Test Phase Name";
  PBXCopyFilesBuildPhase copyPhase = makeCopyFilesPhase();
  copyPhase.setRunOnlyForDeploymentPostprocessing(Optional.of(Boolean.TRUE));
  copyPhase.setName(Optional.of(copyPhaseName));
  target.getBuildPhases().add(copyPhase);

  NSDictionary projPlist = serializer.toPlist();
  NSDictionary copyPhaseDict = getObjectForGID(copyPhase.getGlobalID(), projPlist);

  assertEquals(new NSString(copyPhaseName), copyPhaseDict.get("name"));
  assertEquals(new NSString("1"), copyPhaseDict.get("runOnlyForDeploymentPostprocessing"));
}
 
Example #29
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 #30
Source File: IOSDebugTransport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String nsObjectToString(NSObject o, int lvl) {
    String basicIndent = "    ";                                    //NOI18N
    String levelIndent = "";                                        //NOI18N
    for (int i = 0; i < lvl; i++) {
        levelIndent += basicIndent;
    }
    if (o instanceof NSDictionary) {
        String[] allKeys = ((NSDictionary) o).allKeys();
        StringBuilder sb = new StringBuilder(lvl == 0 ? "\n" : ""); //NOI18N
        sb.append("{\n");                                           //NOI18N
        for (String key: allKeys) {
            NSObject objectForKey = ((NSDictionary) o).objectForKey(key);
            sb.append(levelIndent);
            sb.append(basicIndent);
            sb.append("\"");                                        //NOI18N
            sb.append(key);
            sb.append("\": ");                                      //NOI18N
            sb.append(nsObjectToString(objectForKey, lvl + 1));
            sb.append("\n");                                        //NOI18N
        }
        sb.append(levelIndent);
        sb.append("}\n");                                           //NOI18N
        return sb.toString();
    } else if (o instanceof NSString) {
        return "\"" + ((NSString) o).toString() + "\"";             //NOI18N
    } else if (o instanceof NSData) {
        NSData data = (NSData) o;
        String asStr = new String(data.bytes(), Charset.forName("UTF-8"));
        return "Data: " + asStr;
    } else if (o != null) {
        return o.toString();
    } else {
        return "null";                                              //NOI18N
    }
}