com.dd.plist.NSDictionary Java Examples

The following examples show how to use com.dd.plist.NSDictionary. 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: 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 #2
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 #3
Source File: IOSDebugTransport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JSONObject extractResponse(NSObject r) throws Exception {
    if (r == null) {
        return null;
    }
    if (!(r instanceof NSDictionary)) {
        return null;
    }
    NSDictionary root = (NSDictionary) r;
    NSDictionary argument = (NSDictionary) root.objectForKey("__argument"); // NOI18N
    if (argument == null) {
        return null;
    }
    NSData data = (NSData) argument.objectForKey("WIRMessageDataKey"); // NOI18N
    if (data == null) {
        return null;
    }
    byte[] bytes = data.bytes();
    String s = new String(bytes);
    JSONObject o = (JSONObject) JSONValue.parseWithException(s);
    return o;
}
 
Example #4
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 #5
Source File: PBXProject.java    From buck with Apache License 2.0 6 votes vote down vote up
@Override
public void serializeInto(XcodeprojSerializer s) {
  super.serializeInto(s);

  s.addField("mainGroup", mainGroup);

  targets.sort(Ordering.natural().onResultOf(PBXTarget::getName));
  s.addField("targets", targets);
  s.addField("buildConfigurationList", buildConfigurationList);
  s.addField("compatibilityVersion", compatibilityVersion);

  NSDictionary d = new NSDictionary();
  d.put("LastUpgradeCheck", "9999");

  s.addField("attributes", d);
}
 
Example #6
Source File: IOSDebugTransport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static NSObject findInNSObject(int pos, NSObject obj, String... path) {
    if (obj == null) {
        throw new NullPointerException("obj is null");
    } else if (path == null) {
        throw new NullPointerException("path is null");
    } else if (path.length == pos) {
        return obj;
    } else if (obj instanceof NSDictionary) {
        NSDictionary dict = (NSDictionary) obj;
        NSObject next = dict.objectForKey(path[pos]);
        if (next == null) {
            return null;
        } else {
            return findInNSObject(pos + 1, next, path);
        }
    } else {
        return null;
    }
}
 
Example #7
Source File: AirPlayAuth.java    From AirPlayAuth with MIT License 6 votes vote down vote up
private PairSetupPin1Response doPairSetupPin1(Socket socket) throws Exception {
    byte[] pairSetupPinRequestData = AuthUtils.createPList(new HashMap<String, String>() {{
        put("method", "pin");
        put("user", clientId);
    }});

    byte[] pairSetupPin1ResponseBytes = AuthUtils.postData(socket, "/pair-setup-pin", "application/x-apple-binary-plist", pairSetupPinRequestData);

    NSDictionary pairSetupPin1Response = (NSDictionary) PropertyListParser.parse(pairSetupPin1ResponseBytes);
    if (pairSetupPin1Response.containsKey("pk") && pairSetupPin1Response.containsKey("salt")) {
        byte[] pk = ((NSData) pairSetupPin1Response.get("pk")).bytes();
        byte[] salt = ((NSData) pairSetupPin1Response.get("salt")).bytes();
        return new PairSetupPin1Response(pk, salt);
    }
    throw new Exception();
}
 
Example #8
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 #9
Source File: EscrowOperationsRecover.java    From InflatableDonkey with MIT License 6 votes vote down vote up
static NSDictionary
        srpInit(HttpClient httpClient, EscrowProxyRequestFactory requests, SRPClient srpClient) throws IOException {
    /* 
     SRP-6a SRP_INIT
    
     Randomly generated ephemeral key A presented to escrow server along with id (mmeAuthToken header).
     Server returns amongst other things a salt and an ephemeral key B.
     */
    byte[] ephemeralKeyA = srpClient.generateClientCredentials();

    HttpUriRequest srpInitRequest = requests.srpInit(ephemeralKeyA);
    NSDictionary dictionary = httpClient.execute(srpInitRequest, RESPONSE_HANDLER);
    logger.debug("-- srpInit() - SRP_INIT: {}", dictionary.toXMLPropertyList());

    return dictionary;
}
 
