Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new export methods #236

Draft
wants to merge 4 commits into
base: v1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions exportoptions/properties.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package exportoptions

import "fmt"
import (
"fmt"

"github.com/bitrise-io/go-xcode/utility"
)

// CompileBitcodeKey ...
const CompileBitcodeKey = "compileBitcode"
Expand Down Expand Up @@ -45,6 +49,8 @@ const ManifestFullSizeImageURLKey = "fullSizeImageURL"
// ManifestAssetPackManifestURLKey ...
const ManifestAssetPackManifestURLKey = "assetPackManifestURL"

const xcode15Dot3BuildVersion = "15E204a"

// Manifest ...
type Manifest struct {
AppURL string
Expand Down Expand Up @@ -76,22 +82,27 @@ func (manifest Manifest) ToHash() map[string]string {
return hash
}

// MethodKey ...
const MethodKey = "method"

const (
// MethodAppStore ...
// MethodAppStore is deprecated since Xcode 15.3, its new name is MethodAppStoreConnect
MethodAppStore Method = "app-store"
// MethodAdHoc ...
// MethodAdHoc is deprecated since Xcode 15.3, its new name is MethodReleaseTesting
MethodAdHoc Method = "ad-hoc"
// MethodPackage ...
MethodPackage Method = "package"
// MethodEnterprise ...
MethodEnterprise Method = "enterprise"
// MethodDevelopment ...
// MethodDevelopment is deprecated since Xcode 15.3, its new name is MethodDebugging
MethodDevelopment Method = "development"
// MethodDeveloperID ...
MethodDeveloperID Method = "developer-id"
// MethodDebugging is the new name for MethodDevelopment since Xcode 15.3
MethodDebugging Method = "debugging"
// MethodAppStoreConnect is the new name for MethodAppStore since Xcode 15.3
MethodAppStoreConnect Method = "app-store-connect"
// MethodReleaseTesting is the new name for MethodAdHoc since Xcode 15.3
MethodReleaseTesting Method = "release-testing"
// MethodDefault ...
MethodDefault Method = MethodDevelopment
)
Expand All @@ -101,17 +112,35 @@ type Method string

// ParseMethod ...
func ParseMethod(method string) (Method, error) {
// TODO: Print warning if old export methods are used with Xcode 15.3 or newer
newExportMethods, err := utility.XcodeBuildVersionIsAtLeast(xcode15Dot3BuildVersion)
if err != nil {
return Method(""), fmt.Errorf("check Xcode version: %s", err)
}

switch method {
case "app-store":
return MethodAppStore, nil
if newExportMethods {
return MethodAppStoreConnect, nil
} else {
return MethodAppStore, nil
}
case "ad-hoc":
return MethodAdHoc, nil
if newExportMethods {
return MethodReleaseTesting, nil
} else {
return MethodAdHoc, nil
}
case "package":
return MethodPackage, nil
case "enterprise":
return MethodEnterprise, nil
case "development":
return MethodDevelopment, nil
if newExportMethods {
return MethodDebugging, nil
} else {
return MethodDevelopment, nil
}
case "developer-id":
return MethodDeveloperID, nil
default:
Expand Down
12 changes: 12 additions & 0 deletions utility/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ func GetXcodeVersion() (models.XcodebuildVersionModel, error) {
return getXcodeVersionFromXcodebuildOutput(outStr)
}

// XcodeBuildVersionIsAtLeast returns true if the active Xcode's build version is at least the given version.
// Comparison is done by comparing the version strings, assuming monotonic build versions.
// Use this helper to alter step behavior based on a change introduced in a specific Xcode version.
func XcodeBuildVersionIsAtLeast(buildVersion string) (bool, error) {
xcodeVersion, err := GetXcodeVersion()
if err != nil {
return false, err
}

return strings.Replace(xcodeVersion.BuildVersion, "Build version ", "", -1) >= buildVersion, nil
}

func getXcodeVersionFromXcodebuildOutput(outStr string) (models.XcodebuildVersionModel, error) {
split := strings.Split(outStr, "\n")
if len(split) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion xcarchive/entitlements.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func getEntitlements(basePath, executableRelativePath string) (plistutil.PlistDa
}

func entitlementsFromExecutable(basePath, executableRelativePath string) (*plistutil.PlistData, error) {
fmt.Printf("Fetching entitlements from executable")
fmt.Println("Fetching entitlements from executable")

cmd := command.New("codesign", "--display", "--entitlements", ":-", filepath.Join(basePath, executableRelativePath))
entitlementsString, err := cmd.RunAndReturnTrimmedOutput()
Expand Down