-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovisioning_profile_example.dart
More file actions
84 lines (71 loc) · 2.71 KB
/
Copy pathprovisioning_profile_example.dart
File metadata and controls
84 lines (71 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// ignore_for_file: unused_local_variable, avoid_print
import 'dart:io';
import 'package:phntmxyz_ios_publishing_sidekick_plugin/phntmxyz_ios_publishing_sidekick_plugin.dart';
/// Examples of installing and inspecting provisioning profiles.
void main() {
// Example 1: Reading Provisioning Profile Information
readingProvisioningProfileInformation();
// Example 2: Installing Provisioning Profiles
installingProvisioningProfiles();
// Example 3: Validating Profile Expiration
validateProfileExpiration(
File('profile.mobileprovision').asProvisioningProfile(),
);
}
/// Load provisioning profile and access information.
void readingProvisioningProfileInformation() {
// Load provisioning profile
final profile =
File('profiles/AppStore.mobileprovision').asProvisioningProfile();
// Access profile information
print('Profile Name: ${profile.name}');
print('UUID: ${profile.uuid}');
print('Team ID: ${profile.teamIdentifier}');
print('Team Name: ${profile.teamName}');
print('App ID Name: ${profile.appIdName}');
print('Platforms: ${profile.platform}');
print('Created: ${profile.creationDate}');
print('Expires: ${profile.expirationDate}');
print('Days Valid: ${profile.timeToLive}');
print('Version: ${profile.version}');
print('Xcode Managed: ${profile.isXcodeManaged}');
// Check provisioned devices (for Ad Hoc/Development profiles)
if (profile.provisionedDevices.isNotEmpty) {
print('Devices:');
for (final device in profile.provisionedDevices) {
print(' - $device');
}
}
}
/// Install provisioning profiles.
void installingProvisioningProfiles() {
// Install a provisioning profile
final profile =
File('profiles/AppStore.mobileprovision').asProvisioningProfile();
installProvisioningProfile(profile);
print('Installed profile: ${profile.name}');
// Install multiple profiles
final profiles = [
'profiles/AppStore.mobileprovision',
'profiles/ShareExtension.mobileprovision',
'profiles/NotificationService.mobileprovision',
];
for (final profilePath in profiles) {
final profile = File(profilePath).asProvisioningProfile();
installProvisioningProfile(profile);
print('✓ Installed: ${profile.name}');
}
}
/// Check if profile is still valid.
void validateProfileExpiration(ProvisioningProfile profile) {
final now = DateTime.now();
final daysUntilExpiration = profile.expirationDate.difference(now).inDays;
if (daysUntilExpiration < 0) {
throw Exception(
'Profile "${profile.name}" expired on ${profile.expirationDate}');
} else if (daysUntilExpiration < 7) {
print('⚠️ Warning: Profile expires in $daysUntilExpiration days');
} else {
print('✓ Profile valid for $daysUntilExpiration days');
}
}