Skip to content

Commit

Permalink
Add new path for provisioning profiles starting Xcode 16
Browse files Browse the repository at this point in the history
  • Loading branch information
jperedadnr committed Oct 18, 2024
1 parent 6ee1f25 commit 224fb9c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
15 changes: 12 additions & 3 deletions src/main/java/com/gluonhq/substrate/util/ios/CodeSigning.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private MobileProvision tryModifiedBundleId(Identity identity, String bundleId,
private List<MobileProvision> retrieveValidMobileProvisions() {
final LocalDate now = LocalDate.now();
if (mobileProvisions == null) {
mobileProvisions = retrieveAllMobileProvisions();
mobileProvisions = getProvisioningProfiles();
}
return mobileProvisions.stream()
.filter(provision -> {
Expand All @@ -216,8 +216,17 @@ private List<MobileProvision> retrieveValidMobileProvisions() {
.collect(Collectors.toList());
}

public static List<MobileProvision> retrieveAllMobileProvisions() {
Path provisionPath = Paths.get(System.getProperty("user.home"), "Library", "MobileDevice", "Provisioning Profiles");
public static List<MobileProvision> getProvisioningProfiles() {
// Starting Xcode 16+:
Path provisionPath = Paths.get(System.getProperty("user.home"), "Library", "Developer", "Xcode", "UserData", "Provisioning Profiles");
List<MobileProvision> provisions = new ArrayList<>(retrieveAllMobileProvisionsFromPath(provisionPath));
// Before Xcode 16:
provisionPath = Paths.get(System.getProperty("user.home"), "Library", "MobileDevice", "Provisioning Profiles");
provisions.addAll(retrieveAllMobileProvisionsFromPath(provisionPath));
return provisions;
}

private static List<MobileProvision> retrieveAllMobileProvisionsFromPath(Path provisionPath) {
if (!Files.exists(provisionPath) || !Files.isDirectory(provisionPath)) {
Logger.logSevere("Invalid provisioning profiles folder at " + provisionPath.toString());
return Collections.emptyList();
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/com/gluonhq/substrate/util/macos/CodeSigning.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021, Gluon
* Copyright (c) 2019, 2024, Gluon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -393,18 +393,27 @@ private ProvisionProfile findProvisionProfile(Identity identity, String bundleId
private List<ProvisionProfile> retrieveValidProvisionProfiles() {
final LocalDate now = LocalDate.now();
if (provisionProfiles == null) {
provisionProfiles = retrieveAllProvisionProfiles().stream()
provisionProfiles = getProvisioningProfiles();
}
return provisionProfiles.stream()
.filter(provision -> {
LocalDate expirationDate = provision.getExpirationDate();
return expirationDate != null && !expirationDate.isBefore(now);
})
.collect(Collectors.toList());
}
return provisionProfiles;
}

private static List<ProvisionProfile> retrieveAllProvisionProfiles() {
Path provisionPath = Paths.get(System.getProperty("user.home"), "Library", "MobileDevice", "Provisioning Profiles");
private static List<ProvisionProfile> getProvisioningProfiles() {
// Starting Xcode 16+:
Path provisionPath = Paths.get(System.getProperty("user.home"), "Library", "Developer", "Xcode", "UserData", "Provisioning Profiles");
List<ProvisionProfile> provisions = new ArrayList<>(retrieveAllProvisionProfilesFromPath(provisionPath));
// Before Xcode 16:
provisionPath = Paths.get(System.getProperty("user.home"), "Library", "MobileDevice", "Provisioning Profiles");
provisions.addAll(retrieveAllProvisionProfilesFromPath(provisionPath));
return provisions;
}

private static List<ProvisionProfile> retrieveAllProvisionProfilesFromPath(Path provisionPath) {
if (!Files.exists(provisionPath) || !Files.isDirectory(provisionPath)) {
Logger.logSevere("Invalid provisioning profiles folder at " + provisionPath.toString());
return Collections.emptyList();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/gluonhq/substrate/IOSTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021, Gluon
* Copyright (c) 2019, 2024, Gluon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -97,7 +97,7 @@ void testSigning() {
@Test
void testProvisioning() {
assumeTrue(!isCI());
List<MobileProvision> provisions = CodeSigning.retrieveAllMobileProvisions();
List<MobileProvision> provisions = CodeSigning.getProvisioningProfiles();
assertNotNull(provisions);
assertFalse(provisions.isEmpty());
}
Expand Down

0 comments on commit 224fb9c

Please sign in to comment.