Search in sources :

Example 16 with NSArray

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

the class ProvisioningProfileStoreTest method testPrefixOverride.

@Test
public void testPrefixOverride() throws Exception {
    ProvisioningProfileMetadata expected = makeTestMetadata("AAAAAAAAAA.*", new Date(Long.MAX_VALUE), "00000000-0000-0000-0000-000000000000");
    ProvisioningProfileStore profiles = ProvisioningProfileStore.fromProvisioningProfiles(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);
    assertThat(actual.get(), is(equalTo(expected)));
}
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 17 with NSArray

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

the class AppleBundle method getInfoPlistAdditionalKeys.

private ImmutableMap<String, NSObject> getInfoPlistAdditionalKeys() {
    ImmutableMap.Builder<String, NSObject> keys = ImmutableMap.builder();
    final String platformName = platform.getName();
    if (platformName.contains("osx")) {
        keys.put("NSHighResolutionCapable", new NSNumber(true));
        keys.put("NSSupportsAutomaticGraphicsSwitching", new NSNumber(true));
        keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("MacOSX")));
    } else if (platformName.contains("iphoneos")) {
        keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneOS")));
    } else if (platformName.contains("iphonesimulator")) {
        keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneSimulator")));
    } else if (platformName.contains("watchos") && !isLegacyWatchApp()) {
        keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("WatchOS")));
    } else if (platformName.contains("watchsimulator") && !isLegacyWatchApp()) {
        keys.put("CFBundleSupportedPlatforms", new NSArray(new NSString("WatchSimulator")));
    }
    keys.put("DTPlatformName", new NSString(platformName));
    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();
}
Also used : NSNumber(com.dd.plist.NSNumber) NSObject(com.dd.plist.NSObject) NSArray(com.dd.plist.NSArray) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 18 with NSArray

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

the class AbstractProvisioningProfileMetadata method fromProvisioningProfilePath.

public static ProvisioningProfileMetadata fromProvisioningProfilePath(ProcessExecutor executor, ImmutableList<String> readCommand, Path profilePath) throws IOException, InterruptedException {
    Set<ProcessExecutor.Option> options = EnumSet.of(ProcessExecutor.Option.EXPECTING_STD_OUT);
    // Extract the XML from its signed message wrapper.
    ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().addAllCommand(readCommand).addCommand(profilePath.toString()).build();
    ProcessExecutor.Result result;
    result = executor.launchAndExecute(processExecutorParams, options, /* stdin */
    Optional.empty(), /* timeOutMs */
    Optional.empty(), /* timeOutHandler */
    Optional.empty());
    if (result.getExitCode() != 0) {
        throw new IOException(result.getMessageForResult("Invalid provisioning profile: " + profilePath));
    }
    try {
        NSDictionary plist = (NSDictionary) PropertyListParser.parse(result.getStdout().get().getBytes());
        Date expirationDate = ((NSDate) plist.get("ExpirationDate")).getDate();
        String uuid = ((NSString) plist.get("UUID")).getContent();
        ImmutableSet.Builder<HashCode> certificateFingerprints = ImmutableSet.builder();
        NSArray certificates = (NSArray) plist.get("DeveloperCertificates");
        HashFunction hasher = Hashing.sha1();
        if (certificates != null) {
            for (NSObject item : certificates.getArray()) {
                certificateFingerprints.add(hasher.hashBytes(((NSData) item).bytes()));
            }
        }
        ImmutableMap.Builder<String, NSObject> builder = ImmutableMap.builder();
        NSDictionary entitlements = ((NSDictionary) plist.get("Entitlements"));
        for (String key : entitlements.keySet()) {
            builder = builder.put(key, entitlements.objectForKey(key));
        }
        String appID = entitlements.get("application-identifier").toString();
        ProvisioningProfileMetadata.Builder provisioningProfileMetadata = ProvisioningProfileMetadata.builder();
        if (plist.get("Platform") != null) {
            for (Object platform : (Object[]) plist.get("Platform").toJavaObject()) {
                provisioningProfileMetadata.addPlatforms((String) platform);
            }
        }
        return provisioningProfileMetadata.setAppID(ProvisioningProfileMetadata.splitAppID(appID)).setExpirationDate(expirationDate).setUUID(uuid).setProfilePath(profilePath).setEntitlements(builder.build()).setDeveloperCertificateFingerprints(certificateFingerprints.build()).build();
    } catch (Exception e) {
        throw new IllegalArgumentException("Malformed embedded plist: " + e);
    }
}
Also used : NSObject(com.dd.plist.NSObject) NSData(com.dd.plist.NSData) NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString) HashCode(com.google.common.hash.HashCode) ImmutableSet(com.google.common.collect.ImmutableSet) NSDate(com.dd.plist.NSDate) ProcessExecutorParams(com.facebook.buck.util.ProcessExecutorParams) IOException(java.io.IOException) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) Date(java.util.Date) NSDate(com.dd.plist.NSDate) ImmutableMap(com.google.common.collect.ImmutableMap) IOException(java.io.IOException) HashFunction(com.google.common.hash.HashFunction) NSObject(com.dd.plist.NSObject)

