Search in sources :

Example 11 with NSArray

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

the class PlistProcessStepTest method testHandlesNonDictionaryPlists.

@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())));
}
Also used : ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) NSArray(com.dd.plist.NSArray) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Example 12 with NSArray

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

the class ProvisioningProfileStoreTest method testEntitlementKeysAreMatched.

@Test
public void testEntitlementKeysAreMatched() throws Exception {
    final NSString[] fakeKeychainAccessGroups = { new NSString("AAAAAAAAAA.*") };
    final 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("foo"), new NSString("bar")));
    ImmutableMap<String, NSObject> fakeProductionEntitlements = ImmutableMap.of("keychain-access-groups", fakeKeychainAccessGroupsArray, "aps-environment", new NSString("production"), "com.apple.security.application-groups", new NSArray(new NSString("foo"), new NSString("bar"), new NSString("baz")));
    ProvisioningProfileMetadata expected = makeTestMetadata("AAAAAAAAAA.com.facebook.test", new Date(Long.MAX_VALUE), "11111111-1111-1111-1111-111111111111", fakeProductionEntitlements);
    ProvisioningProfileStore profiles = ProvisioningProfileStore.fromProvisioningProfiles(ImmutableList.of(makeTestMetadata("AAAAAAAAAA.com.facebook.test", new Date(Long.MAX_VALUE), "00000000-0000-0000-0000-000000000000", fakeDevelopmentEntitlements), expected));
    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);
    assertThat(actual.get(), is(equalTo(expected)));
    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("xxx")))), ProvisioningProfileStore.MATCH_ANY_IDENTITY);
    assertFalse(actual.isPresent());
    // Test without keychain access groups.
    actual = profiles.getBestProvisioningProfile("com.facebook.test", ApplePlatform.IPHONEOS, Optional.of(ImmutableMap.of("aps-environment", new NSString("production"), "com.apple.security.application-groups", new NSArray(new NSString("foo"), new NSString("bar")))), ProvisioningProfileStore.MATCH_ANY_IDENTITY);
    assertThat(actual.get(), is(equalTo(expected)));
    actual = profiles.getBestProvisioningProfile("com.facebook.test", ApplePlatform.IPHONEOS, Optional.of(ImmutableMap.of("aps-environment", new NSString("production"), "com.apple.security.application-groups", new NSArray(new NSString("foo"), new NSString("xxx")))), ProvisioningProfileStore.MATCH_ANY_IDENTITY);
    assertFalse(actual.isPresent());
}
Also used : NSObject(com.dd.plist.NSObject) NSArray(com.dd.plist.NSArray) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString) Date(java.util.Date) Test(org.junit.Test)

Example 13 with NSArray

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

the class AbstractProvisioningProfileMetadata method prefixFromEntitlements.

/**
   * 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"));
        Preconditions.checkNotNull(keychainAccessGroups);
        String appID = keychainAccessGroups.objectAtIndex(0).toString();
        return Optional.of(splitAppID(appID).getFirst());
    } catch (RuntimeException e) {
        return Optional.empty();
    }
}
Also used : NSArray(com.dd.plist.NSArray) NSString(com.dd.plist.NSString)

Example 14 with NSArray

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

the class XcodeprojSerializer method addField.

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));
    }
    Preconditions.checkNotNull(currentObject).put(name, array);
}
Also used : NSArray(com.dd.plist.NSArray) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString)

Example 15 with NSArray

use of com.dd.plist.NSArray in project bazel by bazelbuild.

the class XcodeprojGeneration method frameworkSearchPaths.

/**
   * Returns the {@code FRAMEWORK_SEARCH_PATHS} array for a target's build config given the list of
   * {@code .framework} directory paths.
   */
private static NSArray frameworkSearchPaths(Iterable<String> frameworks) {
    ImmutableSet.Builder<NSString> result = new ImmutableSet.Builder<>();
    for (String framework : frameworks) {
        result.add(new NSString("$(WORKSPACE_ROOT)/" + Paths.get(framework).getParent()));
    }
    // This is needed by XcTest targets (and others, just in case) for SenTestingKit.framework.
    result.add(new NSString("$(SDKROOT)/Developer/Library/Frameworks"));
    // This is needed by non-XcTest targets that use XcTest.framework, for instance for test
    // utility libraries packaged as an objc_library.
    result.add(new NSString("$(PLATFORM_DIR)/Developer/Library/Frameworks"));
    return (NSArray) NSObject.wrap(result.build().asList());
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) NSArray(com.dd.plist.NSArray) BuildPhaseBuilder(com.google.devtools.build.xcode.xcodegen.LibraryObjects.BuildPhaseBuilder) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString)

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