diff --git a/go.mod b/go.mod index 6628fe75..555e5ddc 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/bitrise-io/go-utils v1.0.14 github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23 github.com/bitrise-io/go-xcode v1.3.0 - github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.67 + github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.67.0.20250916115031-007c7230724c github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/stretchr/testify v1.10.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 39714657..493e51bb 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,8 @@ github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23 h1:Dfh4nyZPuEtilBisidejqxBrkx9 github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23/go.mod h1:3XUplo0dOWc3DqT2XA2SeHToDSg7+j1y1HTHibT2H68= github.com/bitrise-io/go-xcode v1.3.0 h1:QB8Vyr2oZQro/ocs9DJai80rlYL1hU1kwjHqdGslFLo= github.com/bitrise-io/go-xcode v1.3.0/go.mod h1:9OwsvrhZ4A2JxHVoEY7CPcABAKA+OE7FQqFfBfvbFuY= -github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.67 h1:Fz3LSRoH9p5u7yTqdsmE32RHGWEw8q3BVWoOSiHs7AY= -github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.67/go.mod h1:rSmzmqVD3Mn9dWwe19qiiGjlvk/At3D8bQh7n9E8S58= +github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.67.0.20250916115031-007c7230724c h1:7LVyacj3I5q54CSzzUGmigFxsINYdXTJgJPs9Z83tqY= +github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.67.0.20250916115031-007c7230724c/go.mod h1:rSmzmqVD3Mn9dWwe19qiiGjlvk/At3D8bQh7n9E8S58= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/step/platform.go b/step/platform.go index d664ae68..a1eccb73 100644 --- a/step/platform.go +++ b/step/platform.go @@ -21,9 +21,14 @@ const ( tvOS Platform = "tvOS" watchOS Platform = "watchOS" visionOS Platform = "visionOS" + + // Not permitted on this steps UI, but may come from build-for-simulator + iOSSimulator Platform = "iOS Simulator" + watchOSSimulator Platform = "watchOS Simulator" + tvOSSimulator Platform = "tvOS Simulator" ) -func parsePlatform(platform string) (Platform, error) { +func ParsePlatform(platform string) (Platform, error) { switch strings.ToLower(platform) { case "detect": return detectPlatform, nil @@ -35,6 +40,12 @@ func parsePlatform(platform string) (Platform, error) { return watchOS, nil case "visionos": return visionOS, nil + case "ios simulator": + return iOSSimulator, nil + case "watchos simulator": + return watchOSSimulator, nil + case "tvos simulator": + return tvOSSimulator, nil default: return "", fmt.Errorf("unknown platform: %s", platform) } @@ -157,7 +168,24 @@ func getPlatform(buildSettings serialized.Object) (Platform, error) { case strings.HasPrefix(sdk, "xros"): // visionOS SDK is called xros (as of Xcode 15.2), but the platform is called visionOS (e.g. in the destination specifier) return visionOS, nil + case strings.HasPrefix(sdk, "iphonesimulator"): + return iOSSimulator, nil + case strings.HasPrefix(sdk, "watchsimulator"): + return watchOSSimulator, nil + case strings.HasPrefix(sdk, "appletvsimulator"): + return tvOSSimulator, nil default: return "", fmt.Errorf("unkown SDKROOT: %s", sdk) } } + +func (p Platform) canExportIPA() bool { + switch p { + case iOS, tvOS, watchOS, visionOS: + return true + case osX, iOSSimulator, watchOSSimulator, tvOSSimulator: + return false + default: + return false + } +} diff --git a/step/platform_test.go b/step/platform_test.go index 3f496ad0..50975eff 100644 --- a/step/platform_test.go +++ b/step/platform_test.go @@ -165,8 +165,44 @@ func Test_getPlatform(t *testing.T) { wantErr: false, }, { - name: "unkown SDK path", + name: "iOS Simulator", + buildSettings: serialized.Object(map[string]interface{}{"SDKROOT": "iphonesimulator"}), + want: iOSSimulator, + wantErr: false, + }, + { + name: "tvOS Simulator", + buildSettings: serialized.Object(map[string]interface{}{"SDKROOT": "appletvsimulator"}), + want: tvOSSimulator, + wantErr: false, + }, + { + name: "watchOS Simulator", + buildSettings: serialized.Object(map[string]interface{}{"SDKROOT": "watchsimulator"}), + want: watchOSSimulator, + wantErr: false, + }, + { + name: "iOS simulator with SDK path", + buildSettings: serialized.Object(map[string]interface{}{"SDKROOT": "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"}), + want: iOSSimulator, + wantErr: false, + }, + { + name: "tvOS simulator with SDK path", + buildSettings: serialized.Object(map[string]interface{}{"SDKROOT": "/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk"}), + want: tvOSSimulator, + wantErr: false, + }, + { + name: "watchOS simulator with SDK path", buildSettings: serialized.Object(map[string]interface{}{"SDKROOT": "/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk"}), + want: watchOSSimulator, + wantErr: false, + }, + { + name: "unknown SDK path", + buildSettings: serialized.Object(map[string]interface{}{"SDKROOT": "/Applications/Xcode.app/Contents/Developer/Platforms/Stuff.platform/Developer/SDKs/Stuff.sdk"}), want: Platform(""), wantErr: true, }, diff --git a/step/step.go b/step/step.go index 247b3791..1deee84b 100644 --- a/step/step.go +++ b/step/step.go @@ -201,7 +201,7 @@ func (s XcodebuildArchiveConfigParser) ProcessInputs() (Config, error) { } var err error - if config.DestinationPlatform, err = parsePlatform(config.Platform); err != nil { + if config.DestinationPlatform, err = ParsePlatform(config.Platform); err != nil { return Config{}, fmt.Errorf("issue with input Platform: %w", err) } @@ -454,6 +454,10 @@ func (s XcodebuildArchiver) Run(opts RunOpts) (RunResult, error) { out.Archive = archiveOut.Archive + if !opts.DestinationPlatform.canExportIPA() { + return out, nil + } + IPAExportOpts := xcodeIPAExportOpts{ XcodeMajorVersion: opts.XcodeMajorVersion, XcodeAuthOptions: authOptions, diff --git a/vendor/github.com/bitrise-io/go-xcode/v2/xcarchive/ios.go b/vendor/github.com/bitrise-io/go-xcode/v2/xcarchive/ios.go index b92b1801..25ae7cf6 100644 --- a/vendor/github.com/bitrise-io/go-xcode/v2/xcarchive/ios.go +++ b/vendor/github.com/bitrise-io/go-xcode/v2/xcarchive/ios.go @@ -3,6 +3,7 @@ package xcarchive import ( "errors" "fmt" + "log" "path/filepath" "github.com/bitrise-io/go-utils/v2/command" @@ -48,20 +49,27 @@ func NewIosBaseApplication(path string) (IosBaseApplication, error) { infoPlist = plist } - var provisioningProfile profileutil.ProvisioningProfileInfoModel - { + profileNotFoundErr := fmt.Errorf("profile not exists at: %s", filepath.Join(path, "embedded.mobileprovision")) + var provisioningProfileCreator = func() (profileutil.ProvisioningProfileInfoModel, error) { provisioningProfilePath := filepath.Join(path, "embedded.mobileprovision") if exist, err := pathChecker.IsPathExists(provisioningProfilePath); err != nil { - return IosBaseApplication{}, fmt.Errorf("failed to check if profile exists at: %s, error: %s", provisioningProfilePath, err) + return profileutil.ProvisioningProfileInfoModel{}, fmt.Errorf("failed to check if profile exists at: %s, error: %s", provisioningProfilePath, err) } else if !exist { - return IosBaseApplication{}, fmt.Errorf("profile not exists at: %s", provisioningProfilePath) + return profileutil.ProvisioningProfileInfoModel{}, profileNotFoundErr } profile, err := profileutil.NewProvisioningProfileInfoFromFile(provisioningProfilePath) if err != nil { - return IosBaseApplication{}, err + return profileutil.ProvisioningProfileInfoModel{}, err } - provisioningProfile = profile + + return profile, nil + } + provisioningProfile, err := provisioningProfileCreator() + if err != nil && err != profileNotFoundErr { + return IosBaseApplication{}, err + } else if err == profileNotFoundErr { + log.Printf("No embedded.mobileprovision found for app at: %s", path) } executable := executableNameFromInfoPlist(infoPlist) diff --git a/vendor/modules.txt b/vendor/modules.txt index 9c0a6b78..c68e84b2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -55,7 +55,7 @@ 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 -# github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.67 +# github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.67.0.20250916115031-007c7230724c ## explicit; go 1.22 github.com/bitrise-io/go-xcode/v2/autocodesign github.com/bitrise-io/go-xcode/v2/autocodesign/certdownloader