@@ -142,12 +142,12 @@ func filterLatestProfiles(profiles []profileutil.ProvisioningProfileInfoModel) [
142142 return filteredProfiles
143143}
144144
145- func collectIpaExportCodeSignGroups (archive xcarchive.IosArchive , installedCertificates []certificateutil.CertificateInfoModel , installedProfiles []profileutil.ProvisioningProfileInfoModel ) ([]export.IosCodeSignGroup , error ) {
145+ func collectIpaExportCodeSignGroups (tool Tool , archive xcarchive.IosArchive , installedCertificates []certificateutil.CertificateInfoModel , installedProfiles []profileutil.ProvisioningProfileInfoModel ) ([]export.IosCodeSignGroup , error ) {
146146 iosCodeSignGroups := []export.IosCodeSignGroup {}
147147
148148 codeSignGroups , err := collectIpaExportSelectableCodeSignGroups (archive , installedCertificates , installedProfiles )
149149 if err != nil {
150- return nil , printXcodeScanFinishedWithError ( "Failed to collect valid code sign settings: %s" , err )
150+ return nil , ArchiveError { tool , "failed to collect valid code sign settings: " + err . Error ()}
151151 }
152152
153153 if len (codeSignGroups ) == 0 {
@@ -157,7 +157,7 @@ func collectIpaExportCodeSignGroups(archive xcarchive.IosArchive, installedCerti
157157 log .Errorf ("- which has installed Codesign Identity in your Keychain" )
158158 log .Errorf ("- which can provision your application target's bundle ids" )
159159 log .Errorf ("- which has the project defined Capabilities set" )
160- return nil , printXcodeScanFinishedWithError ( "Failed to find code sign files")
160+ return nil , ArchiveError { tool , "failed to find code sign files"}
161161 }
162162
163163 exportMethods := []string {"development" , "app-store" , "ad-hoc" , "enterprise" }
@@ -166,7 +166,7 @@ func collectIpaExportCodeSignGroups(archive xcarchive.IosArchive, installedCerti
166166 fmt .Println ()
167167 selectedExportMethod , err := goinp .SelectFromStringsWithDefault ("Select the ipa export method" , 1 , exportMethods )
168168 if err != nil {
169- return nil , printXcodeScanFinishedWithError ( "Failed to select ipa export method: %s" , err )
169+ return nil , ArchiveError { tool , "failed to select ipa export method: " + err . Error ()}
170170 }
171171 log .Debugf ("selected export method: %v" , selectedExportMethod )
172172
@@ -226,7 +226,7 @@ func collectIpaExportCodeSignGroups(archive xcarchive.IosArchive, installedCerti
226226 question := fmt .Sprintf ("Select the Codesign Indentity for %s ipa export" , selectedExportMethod )
227227 selectedCertificateOption , err = goinp .SelectFromStringsWithDefault (question , 1 , certificateOptions )
228228 if err != nil {
229- return nil , printXcodeScanFinishedWithError ( "Failed to select Codesign Indentity: %s" , err )
229+ return nil , ArchiveError { tool , fmt . Sprintf ( "failed to select Codesign Indentity: %s" , err )}
230230 }
231231 }
232232
@@ -239,7 +239,7 @@ func collectIpaExportCodeSignGroups(archive xcarchive.IosArchive, installedCerti
239239 }
240240 }
241241 if selectedCertificate == nil {
242- return nil , printXcodeScanFinishedWithError ( "Failed to find selected Codesign Indentity")
242+ return nil , ArchiveError { tool , "failed to find selected Codesign Indentity"}
243243 }
244244
245245 // Select Profiles
@@ -252,7 +252,7 @@ func collectIpaExportCodeSignGroups(archive xcarchive.IosArchive, installedCerti
252252 }
253253 }
254254 if len (bundleIDProfilesMap ) == 0 {
255- return nil , printXcodeScanFinishedWithError ( "Failed to find Provisioning Profiles for Code Sign Identity")
255+ return nil , ArchiveError { tool , "failed to find Provisioning Profiles for Code Sign Identity"}
256256 }
257257
258258 selectedBundleIDProfileMap := map [string ]profileutil.ProvisioningProfileInfoModel {}
@@ -276,7 +276,7 @@ func collectIpaExportCodeSignGroups(archive xcarchive.IosArchive, installedCerti
276276 question := fmt .Sprintf ("Select the Provisioning Profile to sign target with bundle ID: %s" , bundleID )
277277 selectedProfileOption , err = goinp .SelectFromStringsWithDefault (question , 1 , profileOptions )
278278 if err != nil {
279- return nil , printXcodeScanFinishedWithError ( "Failed to select Provisioning Profile: %s" , err )
279+ return nil , ArchiveError { tool , fmt . Sprintf ( "failed to select Provisioning Profile: %s" , err )}
280280 }
281281 }
282282
@@ -288,7 +288,7 @@ func collectIpaExportCodeSignGroups(archive xcarchive.IosArchive, installedCerti
288288 }
289289 }
290290 if len (selectedBundleIDProfileMap ) != len (bundleIDProfilesMap ) {
291- return nil , printXcodeScanFinishedWithError ( "Failed to find Provisioning Profiles for ipa export" )
291+ return nil , ArchiveError { tool , fmt . Sprintf ( "failed to find Provisioning Profiles for ipa export" )}
292292 }
293293
294294 iosCodeSignGroup := export.IosCodeSignGroup {
@@ -320,7 +320,7 @@ func collectIpaExportCodeSignGroups(archive xcarchive.IosArchive, installedCerti
320320 return iosCodeSignGroups , nil
321321}
322322
323- func collectIpaExportCertificate (archiveCertificate certificateutil.CertificateInfoModel , installedCertificates []certificateutil.CertificateInfoModel ) (certificateutil.CertificateInfoModel , error ) {
323+ func collectIpaExportCertificate (tool Tool , archiveCertificate certificateutil.CertificateInfoModel , installedCertificates []certificateutil.CertificateInfoModel ) (certificateutil.CertificateInfoModel , error ) {
324324 fmt .Println ()
325325 fmt .Println ()
326326 question := fmt .Sprintf (`The Xcode archive used codesigning files of team: %s - %s
@@ -342,7 +342,7 @@ Would you like to use this team to sign your project?`, archiveCertificate.TeamI
342342 fmt .Println ()
343343 selectedTeam , err = goinp .SelectFromStringsWithDefault ("Select the Development team to sign your project" , 1 , teams )
344344 if err != nil {
345- return certificateutil.CertificateInfoModel {}, printXcodeScanFinishedWithError ( "Failed to select Codesign Indentity: %s" , err )
345+ return certificateutil.CertificateInfoModel {}, ArchiveError { tool , fmt . Sprintf ( "failed to select Codesign Indentity: %s" , err )}
346346 }
347347 } else {
348348 selectedTeam = fmt .Sprintf ("%s - %s" , archiveCertificate .TeamID , archiveCertificate .TeamName )
@@ -367,7 +367,7 @@ Would you like to use this team to sign your project?`, archiveCertificate.TeamI
367367Please select a development certificate:` , archiveCertificate .CommonName , archiveCertificate .Serial )
368368 selectedCertificateOption , err := goinp .SelectFromStringsWithDefault (question , 1 , certificateOptions )
369369 if err != nil {
370- return certificateutil.CertificateInfoModel {}, printXcodeScanFinishedWithError ( "Failed to select Codesign Indentity: %s" , err )
370+ return certificateutil.CertificateInfoModel {}, ArchiveError { tool , fmt . Sprintf ( "failed to select Codesign Indentity: %s" , err )}
371371 }
372372
373373 for _ , certInfo := range developmentCertificates {
@@ -393,7 +393,7 @@ Please select a development certificate:`, archiveCertificate.CommonName, archiv
393393Please select a distribution certificate:` , archiveCertificate .CommonName , archiveCertificate .Serial )
394394 selectedCertificateOption , err := goinp .SelectFromStringsWithDefault (question , 1 , certificateOptions )
395395 if err != nil {
396- return certificateutil.CertificateInfoModel {}, printXcodeScanFinishedWithError ( "Failed to select Codesign Indentity: %s" , err )
396+ return certificateutil.CertificateInfoModel {}, ArchiveError { tool , fmt . Sprintf ( "failed to select Codesign Indentity: %s" , err )}
397397 }
398398
399399 for _ , certInfo := range distributionCertificates {
@@ -538,11 +538,11 @@ func provProfileExportFileName(info profileutil.ProvisioningProfileInfoModel, pa
538538 return info .UUID + "." + safeTitle + extension
539539}
540540
541- func exportCodesignFiles (toolName , archivePath , outputDirPath string ) error {
541+ func exportCodesignFiles (tool Tool , archivePath , outputDirPath string ) error {
542542 // archive code sign settings
543543 installedCertificates , err := certificateutil .InstalledCodesigningCertificateInfos ()
544544 if err != nil {
545- return printFinishedWithError ( toolName , "Failed to list installed code signing identities, error: %s" , err )
545+ return ArchiveError { tool , fmt . Sprintf ( "failed to list installed code signing identities, error: %s" , err )}
546546 }
547547 installedCertificates = certificateutil .FilterValidCertificateInfos (installedCertificates )
548548
@@ -563,12 +563,12 @@ func exportCodesignFiles(toolName, archivePath, outputDirPath string) error {
563563
564564 archive , err := xcarchive .NewIosArchive (archivePath )
565565 if err != nil {
566- return printFinishedWithError ( toolName , "Failed to analyze archive, error: %s" , err )
566+ return ArchiveError { tool , fmt . Sprintf ( "failed to analyze archive, error: %s" , err )}
567567 }
568568
569569 archiveCodeSignGroup , err := analyzeArchive (archive , installedCertificates )
570570 if err != nil {
571- return printFinishedWithError ( toolName , "Failed to analyze the archive, error: %s" , err )
571+ return ArchiveError { tool , fmt . Sprintf ( "failed to analyze the archive, error: %s" , err )}
572572 }
573573
574574 fmt .Println ()
@@ -585,16 +585,16 @@ func exportCodesignFiles(toolName, archivePath, outputDirPath string) error {
585585 profilesToExport := []profileutil.ProvisioningProfileInfoModel {}
586586
587587 if certificatesOnly {
588- ipaExportCertificate , err := collectIpaExportCertificate (archiveCodeSignGroup .Certificate , installedCertificates )
588+ ipaExportCertificate , err := collectIpaExportCertificate (tool , archiveCodeSignGroup .Certificate , installedCertificates )
589589 if err != nil {
590590 return err
591591 }
592592
593593 certificatesToExport = append (certificatesToExport , archiveCodeSignGroup .Certificate , ipaExportCertificate )
594594 } else {
595- ipaExportCodeSignGroups , err := collectIpaExportCodeSignGroups (archive , installedCertificates , installedProfiles )
595+ ipaExportCodeSignGroups , err := collectIpaExportCodeSignGroups (tool , archive , installedCertificates , installedProfiles )
596596 if err != nil {
597- return printFinishedWithError ( toolName , "Failed to collect ipa export code sign groups, error: %s" , err )
597+ return ArchiveError { tool , fmt . Sprintf ( "failed to collect ipa export code sign groups, error: %s" , err )}
598598 }
599599
600600 codeSignGroups := append (ipaExportCodeSignGroups , archiveCodeSignGroup )
@@ -605,11 +605,11 @@ func exportCodesignFiles(toolName, archivePath, outputDirPath string) error {
605605 }
606606
607607 if err := collectAndExportIdentities (certificatesToExport , outputDirPath ); err != nil {
608- return printFinishedWithError ( toolName , "Failed to export codesign identities, error: %s" , err )
608+ return ArchiveError { tool , fmt . Sprintf ( "failed to export codesign identities, error: %s" , err )}
609609 }
610610
611611 if err := collectAndExportProvisioningProfiles (profilesToExport , outputDirPath ); err != nil {
612- return printFinishedWithError ( toolName , "Failed to export provisioning profiles, error: %s" , err )
612+ return ArchiveError { tool , fmt . Sprintf ( "failed to export provisioning profiles, error: %s" , err )}
613613 }
614614
615615 fmt .Println ()
0 commit comments