nextBuildNumber method
Returns the next unused build number for one app marketing version.
Implementation
@override
Future<String> nextBuildNumber({
required String appId,
required String version,
}) async {
final builds = await buildsForVersion(appId: appId, version: version);
var latestMajor = BigInt.zero;
for (final build in builds) {
final value = build.attributes.version;
final match = RegExp(
r'^([0-9]+)(?:\.[0-9]+){0,2}$',
).firstMatch(value);
if (match == null) {
throw SmfError(
'App Store Connect returned unsupported build number "$value".',
SmfErrorCode.appStoreConnectResponse,
);
}
final majorValue = match.group(1);
if (majorValue == null) {
throw SmfError(
'App Store Connect returned unsupported build number "$value".',
SmfErrorCode.appStoreConnectResponse,
);
}
final major = BigInt.parse(majorValue);
if (major > latestMajor) latestMajor = major;
}
return '${latestMajor + BigInt.one}';
}