Example #10
Source File: EscrowOperationsRecover.java    From InflatableDonkey with MIT License 6 votes vote down vote up
static NSDictionary
        recover(HttpClient httpClient, EscrowProxyRequestFactory requests, byte[] uid, byte[] tag, byte[] m1)
        throws IOException {
    logger.debug("-- recover() - uid: 0x{} tag: 0x{} m1: 0x{}",
            Hex.toHexString(uid), Hex.toHexString(tag), Hex.toHexString(m1));
    /* 
     SRP-6a RECOVER
    
     Failures will deplete attempts (we have 10 attempts max).
     Server will abort on an invalid M1 or present us with, amongst other things, M2 which we can verify (or not).
     */
    HttpUriRequest recoverRequest = requests.recover(m1, uid, tag);
    NSDictionary response = httpClient.execute(recoverRequest, RESPONSE_HANDLER);
    logger.debug("-- recover() - response: {}", response.toXMLPropertyList());

    return response;
}
 
Example #11
Source File: OXPParser.java    From Alite with GNU General Public License v3.0 6 votes vote down vote up
private void parseOXZ(String fileName) throws IOException {
	ZipResourceFile zip = new ZipResourceFile(fileName);
	InputStream manifestStream = zip.getInputStream("manifest.plist");
	if (manifestStream == null) {
		throw new FileNotFoundException("Cannot read manifest file of " + fileName + ".");
	}
	NSDictionary manifest = PListParser.parseFile(manifestStream);
	if (manifest.isEmpty()) {
		throw new FileNotFoundException("Cannot parse manifest file of " + fileName + ".");
	}
	identifier  = readRequiredString(manifest, "identifier", fileName);
	name        = readRequiredString(manifest, "title", fileName);
	version     = readRequiredString(manifest, "version", fileName);
	category    = readString(manifest, "category");
	description = readString(manifest, "description");
	author      = readString(manifest, "author");
	license     = readString(manifest, "license");
}
 
Example #12
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 #13
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 #14
Source File: EscrowOperationsRecover.java    From InflatableDonkey with MIT License 5 votes vote down vote up
static void validateSrpInitResponse(NSDictionary srpInitResponseBlob) {
    Integer version = PListsLegacy.optionalAs(srpInitResponseBlob, "version", NSNumber.class)
            .map(NSNumber::intValue)
            .orElse(null);
    if (!version.equals(1)) {
        throw new UnsupportedOperationException("unknown SRP_INIT version: " + version);
    }
}
 
