From 9c376f23b6caaa830438fc495f1762a227d45bb5 Mon Sep 17 00:00:00 2001 From: Viktor Benei Date: Thu, 1 Jun 2017 18:16:14 +0200 Subject: [PATCH] new xcode command flag: `xcodebuild-sdk` if specified the value will be passed as the `-sdk` flag's value to `xcodebuild` for the scan --- cmd/xcode.go | 8 ++++++++ xcode/xcodecmd.go | 23 +++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/cmd/xcode.go b/cmd/xcode.go index 2a923b50..9c53ae48 100644 --- a/cmd/xcode.go +++ b/cmd/xcode.go @@ -28,6 +28,7 @@ var ( paramXcodeProjectFilePath = "" paramXcodeScheme = "" paramXcodebuildOutputLogFilePath = "" + paramXcodebuildSDK = "" ) func init() { @@ -42,6 +43,9 @@ func init() { xcodeCmd.Flags().StringVar(¶mXcodebuildOutputLogFilePath, "xcodebuild-log", "", "xcodebuild output log (file path). If specified it will be used instead of running xcodebuild") + 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") } func printXcodeScanFinishedWithError(format string, args ...interface{}) error { @@ -111,6 +115,10 @@ func scanXcodeProject(cmd *cobra.Command, args []string) error { } xcodeCmd.Scheme = schemeToUse + if paramXcodebuildSDK != "" { + xcodeCmd.SDK = paramXcodebuildSDK + } + fmt.Println() fmt.Println() log.Println("🔦 Running an Xcode Archive, to get all the required code signing settings...") diff --git a/xcode/xcodecmd.go b/xcode/xcodecmd.go index d868409f..7ae590bb 100644 --- a/xcode/xcodecmd.go +++ b/xcode/xcodecmd.go @@ -20,10 +20,25 @@ import ( // CommandModel ... type CommandModel struct { + // --- Required --- + // ProjectFilePath - might be a `xcodeproj` or `xcworkspace` - ProjectFilePath string - Scheme string + ProjectFilePath string + + // --- Optional --- + + // Scheme will be passed to xcodebuild as the -scheme flag's value + // Only passed to xcodebuild if not empty! + Scheme string + + // CodeSignIdentity will be passed to xcodebuild as an CODE_SIGN_IDENTITY= argument. + // Only passed to xcodebuild if not empty! CodeSignIdentity string + + // SDK: if defined it'll be passed as the -sdk flag to xcodebuild. + // 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 } func parseSchemesFromXcodeOutput(xcodeOutput string) []string { @@ -180,6 +195,10 @@ func (xccmd CommandModel) transformToXcodebuildParams(xcodebuildActionArgs ...st baseArgs = append(baseArgs, "-scheme", xccmd.Scheme) } + if xccmd.SDK != "" { + baseArgs = append(baseArgs, "-sdk", xccmd.SDK) + } + if xccmd.CodeSignIdentity != "" { baseArgs = append(baseArgs, `CODE_SIGN_IDENTITY=`+xccmd.CodeSignIdentity) }