Revert "update"

This reverts commit 9bd79312a7.
This commit is contained in:
leedongmyung 2025-08-13 17:16:12 +09:00
parent 6bbdf90984
commit 297fb9128c

View file

@ -33,10 +33,7 @@ class BuildiOS extends Command {
await getMainXcodeprojPath(data.xcworkspaceFilePath!);
/************ Auto find build number ************/
var autoBuildNumber = (data.autoBuildNumber ?? false)
? !((version != null && version.isNotEmpty) ||
(buildNumber != null && buildNumber.isNotEmpty))
: false;
var autoBuildNumber = (data.autoBuildNumber ?? false) ? !((version != null && version.isNotEmpty) || (buildNumber != null && buildNumber.isNotEmpty)) : false;
if (autoBuildNumber) {
var appID = await getAppIdentifier(
data.workspace, xcodeproj, data.scheme, data.setAppID);
@ -44,7 +41,7 @@ class BuildiOS extends Command {
throw Exception('Can not find App Identifier.');
}
var teamID = data.teamID;
if (teamID == null) {
if(teamID == null) {
throw Exception('Can not find Apple Store Team ID');
}
if (data.apiKeyPath == null) {
@ -52,8 +49,7 @@ class BuildiOS extends Command {
'If autoVersionNumber = true then must set apiKeyPath.');
}
var apiKeyPath = data.apiKeyPath!;
var fastFile =
await initializeFastlane(data.workspace!, apiKeyPath, appID);
var fastFile = await initializeFastlane(data.workspace!, apiKeyPath, appID);
var fastlaneContent = fastFile.readAsStringSync();
//Find PREPARE_FOR_SUBMISSION state Version
@ -63,7 +59,7 @@ class BuildiOS extends Command {
shell.write(' && fastlane appstore_versions');
var process = await ProcessExecutor.run(shell);
var arr = process.stdout.toString().split('\n');
var result = '[RESULT]: ';
const result = '[RESULT]: ';
for (var item in arr) {
if (item.contains(result)) {
var jsonArr =
@ -91,15 +87,12 @@ class BuildiOS extends Command {
fastFile.writeAsStringSync(fastlaneContent, flush: true);
shell = StringBuffer();
shell.write('cd ${data.workspace}/fastlane');
shell.write(
' && fastlane run latest_testflight_build_number app_identifier:$appID version:$version platform:ios api_key_path:"$apiKeyPath" team_id:"$teamID"');
shell.write(' && fastlane run latest_testflight_build_number app_identifier:$appID version:$version platform:ios api_key_path:"$apiKeyPath" team_id:"$teamID"');
process = await ProcessExecutor.run(shell);
arr = process.stdout.toString().split('\n');
result = 'RESULT: ';
for (var item in arr) {
if (item.contains(result)) {
targetBuildNumber =
item.substring(item.indexOf(result) + result.length).trim();
targetBuildNumber = item.substring(item.indexOf(result) + result.length).trim();
break;
}
}
@ -118,8 +111,7 @@ class BuildiOS extends Command {
'${data.workspace}/$xcodeproj/project.pbxproj', version);
} else {
target = target ?? await getTargetXcodeproj(data.workspace!, xcodeproj!);
version = await getSettingXcodeproj(
data.workspace!, xcodeproj!, target!, 'MARKETING_VERSION');
version = await getSettingXcodeproj(data.workspace!, xcodeproj!, target!, 'MARKETING_VERSION');
}
//buildNumber가 ,
if (buildNumber != null && buildNumber.isNotEmpty) {
@ -127,18 +119,12 @@ class BuildiOS extends Command {
'${data.workspace}/$xcodeproj/project.pbxproj', buildNumber);
} else {
target = target ?? await getTargetXcodeproj(data.workspace!, xcodeproj!);
buildNumber = await getSettingXcodeproj(
data.workspace!, xcodeproj!, target!, 'CURRENT_PROJECT_VERSION');
buildNumber = await getSettingXcodeproj(data.workspace!, xcodeproj!, target!, 'CURRENT_PROJECT_VERSION');
}
var setVersion = data.setVersion != null && data.setVersion!.isNotEmpty
? data.setVersion!
: '<@property.version>';
var setVersion = data.setVersion != null && data.setVersion!.isNotEmpty ? data.setVersion! : '<@property.version>';
setProperty(setVersion, version);
var setBuildNumber =
data.setBuildNumber != null && data.setBuildNumber!.isNotEmpty
? data.setBuildNumber!
: '<@property.buildNumber>';
var setBuildNumber = data.setBuildNumber != null && data.setBuildNumber!.isNotEmpty ? data.setBuildNumber! : '<@property.buildNumber>';
setProperty(setBuildNumber, buildNumber);
var os = 'iOS';
@ -212,26 +198,25 @@ class BuildiOS extends Command {
}
}
static Future<File> initializeFastlane(
String workspace, String apiKeyPath, String appID) async {
static Future<File> initializeFastlane(String workspace, String apiKeyPath, String appID) async {
var json = jsonDecode(File(apiKeyPath).readAsStringSync());
var fastlaneContent = fastlaneTemplete;
fastlaneContent = fastlaneContent
.replaceFirst('[APP_IDENTIFIER]', appID)
.replaceFirst('[API_KEY_ID]', json['key_id'])
.replaceFirst('[API_ISSUER_ID]', json['issuer_id'])
.replaceFirst('[AUTH_KEY_CONTENT]',
json['key'].toString().replaceAll('\n', '\\n'));
var fastlaneContent = fastlaneTemplete;
fastlaneContent = fastlaneContent
.replaceFirst('[APP_IDENTIFIER]', appID)
.replaceFirst('[API_KEY_ID]', json['key_id'])
.replaceFirst('[API_ISSUER_ID]', json['issuer_id'])
.replaceFirst('[AUTH_KEY_CONTENT]',
json['key'].toString().replaceAll('\n', '\\n'));
var shell = StringBuffer();
shell.write('cd $workspace');
shell.write(' && rm -rf "$workspace/fastlane"');
shell.write(' && yes | fastlane init');
await ProcessExecutor.run(shell);
var shell = StringBuffer();
shell.write('cd $workspace');
shell.write(' && rm -rf "$workspace/fastlane"');
shell.write(' && yes | fastlane init');
await ProcessExecutor.run(shell);
var fastFile = File('$workspace/fastlane/Fastfile');
fastFile.writeAsStringSync(fastlaneContent, flush: true);
return dataFutrue(fastFile);
var fastFile = File('$workspace/fastlane/Fastfile');
fastFile.writeAsStringSync(fastlaneContent, flush: true);
return dataFutrue(fastFile);
}
Future<String?> getAppIdentifier(String? workspace, String? xcodeproj,
@ -344,18 +329,16 @@ class BuildiOS extends Command {
await file.writeAsString(updatedLines.join('\n'));
}
Future<String?> getSettingXcodeproj(
String workspace, String xcodeproj, String target, String marker) async {
Future<String?> getSettingXcodeproj(String workspace, String xcodeproj, String target, String marker) async {
String? version;
var shell = StringBuffer();
shell.write('cd $workspace');
shell.write(
' && xcodebuild -project $xcodeproj -target $target -showBuildSettings | grep $marker');
shell.write(' && xcodebuild -project $xcodeproj -target $target -showBuildSettings | grep $marker');
var mark = '$marker = ';
var process = await ProcessExecutor.run(shell);
var arr = process.stdout.toString().split('\n');
for (var item in arr) {
for(var item in arr) {
if (item.contains(mark)) {
version = item.replaceAll(mark, '').trim();
break;
@ -364,17 +347,15 @@ class BuildiOS extends Command {
return dataFutrue(version);
}
Future<String?> getTargetXcodeproj(
String workspace, String xcoodeproj) async {
Future<String?> getTargetXcodeproj(String workspace, String xcoodeproj) async {
String? target;
var shell = StringBuffer();
shell.write('cd $workspace');
shell.write(
" && xcodebuild -project $xcoodeproj -list | awk '/Targets:/ {getline; print; exit}'");
shell.write(" && xcodebuild -project $xcoodeproj -list | awk '/Targets:/ {getline; print; exit}'");
var process = await ProcessExecutor.run(shell);
var arr = process.stdout.toString().split('\n');
for (var item in arr) {
for(var item in arr) {
item = item.trim();
if (item.isNotEmpty) {
target = item.trim();