Example #15
Source File: InflatableData.java    From InflatableDonkey with MIT License 5 votes vote down vote up
public byte[] encoded() {
    try {
        NSDictionary dict = new NSDictionary();
        dict.put("escrowedKeys", new NSData(escrowedKeys));
        dict.put("deviceUuid", new NSString(deviceUuid.toString()));
        dict.put("deviceHardWareId", new NSString(deviceHardWareId));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PropertyListParser.saveAsBinary(dict, baos);
        return baos.toByteArray();
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
 
Example #16
Source File: EscrowOperationsRecover.java    From InflatableDonkey with MIT License 5 votes vote down vote up
static NSDictionary decrypt(SRPClient srpClient, NSDictionary recoverResponse) {
    String respBlob = PListsLegacy.getAs(recoverResponse, "respBlob", NSString.class).getContent();
    BlobA6 blob = blobA6(respBlob);

    byte[] key = sessionKey(srpClient, blob);

    return decrypt(blob, key);
}
 
Example #17
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 #18
Source File: PListsLegacy.java    From InflatableDonkey with MIT License 5 votes vote down vote up
@Deprecated
public static <T extends NSObject> T fetchOrDefault(NSDictionary dictionary, String key, T defaultValue)
        throws BadDataException {

    return dictionary.containsKey(key)
            ? cast(key, dictionary)
            : defaultValue;
}
 
Example #19
Source File: Accounts.java    From InflatableDonkey with MIT License 5 votes vote down vote up
public static Account account(NSDictionary settings) {
    logger.debug("-- account() - settings: {}", settings.toASCIIPropertyList());

    NSDictionary accountInfoDict = PListsLegacy.getAs(settings, "appleAccountInfo", NSDictionary.class);
    NSDictionary tokensDict = PListsLegacy.getAs(settings, "tokens", NSDictionary.class);
    NSDictionary mobileMeDict = PListsLegacy.getAs(settings, "com.apple.mobileme", NSDictionary.class);

    AccountInfo accountInfo = new AccountInfo(accountInfoDict);
    Tokens tokens = new Tokens(tokensDict);
    MobileMe mobileMe = new MobileMe(mobileMeDict);

    return new Account(mobileMe, accountInfo, tokens);
}
 
Example #20
Source File: EscrowOperationsRecords.java    From InflatableDonkey with MIT License 5 votes vote down vote up
public static NSDictionary records(HttpClient httpClient, EscrowProxyRequestFactory requests) throws IOException {
    /* 
    EscrowService SRP-6a exchanges: GETRECORDS
     */
    HttpUriRequest recordsRequest = requests.getRecords();
    NSDictionary dictionary = httpClient.execute(recordsRequest, RESPONSE_HANDLER);
    logger.debug("-- records() - GETRECORDS: {}", dictionary.toXMLPropertyList());
    return dictionary;
}
 
Example #21
Source File: Accounts.java    From InflatableDonkey with MIT License 5 votes vote down vote up
public static Account account(HttpClient httpClient, Auth auth) throws IOException {
    HttpUriRequest accountSettingsRequest = AccountSettingsRequestFactory.instance()
            .apply(auth.dsPrsID(), auth.mmeAuthToken());

    NSDictionary settings
            = httpClient.execute(accountSettingsRequest, PropertyListResponseHandler.dictionary());

    return account(settings);
}
 
Example #22
Source File: PBXBuildPhasesTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testCopyFilesBuildPhaseWithoutOptionalFields() {
  PBXCopyFilesBuildPhase copyPhase = makeCopyFilesPhase();
  target.getBuildPhases().add(copyPhase);

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

  assertNull(copyPhaseDict.get("name"));
  assertNull(copyPhaseDict.get("runOnlyForDeploymentPostprocessing"));
}
 
Example #23
Source File: PBXBuildPhasesTest.java    From buck with Apache License 2.0 5 votes vote down vote up
private NSDictionary getObjectForGID(String gid, NSDictionary projPlist) {
  assertNotNull(projPlist);

  NSDictionary objects = (NSDictionary) projPlist.get("objects");
  assertNotNull(objects);

  NSDictionary object = (NSDictionary) objects.get(gid);
  assertNotNull(object);

  return object;
}
 
Example #24
Source File: AppleBundleIntegrationTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void infoPlistSubstitutionsAreApplied() throws Exception {
  ProjectWorkspace workspace =
      TestDataHelper.createProjectWorkspaceForScenario(
          this, "application_bundle_with_substitutions", tmp);
  workspace.setUp();

  BuildTarget target = workspace.newBuildTarget("//:DemoApp#iphonesimulator-x86_64,no-debug");
  workspace.runBuckCommand("build", target.getFullyQualifiedName()).assertSuccess();

  workspace.verify(
      Paths.get("DemoApp_output.expected"),
      BuildTargetPaths.getGenPath(
          filesystem,
          target.withAppendedFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR),
          "%s"));

  Path appPath =
      BuildTargetPaths.getGenPath(
              filesystem,
              target.withAppendedFlavors(AppleDescriptions.NO_INCLUDE_FRAMEWORKS_FLAVOR),
              "%s")
          .resolve(target.getShortName() + ".app");
  assertTrue(Files.exists(workspace.getPath(appPath.resolve(target.getShortName()))));

  NSDictionary plist =
      (NSDictionary)
          PropertyListParser.parse(
              Files.readAllBytes(workspace.getPath(appPath.resolve("Info.plist"))));
  assertThat(
      "Should contain xcode build version",
      (String) plist.get("DTXcodeBuild").toJavaObject(),
      not(emptyString()));
}
 
Example #25
Source File: PlistProcessStepTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testMergeFromFileReplacesExistingKey() throws Exception {
  FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();

  PlistProcessStep plistProcessStep =
      new PlistProcessStep(
          projectFilesystem,
          INPUT_PATH,
          Optional.of(MERGE_PATH),
          OUTPUT_PATH,
          ImmutableMap.of(),
          ImmutableMap.of(),
          PlistProcessStep.OutputFormat.XML);

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

  NSDictionary overrideDict = new NSDictionary();
  overrideDict.put("Key1", "OverrideValue");
  projectFilesystem.writeContentsToPath(overrideDict.toXMLPropertyList(), MERGE_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 #26
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 #27
Source File: ProvisioningProfileCopyStepTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testEntitlementsMergesValidProfileKeys() 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);

  ProvisioningProfileMetadata selectedProfile =
      step.getSelectedProvisioningProfileFuture().get().get();
  ImmutableMap<String, NSObject> profileEntitlements = selectedProfile.getEntitlements();
  assertTrue(profileEntitlements.containsKey("get-task-allow"));

  Optional<String> entitlementsContents = projectFilesystem.readFileIfItExists(entitlementsFile);
  assertTrue(entitlementsContents.isPresent());
  NSDictionary entitlementsPlist =
      (NSDictionary) PropertyListParser.parse(entitlementsContents.get().getBytes());
  assertFalse(entitlementsPlist.containsKey("get-task-allow"));

  Optional<String> xcentContents = projectFilesystem.readFileIfItExists(xcentFile);
  assertTrue(xcentContents.isPresent());
  NSDictionary xcentPlist =
      (NSDictionary) PropertyListParser.parse(xcentContents.get().getBytes());
  assertTrue(xcentPlist.containsKey("get-task-allow"));
}
 
Example #28
Source File: EntryHelper.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
public static Entry parse(File file) {
    LogUtil.log("EntryUtil", "parse(File)");

    try {

        NSDictionary rootDict = (NSDictionary) PropertyListParser.parse(file);
        LogUtil.log("EntryUtil", "NSDictionary: " + rootDict.toXMLPropertyList());
        return fromDictionary(rootDict);

    } catch (Exception e) {
        LogUtil.e("EntryUtil", "Exception in parse: ", e);
        return null;
    }
}
 
Example #29
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 #30
Source File: ProvisioningProfileCopyStepTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoEntitlementsDoesNotMergeInvalidProfileKeys() 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.empty(),
          ProvisioningProfileStoreFactory.fromSearchPath(
              new DefaultProcessExecutor(new TestConsole()), FAKE_READ_COMMAND, testdataDir),
          outputFile,
          xcentFile,
          codeSignIdentitiesSupplier,
          Optional.empty());
  step.execute(executionContext);

  ProvisioningProfileMetadata selectedProfile =
      step.getSelectedProvisioningProfileFuture().get().get();
  ImmutableMap<String, NSObject> profileEntitlements = selectedProfile.getEntitlements();
  assertTrue(
      profileEntitlements.containsKey(
          "com.apple.developer.icloud-container-development-container-identifiers"));

  Optional<String> xcentContents = projectFilesystem.readFileIfItExists(xcentFile);
  assertTrue(xcentContents.isPresent());
  NSDictionary xcentPlist =
      (NSDictionary) PropertyListParser.parse(xcentContents.get().getBytes());
  assertFalse(
      xcentPlist.containsKey(
          "com.apple.developer.icloud-container-development-container-identifiers"));
  assertEquals(
      xcentPlist.get("com.apple.developer.team-identifier"),
      profileEntitlements.get("com.apple.developer.team-identifier"));
}