From 0ed79a08d17d84130ecea5d41f4752478b442c11 Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Wed, 19 Jan 2022 11:33:18 +0000 Subject: [PATCH 01/12] patch for m1 --- cmd/xcode.go | 66 ++++++++++++++++++++++ cmd/xcodeUITests.go | 66 ++++++++++++++++++++++ utility/utility.go | 101 ++++++++++++++++++++++++++++++++++ xcode/xcodecmd.go | 15 +++++ xcodeuitest/xcodeuitestcmd.go | 16 ++++++ 5 files changed, 264 insertions(+) diff --git a/cmd/xcode.go b/cmd/xcode.go index ee7ed686..071d51c3 100644 --- a/cmd/xcode.go +++ b/cmd/xcode.go @@ -8,11 +8,15 @@ import ( "github.com/bitrise-io/codesigndoc/codesign" "github.com/bitrise-io/codesigndoc/codesigndoc" + "github.com/bitrise-io/codesigndoc/utility" "github.com/bitrise-io/codesigndoc/xcode" "github.com/bitrise-io/go-utils/colorstring" "github.com/bitrise-io/go-utils/fileutil" "github.com/bitrise-io/go-utils/log" "github.com/bitrise-io/go-utils/pathutil" + "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" + "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" + "github.com/bitrise-io/go-xcode/xcodeproject/xcworkspace" "github.com/bitrise-io/goinp/goinp" "github.com/spf13/cobra" ) @@ -32,6 +36,7 @@ var ( paramXcodeProjectFilePath string paramXcodeScheme string paramXcodebuildSDK string + paramXcodeDestination string ) func init() { @@ -40,6 +45,7 @@ func init() { xcodeCmd.Flags().StringVar(¶mXcodeProjectFilePath, "file", "", "Xcode Project/Workspace file path") xcodeCmd.Flags().StringVar(¶mXcodeScheme, "scheme", "", "Xcode Scheme") xcodeCmd.Flags().StringVar(¶mXcodebuildSDK, "xcodebuild-sdk", "", "xcodebuild -sdk param. If a value is specified for this flag it'll be passed to xcodebuild as the value of the -sdk flag. For more info about the values please see xcodebuild's -sdk flag docs. Example value: iphoneos") + xcodeCmd.Flags().StringVar(¶mXcodeDestination, "xcodebuild-destination", "", "The -destination option takes as its argument a destination specifier describing the device (or devices) to use as a destination. If a value is specified for this flag it'll be passed to xcodebuild.") } func absOutputDir() (string, error) { @@ -108,6 +114,66 @@ func scanXcodeProject(_ *cobra.Command, _ []string) error { xcodeCmd.SDK = paramXcodebuildSDK } + if paramXcodeDestination != "" { + xcodeCmd.DESTINATION = paramXcodeDestination + } else { + var project xcodeproj.XcodeProj + var scheme xcscheme.Scheme + + if xcodeproj.IsXcodeProj(xcodeCmd.ProjectFilePath) { + proj, err := xcodeproj.Open(xcodeCmd.ProjectFilePath) + if err != nil { + return fmt.Errorf("Failed to open project (%s), error: %s", xcodeCmd.ProjectFilePath, err) + } + + projectScheme, _, err := project.Scheme(xcodeCmd.Scheme) + if err != nil { + return fmt.Errorf("failed to find scheme (%s) in project (%s), error: %s", xcodeCmd.Scheme, project.Path, err) + } + + project = proj + scheme = *projectScheme + } else { + workspace, err := xcworkspace.Open(xcodeCmd.ProjectFilePath) + if err != nil { + return err + } + + projects, err := workspace.ProjectFileLocations() + if err != nil { + return err + } + + for _, projectLocation := range projects { + if exist, err := pathutil.IsPathExists(projectLocation); err != nil { + return fmt.Errorf("failed to check if project exist at: %s, error: %s", projectLocation, err) + } else if !exist { + // at this point we are interested the schemes visible for the workspace + continue + } + + possibleProject, _ := xcodeproj.Open(projectLocation) + projectScheme, _, _ := possibleProject.Scheme(xcodeCmd.Scheme) + + if projectScheme != nil { + project = possibleProject + scheme = *projectScheme + + break + } + } + } + + platform, err := utility.BuildableTargetPlatform(&project, &scheme, "", utility.XcodeBuild{}) + if err == nil { + destination := "generic/platform=" + string(platform) + + xcodeCmd.DESTINATION = destination + + fmt.Print("Setting -destination flag to: ", destination) + } + } + writeBuildLogs := func(xcodebuildOutput string) error { if writeFiles == codesign.WriteFilesAlways || writeFiles == codesign.WriteFilesFallback && err != nil { // save the xcodebuild output into a debug log file xcodebuildOutputFilePath := filepath.Join(absExportOutputDirPath, "xcodebuild-output.log") diff --git a/cmd/xcodeUITests.go b/cmd/xcodeUITests.go index 5576b28b..50d93b84 100644 --- a/cmd/xcodeUITests.go +++ b/cmd/xcodeUITests.go @@ -8,12 +8,17 @@ import ( "github.com/bitrise-io/codesigndoc/codesign" "github.com/bitrise-io/codesigndoc/codesigndocuitests" + codesigndocutility "github.com/bitrise-io/codesigndoc/utility" "github.com/bitrise-io/codesigndoc/xcodeuitest" "github.com/bitrise-io/go-utils/colorstring" "github.com/bitrise-io/go-utils/fileutil" "github.com/bitrise-io/go-utils/log" + "github.com/bitrise-io/go-utils/pathutil" "github.com/bitrise-io/go-utils/stringutil" "github.com/bitrise-io/go-xcode/utility" + "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" + "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" + "github.com/bitrise-io/go-xcode/xcodeproject/xcworkspace" "github.com/bitrise-io/goinp/goinp" "github.com/spf13/cobra" ) @@ -34,6 +39,7 @@ func init() { xcodeUITestsCmd.Flags().StringVar(¶mXcodeProjectFilePath, "file", "", "Xcode Project/Workspace file path") xcodeUITestsCmd.Flags().StringVar(¶mXcodeScheme, "scheme", "", "Xcode Scheme") xcodeUITestsCmd.Flags().StringVar(¶mXcodebuildSDK, "xcodebuild-sdk", "", "xcodebuild -sdk param. If a value is specified for this flag it'll be passed to xcodebuild as the value of the -sdk flag. For more info about the values please see xcodebuild's -sdk flag docs. Example value: iphoneos") + xcodeUITestsCmd.Flags().StringVar(¶mXcodeDestination, "xcodebuild-destination", "", "The -destination option takes as its argument a destination specifier describing the device (or devices) to use as a destination. If a value is specified for this flag it'll be passed to xcodebuild.") } func scanXcodeUITestsProject(cmd *cobra.Command, args []string) error { @@ -114,6 +120,66 @@ func scanXcodeUITestsProject(cmd *cobra.Command, args []string) error { xcodeUITestsCmd.SDK = paramXcodebuildSDK } + if paramXcodeDestination != "" { + xcodeUITestsCmd.DESTINATION = paramXcodeDestination + } else { + var project xcodeproj.XcodeProj + var scheme xcscheme.Scheme + + if xcodeproj.IsXcodeProj(xcodeUITestsCmd.ProjectFilePath) { + proj, err := xcodeproj.Open(xcodeUITestsCmd.ProjectFilePath) + if err != nil { + return fmt.Errorf("Failed to open project (%s), error: %s", xcodeUITestsCmd.ProjectFilePath, err) + } + + projectScheme, _, err := project.Scheme(xcodeUITestsCmd.Scheme) + if err != nil { + return fmt.Errorf("failed to find scheme (%s) in project (%s), error: %s", xcodeUITestsCmd.Scheme, project.Path, err) + } + + project = proj + scheme = *projectScheme + } else { + workspace, err := xcworkspace.Open(xcodeUITestsCmd.ProjectFilePath) + if err != nil { + return err + } + + projects, err := workspace.ProjectFileLocations() + if err != nil { + return err + } + + for _, projectLocation := range projects { + if exist, err := pathutil.IsPathExists(projectLocation); err != nil { + return fmt.Errorf("failed to check if project exist at: %s, error: %s", projectLocation, err) + } else if !exist { + // at this point we are interested the schemes visible for the workspace + continue + } + + possibleProject, _ := xcodeproj.Open(projectLocation) + projectScheme, _, _ := possibleProject.Scheme(xcodeUITestsCmd.Scheme) + + if projectScheme != nil { + project = possibleProject + scheme = *projectScheme + + break + } + } + } + + platform, err := codesigndocutility.BuildableTargetPlatform(&project, &scheme, "", codesigndocutility.XcodeBuild{}) + if err == nil { + destination := "generic/platform=" + string(platform) + + xcodeUITestsCmd.DESTINATION = destination + + fmt.Print("Setting -destination flag to: ", destination) + } + } + fmt.Println() fmt.Println() log.Printf("🔦 Running an Xcode build-for-testing, to get all the required code signing settings...") diff --git a/utility/utility.go b/utility/utility.go index 3055403c..43bebe1d 100644 --- a/utility/utility.go +++ b/utility/utility.go @@ -1,10 +1,16 @@ package utility import ( + "fmt" + "path/filepath" "regexp" + "strings" "github.com/bitrise-io/go-utils/log" "github.com/bitrise-io/go-xcode/profileutil" + "github.com/bitrise-io/go-xcode/xcodeproject/serialized" + "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" + "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" ) // ProfileExportFileNameNoPath creates a file name for the given profile with pattern: uuid.escaped_profile_name.[mobileprovision|provisionprofile] @@ -22,3 +28,98 @@ func ProfileExportFileNameNoPath(info profileutil.ProvisioningProfileInfoModel) return info.UUID + "." + safeTitle + extension } + +// Platform ... +type Platform string + +const ( + iOS Platform = "iOS" + osX Platform = "OS X" + tvOS Platform = "tvOS" + watchOS Platform = "watchOS" +) + +// TargetBuildSettingsProvider ... +type TargetBuildSettingsProvider interface { + TargetBuildSettings(xcodeProj *xcodeproj.XcodeProj, target, configuration string, customOptions ...string) (serialized.Object, error) +} + +// XcodeBuild ... +type XcodeBuild struct { +} + +// TargetBuildSettings ... +func (x XcodeBuild) TargetBuildSettings(xcodeProj *xcodeproj.XcodeProj, target, configuration string, customOptions ...string) (serialized.Object, error) { + return xcodeProj.TargetBuildSettings(target, configuration, customOptions...) +} + +// BuildableTargetPlatform ... +func BuildableTargetPlatform( + xcodeProj *xcodeproj.XcodeProj, + scheme *xcscheme.Scheme, + configurationName string, + provider TargetBuildSettingsProvider, +) (Platform, error) { + archiveEntry, ok := scheme.AppBuildActionEntry() + if !ok { + return "", fmt.Errorf("archivable entry not found in project: %s, scheme: %s", xcodeProj.Path, scheme.Name) + } + + mainTarget, ok := xcodeProj.Proj.Target(archiveEntry.BuildableReference.BlueprintIdentifier) + if !ok { + return "", fmt.Errorf("target not found: %s", archiveEntry.BuildableReference.BlueprintIdentifier) + } + + settings, err := provider.TargetBuildSettings(xcodeProj, mainTarget.Name, configurationName) + if err != nil { + return "", fmt.Errorf("failed to get target (%s) build settings: %s", mainTarget.Name, err) + } + + return getPlatform(settings) +} + +func getPlatform(buildSettings serialized.Object) (Platform, error) { + /* + Xcode help: + Base SDK (SDKROOT) + The name or path of the base SDK being used during the build. + The product will be built against the headers and libraries located inside the indicated SDK. + This path will be prepended to all search paths, and will be passed through the environment to the compiler and linker. + Additional SDKs can be specified in the Additional SDKs (ADDITIONAL_SDKS) setting. + + Examples: + - /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk + - /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator13.4.sdk + - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.4.sdk + - /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk + - /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk + - /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk + - /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk + - iphoneos + - macosx + - appletvos + - watchos + */ + sdk, err := buildSettings.String("SDKROOT") + if err != nil { + return "", fmt.Errorf("failed to get SDKROOT: %s", err) + } + + sdk = strings.ToLower(sdk) + if filepath.Ext(sdk) == ".sdk" { + sdk = filepath.Base(sdk) + } + + switch { + case strings.HasPrefix(sdk, "iphoneos"): + return iOS, nil + case strings.HasPrefix(sdk, "macosx"): + return osX, nil + case strings.HasPrefix(sdk, "appletvos"): + return tvOS, nil + case strings.HasPrefix(sdk, "watchos"): + return watchOS, nil + default: + return "", fmt.Errorf("unkown SDKROOT: %s", sdk) + } +} diff --git a/xcode/xcodecmd.go b/xcode/xcodecmd.go index dfccd299..e1975410 100644 --- a/xcode/xcodecmd.go +++ b/xcode/xcodecmd.go @@ -35,6 +35,17 @@ type CommandModel struct { // For more info about the possible values please see xcodebuild's docs about the -sdk flag. // Only passed to xcodebuild if not empty! SDK string + + // DESTINATION: configure which device or Simulator will be used by the tool + // The supported platforms are: + // OS X, your Mac + // iOS, a connected iOS device + // iOS Simulator + // watchOS + // watchOS Simulator + // tvOS + // tvOS Simulator + DESTINATION string } // GenerateArchive : generates the archive for subsequent "Scan" @@ -83,6 +94,10 @@ func (xccmd CommandModel) transformToXcodebuildParams(xcodebuildActionArgs ...st baseArgs = append(baseArgs, "-sdk", xccmd.SDK) } + if xccmd.DESTINATION != "" { + baseArgs = append(baseArgs, "-destination", xccmd.DESTINATION) + } + if xccmd.CodeSignIdentity != "" { baseArgs = append(baseArgs, `CODE_SIGN_IDENTITY=`+xccmd.CodeSignIdentity) } diff --git a/xcodeuitest/xcodeuitestcmd.go b/xcodeuitest/xcodeuitestcmd.go index c352219c..40c2dc61 100644 --- a/xcodeuitest/xcodeuitestcmd.go +++ b/xcodeuitest/xcodeuitestcmd.go @@ -34,6 +34,17 @@ type CommandModel struct { // For more info about the possible values please see xcodebuild's docs about the -sdk flag. // Only passed to xcodebuild if not empty! SDK string + + // DESTINATION: configure which device or Simulator will be used by the tool + // The supported platforms are: + // OS X, your Mac + // iOS, a connected iOS device + // iOS Simulator + // watchOS + // watchOS Simulator + // tvOS + // tvOS Simulator + DESTINATION string } // RunBuildForTesting runs the build-for-tesing xcode command @@ -82,12 +93,17 @@ func (xcuitestcmd CommandModel) transformToXcodebuildParams(xcodebuildActionArgs baseArgs = append(baseArgs, "-sdk", xcuitestcmd.SDK) } + if xcuitestcmd.DESTINATION != "" { + baseArgs = append(baseArgs, "-destination", xcuitestcmd.DESTINATION) + } + return append(baseArgs, xcodebuildActionArgs...), nil } // RunXcodebuildCommand TODO comment func (xcuitestcmd CommandModel) RunXcodebuildCommand(xcodebuildActionArgs ...string) (string, error) { xcodeCmdParamsToRun, err := xcuitestcmd.transformToXcodebuildParams(xcodebuildActionArgs...) + if err != nil { return "", err } From b0aa3c06de4f6ef619b496c27f15249a228cb127 Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Wed, 19 Jan 2022 11:33:30 +0000 Subject: [PATCH 02/12] use ccode --- .vscode/launch.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..ab2a10d2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "./", + "args": ["scan", "xcode", "--file", "~/apm-ios-test-hackerNews/HackerNews.xcworkspace", "--scheme", "HackerNews"], + } + ] +} \ No newline at end of file From 6a3710949f672291304783ad43ffa8278adb515e Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Wed, 19 Jan 2022 14:22:22 +0000 Subject: [PATCH 03/12] fixed project link for xcodeproj --- cmd/xcode.go | 5 +++-- cmd/xcodeUITests.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/xcode.go b/cmd/xcode.go index 071d51c3..a141763c 100644 --- a/cmd/xcode.go +++ b/cmd/xcode.go @@ -126,9 +126,10 @@ func scanXcodeProject(_ *cobra.Command, _ []string) error { return fmt.Errorf("Failed to open project (%s), error: %s", xcodeCmd.ProjectFilePath, err) } - projectScheme, _, err := project.Scheme(xcodeCmd.Scheme) + projectScheme, _, err := proj.Scheme(xcodeCmd.Scheme) + if err != nil { - return fmt.Errorf("failed to find scheme (%s) in project (%s), error: %s", xcodeCmd.Scheme, project.Path, err) + return fmt.Errorf("failed to find scheme (%s) in project (%s), error: %s", xcodeCmd.Scheme, proj.Path, err) } project = proj diff --git a/cmd/xcodeUITests.go b/cmd/xcodeUITests.go index 50d93b84..e4b43a6e 100644 --- a/cmd/xcodeUITests.go +++ b/cmd/xcodeUITests.go @@ -132,9 +132,9 @@ func scanXcodeUITestsProject(cmd *cobra.Command, args []string) error { return fmt.Errorf("Failed to open project (%s), error: %s", xcodeUITestsCmd.ProjectFilePath, err) } - projectScheme, _, err := project.Scheme(xcodeUITestsCmd.Scheme) + projectScheme, _, err := proj.Scheme(xcodeUITestsCmd.Scheme) if err != nil { - return fmt.Errorf("failed to find scheme (%s) in project (%s), error: %s", xcodeUITestsCmd.Scheme, project.Path, err) + return fmt.Errorf("failed to find scheme (%s) in project (%s), error: %s", xcodeUITestsCmd.Scheme, proj.Path, err) } project = proj From 511f4443ba86962479594e957729704f821e1beb Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Wed, 26 Jan 2022 18:13:23 +0000 Subject: [PATCH 04/12] added new tests for platform matching --- utility/utility_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 utility/utility_test.go diff --git a/utility/utility_test.go b/utility/utility_test.go new file mode 100644 index 00000000..faab2fe1 --- /dev/null +++ b/utility/utility_test.go @@ -0,0 +1,36 @@ +package utility + +import ( + "testing" + + "github.com/bitrise-io/go-xcode/xcodeproject/serialized" + "github.com/stretchr/testify/require" +) + +func TestPlatformsMatching_iOS(t *testing.T) { + buildSettings := serialized.Object{} + buildSettings["SDKROOT"] = "iphoneos" + + platform, err := getPlatform(buildSettings) + + require.Equal(t, "iOS", string(platform)) + require.Nil(t, err) +} + +func TestPlatformsMatching_macOS(t *testing.T) { + buildSettings := serialized.Object{} + buildSettings["SDKROOT"] = "macosx" + + platform, err := getPlatform(buildSettings) + + require.Equal(t, "OS X", string(platform)) + require.Nil(t, err) +} + +func TestPlatformsMatching_fails(t *testing.T) { + buildSettings := serialized.Object{} + platform, err := getPlatform(buildSettings) + + require.Empty(t, platform) + require.NotNil(t, err) +} From 39c9b14622f5135a3dff3997fed73b861bba7270 Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Wed, 26 Jan 2022 18:19:44 +0000 Subject: [PATCH 05/12] remove extra files --- .vscode/launch.json | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index ab2a10d2..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Launch", - "type": "go", - "request": "launch", - "mode": "debug", - "program": "./", - "args": ["scan", "xcode", "--file", "~/apm-ios-test-hackerNews/HackerNews.xcworkspace", "--scheme", "HackerNews"], - } - ] -} \ No newline at end of file From 03ae84941307e81a0d5d702e016bc3611b53b131 Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Wed, 26 Jan 2022 18:41:47 +0000 Subject: [PATCH 06/12] fixed lint --- cmd/xcode.go | 6 +++--- cmd/xcodeUITests.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/xcode.go b/cmd/xcode.go index a141763c..1ed8f7b5 100644 --- a/cmd/xcode.go +++ b/cmd/xcode.go @@ -153,10 +153,10 @@ func scanXcodeProject(_ *cobra.Command, _ []string) error { continue } - possibleProject, _ := xcodeproj.Open(projectLocation) - projectScheme, _, _ := possibleProject.Scheme(xcodeCmd.Scheme) + possibleProject, err := xcodeproj.Open(projectLocation) + projectScheme, _, err := possibleProject.Scheme(xcodeCmd.Scheme) - if projectScheme != nil { + if projectScheme != nil && err == nil { project = possibleProject scheme = *projectScheme diff --git a/cmd/xcodeUITests.go b/cmd/xcodeUITests.go index e4b43a6e..93f4ef14 100644 --- a/cmd/xcodeUITests.go +++ b/cmd/xcodeUITests.go @@ -158,10 +158,10 @@ func scanXcodeUITestsProject(cmd *cobra.Command, args []string) error { continue } - possibleProject, _ := xcodeproj.Open(projectLocation) - projectScheme, _, _ := possibleProject.Scheme(xcodeUITestsCmd.Scheme) + possibleProject, err := xcodeproj.Open(projectLocation) + projectScheme, _, err := possibleProject.Scheme(xcodeUITestsCmd.Scheme) - if projectScheme != nil { + if projectScheme != nil && err == nil { project = possibleProject scheme = *projectScheme From fcafd8a40dd4e5d9f3e5c84cc0c2e8559589d4ab Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Thu, 27 Jan 2022 16:06:48 +0000 Subject: [PATCH 07/12] Pr comments --- cmd/xcode.go | 44 ++++----------------- cmd/xcodeUITests.go | 44 ++++----------------- utility/utility.go | 72 +++++++++++++++++++++++++++++++++++ xcode/xcodecmd.go | 6 +-- xcodeuitest/xcodeuitestcmd.go | 8 ++-- 5 files changed, 95 insertions(+), 79 deletions(-) diff --git a/cmd/xcode.go b/cmd/xcode.go index 1ed8f7b5..218f56d9 100644 --- a/cmd/xcode.go +++ b/cmd/xcode.go @@ -16,7 +16,6 @@ import ( "github.com/bitrise-io/go-utils/pathutil" "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" - "github.com/bitrise-io/go-xcode/xcodeproject/xcworkspace" "github.com/bitrise-io/goinp/goinp" "github.com/spf13/cobra" ) @@ -115,61 +114,34 @@ func scanXcodeProject(_ *cobra.Command, _ []string) error { } if paramXcodeDestination != "" { - xcodeCmd.DESTINATION = paramXcodeDestination + xcodeCmd.Destination = paramXcodeDestination } else { var project xcodeproj.XcodeProj var scheme xcscheme.Scheme if xcodeproj.IsXcodeProj(xcodeCmd.ProjectFilePath) { - proj, err := xcodeproj.Open(xcodeCmd.ProjectFilePath) + proj, projectScheme, _, err := utility.OpenArchivableProject(xcodeCmd.ProjectFilePath, xcodeCmd.Scheme, "") if err != nil { - return fmt.Errorf("Failed to open project (%s), error: %s", xcodeCmd.ProjectFilePath, err) - } - - projectScheme, _, err := proj.Scheme(xcodeCmd.Scheme) - - if err != nil { - return fmt.Errorf("failed to find scheme (%s) in project (%s), error: %s", xcodeCmd.Scheme, proj.Path, err) + return err } - project = proj + project = *proj scheme = *projectScheme } else { - workspace, err := xcworkspace.Open(xcodeCmd.ProjectFilePath) - if err != nil { - return err - } - - projects, err := workspace.ProjectFileLocations() + proj, projectScheme, _, err := utility.OpenArchivableWorkspace(xcodeCmd.ProjectFilePath, xcodeCmd.Scheme, "") if err != nil { return err } - for _, projectLocation := range projects { - if exist, err := pathutil.IsPathExists(projectLocation); err != nil { - return fmt.Errorf("failed to check if project exist at: %s, error: %s", projectLocation, err) - } else if !exist { - // at this point we are interested the schemes visible for the workspace - continue - } - - possibleProject, err := xcodeproj.Open(projectLocation) - projectScheme, _, err := possibleProject.Scheme(xcodeCmd.Scheme) - - if projectScheme != nil && err == nil { - project = possibleProject - scheme = *projectScheme - - break - } - } + project = *proj + scheme = *projectScheme } platform, err := utility.BuildableTargetPlatform(&project, &scheme, "", utility.XcodeBuild{}) if err == nil { destination := "generic/platform=" + string(platform) - xcodeCmd.DESTINATION = destination + xcodeCmd.Destination = destination fmt.Print("Setting -destination flag to: ", destination) } diff --git a/cmd/xcodeUITests.go b/cmd/xcodeUITests.go index 93f4ef14..6742b61c 100644 --- a/cmd/xcodeUITests.go +++ b/cmd/xcodeUITests.go @@ -13,12 +13,10 @@ import ( "github.com/bitrise-io/go-utils/colorstring" "github.com/bitrise-io/go-utils/fileutil" "github.com/bitrise-io/go-utils/log" - "github.com/bitrise-io/go-utils/pathutil" "github.com/bitrise-io/go-utils/stringutil" "github.com/bitrise-io/go-xcode/utility" "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" - "github.com/bitrise-io/go-xcode/xcodeproject/xcworkspace" "github.com/bitrise-io/goinp/goinp" "github.com/spf13/cobra" ) @@ -121,60 +119,34 @@ func scanXcodeUITestsProject(cmd *cobra.Command, args []string) error { } if paramXcodeDestination != "" { - xcodeUITestsCmd.DESTINATION = paramXcodeDestination + xcodeUITestsCmd.Destination = paramXcodeDestination } else { var project xcodeproj.XcodeProj var scheme xcscheme.Scheme if xcodeproj.IsXcodeProj(xcodeUITestsCmd.ProjectFilePath) { - proj, err := xcodeproj.Open(xcodeUITestsCmd.ProjectFilePath) + proj, projectScheme, _, err := codesigndocutility.OpenArchivableProject(xcodeUITestsCmd.ProjectFilePath, xcodeUITestsCmd.Scheme, "") if err != nil { - return fmt.Errorf("Failed to open project (%s), error: %s", xcodeUITestsCmd.ProjectFilePath, err) - } - - projectScheme, _, err := proj.Scheme(xcodeUITestsCmd.Scheme) - if err != nil { - return fmt.Errorf("failed to find scheme (%s) in project (%s), error: %s", xcodeUITestsCmd.Scheme, proj.Path, err) + return err } - project = proj + project = *proj scheme = *projectScheme } else { - workspace, err := xcworkspace.Open(xcodeUITestsCmd.ProjectFilePath) - if err != nil { - return err - } - - projects, err := workspace.ProjectFileLocations() + proj, projectScheme, _, err := codesigndocutility.OpenArchivableWorkspace(xcodeUITestsCmd.ProjectFilePath, xcodeUITestsCmd.Scheme, "") if err != nil { return err } - for _, projectLocation := range projects { - if exist, err := pathutil.IsPathExists(projectLocation); err != nil { - return fmt.Errorf("failed to check if project exist at: %s, error: %s", projectLocation, err) - } else if !exist { - // at this point we are interested the schemes visible for the workspace - continue - } - - possibleProject, err := xcodeproj.Open(projectLocation) - projectScheme, _, err := possibleProject.Scheme(xcodeUITestsCmd.Scheme) - - if projectScheme != nil && err == nil { - project = possibleProject - scheme = *projectScheme - - break - } - } + project = *proj + scheme = *projectScheme } platform, err := codesigndocutility.BuildableTargetPlatform(&project, &scheme, "", codesigndocutility.XcodeBuild{}) if err == nil { destination := "generic/platform=" + string(platform) - xcodeUITestsCmd.DESTINATION = destination + xcodeUITestsCmd.Destination = destination fmt.Print("Setting -destination flag to: ", destination) } diff --git a/utility/utility.go b/utility/utility.go index 43bebe1d..9f3cf42b 100644 --- a/utility/utility.go +++ b/utility/utility.go @@ -7,10 +7,13 @@ import ( "strings" "github.com/bitrise-io/go-utils/log" + "github.com/bitrise-io/go-utils/pathutil" "github.com/bitrise-io/go-xcode/profileutil" + "github.com/bitrise-io/go-xcode/xcodeproject/schemeint" "github.com/bitrise-io/go-xcode/xcodeproject/serialized" "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" + "github.com/bitrise-io/go-xcode/xcodeproject/xcworkspace" ) // ProfileExportFileNameNoPath creates a file name for the given profile with pattern: uuid.escaped_profile_name.[mobileprovision|provisionprofile] @@ -123,3 +126,72 @@ func getPlatform(buildSettings serialized.Object) (Platform, error) { return "", fmt.Errorf("unkown SDKROOT: %s", sdk) } } + +// OpenArchivableProject ... +func OpenArchivableProject(pth, schemeName, configurationName string) (*xcodeproj.XcodeProj, *xcscheme.Scheme, string, error) { + scheme, schemeContainerDir, err := schemeint.Scheme(pth, schemeName) + if err != nil { + return nil, nil, "", fmt.Errorf("could not get scheme (%s) from path (%s): %s", schemeName, pth, err) + } + if configurationName == "" { + configurationName = scheme.ArchiveAction.BuildConfiguration + } + + if configurationName == "" { + return nil, nil, "", fmt.Errorf("no configuration provided nor default defined for the scheme's (%s) archive action", schemeName) + } + + archiveEntry, ok := scheme.AppBuildActionEntry() + if !ok { + return nil, nil, "", fmt.Errorf("archivable entry not found") + } + + projectPth, err := archiveEntry.BuildableReference.ReferencedContainerAbsPath(filepath.Dir(schemeContainerDir)) + if err != nil { + return nil, nil, "", err + } + + xcodeProj, err := xcodeproj.Open(projectPth) + if err != nil { + return nil, nil, "", err + } + return &xcodeProj, scheme, configurationName, nil +} + +func OpenArchivableWorkspace(pth, schemeName, configurationName string) (*xcodeproj.XcodeProj, *xcscheme.Scheme, string, error) { + workspace, err := xcworkspace.Open(pth) + if err != nil { + return nil, nil, "", err + } + + projects, err := workspace.ProjectFileLocations() + if err != nil { + return nil, nil, "", err + } + + for _, projectLocation := range projects { + if exist, err := pathutil.IsPathExists(projectLocation); err != nil { + return nil, nil, "", fmt.Errorf("failed to check if project exist at: %s, error: %s", projectLocation, err) + } else if !exist { + // at this point we are interested the schemes visible for the workspace + continue + } + + possibleProject, err := xcodeproj.Open(projectLocation) + projectScheme, _, err := possibleProject.Scheme(schemeName) + + if projectScheme != nil && err == nil { + if configurationName == "" { + configurationName = projectScheme.ArchiveAction.BuildConfiguration + } + + if configurationName == "" { + return nil, nil, "", fmt.Errorf("no configuration provided nor default defined for the scheme's (%s) archive action", schemeName) + } + + return &possibleProject, projectScheme, configurationName, err + } + } + + return nil, nil, "", fmt.Errorf("failed to find project in workspace") +} diff --git a/xcode/xcodecmd.go b/xcode/xcodecmd.go index e1975410..cbbf1a27 100644 --- a/xcode/xcodecmd.go +++ b/xcode/xcodecmd.go @@ -45,7 +45,7 @@ type CommandModel struct { // watchOS Simulator // tvOS // tvOS Simulator - DESTINATION string + Destination string } // GenerateArchive : generates the archive for subsequent "Scan" @@ -94,8 +94,8 @@ func (xccmd CommandModel) transformToXcodebuildParams(xcodebuildActionArgs ...st baseArgs = append(baseArgs, "-sdk", xccmd.SDK) } - if xccmd.DESTINATION != "" { - baseArgs = append(baseArgs, "-destination", xccmd.DESTINATION) + if xccmd.Destination != "" { + baseArgs = append(baseArgs, "-destination", xccmd.Destination) } if xccmd.CodeSignIdentity != "" { diff --git a/xcodeuitest/xcodeuitestcmd.go b/xcodeuitest/xcodeuitestcmd.go index 40c2dc61..a46c53b3 100644 --- a/xcodeuitest/xcodeuitestcmd.go +++ b/xcodeuitest/xcodeuitestcmd.go @@ -44,7 +44,7 @@ type CommandModel struct { // watchOS Simulator // tvOS // tvOS Simulator - DESTINATION string + Destination string } // RunBuildForTesting runs the build-for-tesing xcode command @@ -93,8 +93,8 @@ func (xcuitestcmd CommandModel) transformToXcodebuildParams(xcodebuildActionArgs baseArgs = append(baseArgs, "-sdk", xcuitestcmd.SDK) } - if xcuitestcmd.DESTINATION != "" { - baseArgs = append(baseArgs, "-destination", xcuitestcmd.DESTINATION) + if xcuitestcmd.Destination != "" { + baseArgs = append(baseArgs, "-destination", xcuitestcmd.Destination) } return append(baseArgs, xcodebuildActionArgs...), nil @@ -142,7 +142,7 @@ func (xcuitestcmd CommandModel) ScanSchemes() (schemes []xcscheme.Scheme, scheme } else { proj, err := xcodeproj.Open(xcuitestcmd.ProjectFilePath) if err != nil { - return nil, nil, fmt.Errorf("Failed to open project (%s), error: %s", xcuitestcmd.ProjectFilePath, err) + return nil, nil, fmt.Errorf("failed to open project (%s), error: %s", xcuitestcmd.ProjectFilePath, err) } schemes, err = proj.Schemes() From aeac26f6854dc774e14e7b5d20673b088b3b7b8c Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Thu, 27 Jan 2022 16:10:01 +0000 Subject: [PATCH 08/12] updated text --- cmd/xcode.go | 2 +- cmd/xcodeUITests.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/xcode.go b/cmd/xcode.go index 218f56d9..e9ad324a 100644 --- a/cmd/xcode.go +++ b/cmd/xcode.go @@ -44,7 +44,7 @@ func init() { xcodeCmd.Flags().StringVar(¶mXcodeProjectFilePath, "file", "", "Xcode Project/Workspace file path") xcodeCmd.Flags().StringVar(¶mXcodeScheme, "scheme", "", "Xcode Scheme") xcodeCmd.Flags().StringVar(¶mXcodebuildSDK, "xcodebuild-sdk", "", "xcodebuild -sdk param. If a value is specified for this flag it'll be passed to xcodebuild as the value of the -sdk flag. For more info about the values please see xcodebuild's -sdk flag docs. Example value: iphoneos") - xcodeCmd.Flags().StringVar(¶mXcodeDestination, "xcodebuild-destination", "", "The -destination option takes as its argument a destination specifier describing the device (or devices) to use as a destination. If a value is specified for this flag it'll be passed to xcodebuild.") + xcodeCmd.Flags().StringVar(¶mXcodeDestination, "xcodebuild-destination", "", "The xcodebuild -destination option takes as its argument a destination specifier describing the device (or devices) to use as a destination i.e `generic/platform=iOS`. If a value is specified for this flag it'll be passed to xcodebuild.") } func absOutputDir() (string, error) { diff --git a/cmd/xcodeUITests.go b/cmd/xcodeUITests.go index 6742b61c..5d3fdb9d 100644 --- a/cmd/xcodeUITests.go +++ b/cmd/xcodeUITests.go @@ -37,7 +37,7 @@ func init() { xcodeUITestsCmd.Flags().StringVar(¶mXcodeProjectFilePath, "file", "", "Xcode Project/Workspace file path") xcodeUITestsCmd.Flags().StringVar(¶mXcodeScheme, "scheme", "", "Xcode Scheme") xcodeUITestsCmd.Flags().StringVar(¶mXcodebuildSDK, "xcodebuild-sdk", "", "xcodebuild -sdk param. If a value is specified for this flag it'll be passed to xcodebuild as the value of the -sdk flag. For more info about the values please see xcodebuild's -sdk flag docs. Example value: iphoneos") - xcodeUITestsCmd.Flags().StringVar(¶mXcodeDestination, "xcodebuild-destination", "", "The -destination option takes as its argument a destination specifier describing the device (or devices) to use as a destination. If a value is specified for this flag it'll be passed to xcodebuild.") + xcodeUITestsCmd.Flags().StringVar(¶mXcodeDestination, "xcodebuild-destination", "", "The xcodebuild -destination option takes as its argument a destination specifier describing the device (or devices) to use as a destination i.e `generic/platform=iOS`. If a value is specified for this flag it'll be passed to xcodebuild.") } func scanXcodeUITestsProject(cmd *cobra.Command, args []string) error { From bc5ab409a77797d7476f7c9a28446378772a6bb4 Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Thu, 27 Jan 2022 16:14:27 +0000 Subject: [PATCH 09/12] updated text --- utility/utility.go | 1 + 1 file changed, 1 insertion(+) diff --git a/utility/utility.go b/utility/utility.go index 9f3cf42b..9a31fb84 100644 --- a/utility/utility.go +++ b/utility/utility.go @@ -158,6 +158,7 @@ func OpenArchivableProject(pth, schemeName, configurationName string) (*xcodepro return &xcodeProj, scheme, configurationName, nil } +// OpenArchivableWorkspace func OpenArchivableWorkspace(pth, schemeName, configurationName string) (*xcodeproj.XcodeProj, *xcscheme.Scheme, string, error) { workspace, err := xcworkspace.Open(pth) if err != nil { From d627714305a2e3340401d0d0c8bd956781514b99 Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Thu, 27 Jan 2022 16:24:15 +0000 Subject: [PATCH 10/12] fixed lint --- utility/utility.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/utility.go b/utility/utility.go index 9a31fb84..7c7621aa 100644 --- a/utility/utility.go +++ b/utility/utility.go @@ -158,7 +158,7 @@ func OpenArchivableProject(pth, schemeName, configurationName string) (*xcodepro return &xcodeProj, scheme, configurationName, nil } -// OpenArchivableWorkspace +// OpenArchivableWorkspace ... func OpenArchivableWorkspace(pth, schemeName, configurationName string) (*xcodeproj.XcodeProj, *xcscheme.Scheme, string, error) { workspace, err := xcworkspace.Open(pth) if err != nil { From d32fc771eb3ee064de76502abdb55cf1ddcf2615 Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Fri, 28 Jan 2022 09:52:50 +0000 Subject: [PATCH 11/12] remove workspace dupe code --- cmd/xcode.go | 28 +++++----------------------- cmd/xcodeUITests.go | 28 +++++----------------------- utility/utility.go | 41 ----------------------------------------- 3 files changed, 10 insertions(+), 87 deletions(-) diff --git a/cmd/xcode.go b/cmd/xcode.go index e9ad324a..50529e52 100644 --- a/cmd/xcode.go +++ b/cmd/xcode.go @@ -14,8 +14,6 @@ import ( "github.com/bitrise-io/go-utils/fileutil" "github.com/bitrise-io/go-utils/log" "github.com/bitrise-io/go-utils/pathutil" - "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" - "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" "github.com/bitrise-io/goinp/goinp" "github.com/spf13/cobra" ) @@ -116,34 +114,18 @@ func scanXcodeProject(_ *cobra.Command, _ []string) error { if paramXcodeDestination != "" { xcodeCmd.Destination = paramXcodeDestination } else { - var project xcodeproj.XcodeProj - var scheme xcscheme.Scheme - - if xcodeproj.IsXcodeProj(xcodeCmd.ProjectFilePath) { - proj, projectScheme, _, err := utility.OpenArchivableProject(xcodeCmd.ProjectFilePath, xcodeCmd.Scheme, "") - if err != nil { - return err - } - - project = *proj - scheme = *projectScheme - } else { - proj, projectScheme, _, err := utility.OpenArchivableWorkspace(xcodeCmd.ProjectFilePath, xcodeCmd.Scheme, "") - if err != nil { - return err - } - - project = *proj - scheme = *projectScheme + project, scheme, _, err := utility.OpenArchivableProject(xcodeCmd.ProjectFilePath, xcodeCmd.Scheme, "") + if err != nil { + return err } - platform, err := utility.BuildableTargetPlatform(&project, &scheme, "", utility.XcodeBuild{}) + platform, err := utility.BuildableTargetPlatform(project, scheme, "", utility.XcodeBuild{}) if err == nil { destination := "generic/platform=" + string(platform) xcodeCmd.Destination = destination - fmt.Print("Setting -destination flag to: ", destination) + fmt.Print("Setting xcodebuild -destination flag to: ", destination) } } diff --git a/cmd/xcodeUITests.go b/cmd/xcodeUITests.go index 5d3fdb9d..784c25b4 100644 --- a/cmd/xcodeUITests.go +++ b/cmd/xcodeUITests.go @@ -15,8 +15,6 @@ import ( "github.com/bitrise-io/go-utils/log" "github.com/bitrise-io/go-utils/stringutil" "github.com/bitrise-io/go-xcode/utility" - "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" - "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" "github.com/bitrise-io/goinp/goinp" "github.com/spf13/cobra" ) @@ -121,34 +119,18 @@ func scanXcodeUITestsProject(cmd *cobra.Command, args []string) error { if paramXcodeDestination != "" { xcodeUITestsCmd.Destination = paramXcodeDestination } else { - var project xcodeproj.XcodeProj - var scheme xcscheme.Scheme - - if xcodeproj.IsXcodeProj(xcodeUITestsCmd.ProjectFilePath) { - proj, projectScheme, _, err := codesigndocutility.OpenArchivableProject(xcodeUITestsCmd.ProjectFilePath, xcodeUITestsCmd.Scheme, "") - if err != nil { - return err - } - - project = *proj - scheme = *projectScheme - } else { - proj, projectScheme, _, err := codesigndocutility.OpenArchivableWorkspace(xcodeUITestsCmd.ProjectFilePath, xcodeUITestsCmd.Scheme, "") - if err != nil { - return err - } - - project = *proj - scheme = *projectScheme + project, scheme, _, err := codesigndocutility.OpenArchivableProject(xcodeUITestsCmd.ProjectFilePath, xcodeUITestsCmd.Scheme, "") + if err != nil { + return err } - platform, err := codesigndocutility.BuildableTargetPlatform(&project, &scheme, "", codesigndocutility.XcodeBuild{}) + platform, err := codesigndocutility.BuildableTargetPlatform(project, scheme, "", codesigndocutility.XcodeBuild{}) if err == nil { destination := "generic/platform=" + string(platform) xcodeUITestsCmd.Destination = destination - fmt.Print("Setting -destination flag to: ", destination) + fmt.Print("Setting xcodebuild -destination flag to: ", destination) } } diff --git a/utility/utility.go b/utility/utility.go index 7c7621aa..a56af5fc 100644 --- a/utility/utility.go +++ b/utility/utility.go @@ -7,13 +7,11 @@ import ( "strings" "github.com/bitrise-io/go-utils/log" - "github.com/bitrise-io/go-utils/pathutil" "github.com/bitrise-io/go-xcode/profileutil" "github.com/bitrise-io/go-xcode/xcodeproject/schemeint" "github.com/bitrise-io/go-xcode/xcodeproject/serialized" "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" - "github.com/bitrise-io/go-xcode/xcodeproject/xcworkspace" ) // ProfileExportFileNameNoPath creates a file name for the given profile with pattern: uuid.escaped_profile_name.[mobileprovision|provisionprofile] @@ -157,42 +155,3 @@ func OpenArchivableProject(pth, schemeName, configurationName string) (*xcodepro } return &xcodeProj, scheme, configurationName, nil } - -// OpenArchivableWorkspace ... -func OpenArchivableWorkspace(pth, schemeName, configurationName string) (*xcodeproj.XcodeProj, *xcscheme.Scheme, string, error) { - workspace, err := xcworkspace.Open(pth) - if err != nil { - return nil, nil, "", err - } - - projects, err := workspace.ProjectFileLocations() - if err != nil { - return nil, nil, "", err - } - - for _, projectLocation := range projects { - if exist, err := pathutil.IsPathExists(projectLocation); err != nil { - return nil, nil, "", fmt.Errorf("failed to check if project exist at: %s, error: %s", projectLocation, err) - } else if !exist { - // at this point we are interested the schemes visible for the workspace - continue - } - - possibleProject, err := xcodeproj.Open(projectLocation) - projectScheme, _, err := possibleProject.Scheme(schemeName) - - if projectScheme != nil && err == nil { - if configurationName == "" { - configurationName = projectScheme.ArchiveAction.BuildConfiguration - } - - if configurationName == "" { - return nil, nil, "", fmt.Errorf("no configuration provided nor default defined for the scheme's (%s) archive action", schemeName) - } - - return &possibleProject, projectScheme, configurationName, err - } - } - - return nil, nil, "", fmt.Errorf("failed to find project in workspace") -} From ba9f864a583da753a9e1901016a7f9918ad5594a Mon Sep 17 00:00:00 2001 From: Shams Ahmed Date: Fri, 28 Jan 2022 12:10:19 +0000 Subject: [PATCH 12/12] fixed PR comments --- cmd/xcode.go | 4 ++-- cmd/xcodeUITests.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/xcode.go b/cmd/xcode.go index 50529e52..49616b9d 100644 --- a/cmd/xcode.go +++ b/cmd/xcode.go @@ -114,12 +114,12 @@ func scanXcodeProject(_ *cobra.Command, _ []string) error { if paramXcodeDestination != "" { xcodeCmd.Destination = paramXcodeDestination } else { - project, scheme, _, err := utility.OpenArchivableProject(xcodeCmd.ProjectFilePath, xcodeCmd.Scheme, "") + project, scheme, configuration, err := utility.OpenArchivableProject(xcodeCmd.ProjectFilePath, xcodeCmd.Scheme, "") if err != nil { return err } - platform, err := utility.BuildableTargetPlatform(project, scheme, "", utility.XcodeBuild{}) + platform, err := utility.BuildableTargetPlatform(project, scheme, configuration, utility.XcodeBuild{}) if err == nil { destination := "generic/platform=" + string(platform) diff --git a/cmd/xcodeUITests.go b/cmd/xcodeUITests.go index 784c25b4..fc042759 100644 --- a/cmd/xcodeUITests.go +++ b/cmd/xcodeUITests.go @@ -119,12 +119,12 @@ func scanXcodeUITestsProject(cmd *cobra.Command, args []string) error { if paramXcodeDestination != "" { xcodeUITestsCmd.Destination = paramXcodeDestination } else { - project, scheme, _, err := codesigndocutility.OpenArchivableProject(xcodeUITestsCmd.ProjectFilePath, xcodeUITestsCmd.Scheme, "") + project, scheme, configuration, err := codesigndocutility.OpenArchivableProject(xcodeUITestsCmd.ProjectFilePath, xcodeUITestsCmd.Scheme, "") if err != nil { return err } - platform, err := codesigndocutility.BuildableTargetPlatform(project, scheme, "", codesigndocutility.XcodeBuild{}) + platform, err := codesigndocutility.BuildableTargetPlatform(project, scheme, configuration, codesigndocutility.XcodeBuild{}) if err == nil { destination := "generic/platform=" + string(platform)