Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
[FIX] Updated the iOS Apple Connect tasks to be aware of the path set…
Browse files Browse the repository at this point in the history
… by xcode-select so that multiple installed versions of xcode is supported.
  • Loading branch information
Bradley Clayton committed Jan 30, 2019
1 parent ccfb14d commit a91c667
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
import com.squarepolka.readyci.tasks.Task;
import org.springframework.stereotype.Component;

import java.io.InputStream;

@Component
public class IOSUploadAppleConnect extends Task {

public static final String TASK_UPLOAD_ITUNES_CONNECT = "ios_upload_itunes_connect";
private static final String COMMAND_XCODE_SELECT = "xcode-select";
private static final String PARAM_XCODE_SELECT_PATH = "--print-path";
private static final String PATH_XCODE_DEFAULT = "/Applications/Xcode.app/Contents";

@Override
public String taskIdentifier() {
Expand All @@ -21,11 +26,23 @@ public void performTask(BuildEnvironment buildEnvironment) throws Exception {
String exportPath = String.format("%s/%s.ipa", buildEnvironment.scratchPath, scheme);
String iTunesUsername = buildEnvironment.getProperty("iTunesUsername");
String iTunesPassword = buildEnvironment.getProperty("iTunesPassword");
String xCodePath = getXCodeSelectPath(buildEnvironment);
String altoolPath = xCodePath + "/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool";

executeCommand(new String[] {"/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool",
executeCommand(new String[] {altoolPath,
"--upload-app",
"-f", exportPath,
"-u", iTunesUsername,
"-p", iTunesPassword});
}

protected String getXCodeSelectPath(BuildEnvironment buildEnvironment) {
InputStream inputStream = executeCommand(new String[]{COMMAND_XCODE_SELECT, PARAM_XCODE_SELECT_PATH});
java.util.Scanner scanner = new java.util.Scanner(inputStream).useDelimiter("\\A");
String xCodeSelectPath = scanner.hasNext() ? scanner.next() : PATH_XCODE_DEFAULT;
xCodeSelectPath = xCodeSelectPath.replace("\n", "");
xCodeSelectPath = xCodeSelectPath.replace("\r", "");
xCodeSelectPath = xCodeSelectPath.replace("/Developer", "");
return xCodeSelectPath;
}
}

0 comments on commit a91c667

Please sign in to comment.