Example 19 with NSArray

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

the class AppleSimulatorProfileParsing method parseProfilePlistStream.

public static Optional<AppleSimulatorProfile> parseProfilePlistStream(InputStream inputStream) throws IOException {
    NSDictionary profile;
    try (BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) {
        try {
            profile = (NSDictionary) PropertyListParser.parse(bufferedInputStream);
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
    NSObject supportedProductFamilyIDsObject = profile.objectForKey("supportedProductFamilyIDs");
    if (!(supportedProductFamilyIDsObject instanceof NSArray)) {
        LOG.warn("Invalid simulator profile.plist (supportedProductFamilyIDs missing or not an array)");
        return Optional.empty();
    }
    NSArray supportedProductFamilyIDs = (NSArray) supportedProductFamilyIDsObject;
    AppleSimulatorProfile.Builder profileBuilder = AppleSimulatorProfile.builder();
    for (NSObject supportedProductFamilyID : supportedProductFamilyIDs.getArray()) {
        if (supportedProductFamilyID instanceof NSNumber) {
            profileBuilder.addSupportedProductFamilyIDs(((NSNumber) supportedProductFamilyID).intValue());
        } else {
            LOG.warn("Invalid simulator profile.plist (supportedProductFamilyIDs contains non-number %s)", supportedProductFamilyID);
            return Optional.empty();
        }
    }
    NSObject supportedArchsObject = profile.objectForKey("supportedArchs");
    if (!(supportedArchsObject instanceof NSArray)) {
        LOG.warn("Invalid simulator profile.plist (supportedArchs missing or not an array)");
        return Optional.empty();
    }
    NSArray supportedArchs = (NSArray) supportedArchsObject;
    for (NSObject supportedArch : supportedArchs.getArray()) {
        profileBuilder.addSupportedArchitectures(supportedArch.toString());
    }
    return Optional.of(profileBuilder.build());
}
Also used : NSNumber(com.dd.plist.NSNumber) NSObject(com.dd.plist.NSObject) BufferedInputStream(java.io.BufferedInputStream) NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) IOException(java.io.IOException) IOException(java.io.IOException)

Example 20 with NSArray

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

the class PBXShellScriptBuildPhase method serializeInto.

@Override
public void serializeInto(XcodeprojSerializer s) {
    super.serializeInto(s);
    NSArray inputPathsArray = new NSArray(inputPaths.size());
    for (int i = 0; i < inputPaths.size(); i++) {
        inputPathsArray.setValue(i, new NSString(inputPaths.get(i)));
    }
    s.addField("inputPaths", inputPathsArray);
    NSArray outputPathsArray = new NSArray(outputPaths.size());
    for (int i = 0; i < outputPaths.size(); i++) {
        outputPathsArray.setValue(i, new NSString(outputPaths.get(i)));
    }
    s.addField("outputPaths", outputPathsArray);
    NSString shellPathString;
    if (shellPath == null) {
        shellPathString = DEFAULT_SHELL_PATH;
    } else {
        shellPathString = new NSString(shellPath);
    }
    s.addField("shellPath", shellPathString);
    NSString shellScriptString;
    if (shellScript == null) {
        shellScriptString = DEFAULT_SHELL_SCRIPT;
    } else {
        shellScriptString = new NSString(shellScript);
    }
    s.addField("shellScript", shellScriptString);
}
Also used : NSArray(com.dd.plist.NSArray) 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