Skip to content
Open
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
20 changes: 14 additions & 6 deletions xcarchive/ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package xcarchive
import (
"errors"
"fmt"
"log"
"path/filepath"

"github.com/bitrise-io/go-utils/v2/command"
Expand Down Expand Up @@ -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)
}
Comment on lines +68 to 73
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛 Bug

This change allows creating IosBaseApplication with a zero-value ProvisioningProfile when no embedded.mobileprovision is found. However, the IsXcodeManaged() method (line 310) calls ProvisioningProfile.IsXcodeManaged() directly without checking if the profile is valid, which will cause runtime issues for simulator builds.

🔄 Suggestion:

Suggested change
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)
}
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)
// Note: IsXcodeManaged() method needs to be updated to handle zero-value ProvisioningProfile
}


executable := executableNameFromInfoPlist(infoPlist)
Expand Down