Skip to content

Commit fbf67b9

Browse files
authored
Scheme workspace (#293)
* Added SchemeCodeSignEntitlements * Add customOptions
1 parent 0c84f25 commit fbf67b9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

xcodeproject/xcworkspace/xcworkspace.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/bitrise-io/go-utils/fileutil"
1010
"github.com/bitrise-io/go-utils/log"
11+
"github.com/bitrise-io/go-utils/pathutil"
1112
"github.com/bitrise-io/go-xcode/xcodebuild"
1213
"github.com/bitrise-io/go-xcode/xcodeproject/serialized"
1314
"github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj"
@@ -62,6 +63,31 @@ func (w Workspace) SchemeBuildSettings(scheme, configuration string, customOptio
6263
return object, err
6364
}
6465

66+
// SchemeCodeSignEntitlements returns the code sign entitlements for a scheme and configuration
67+
func (w Workspace) SchemeCodeSignEntitlements(scheme, configuration string, customOptions ...string) (serialized.Object, error) {
68+
buildSettings, err := w.SchemeBuildSettings(scheme, configuration, customOptions...)
69+
if err != nil {
70+
return nil, err
71+
}
72+
73+
entitlementsPath, err := buildSettings.String("CODE_SIGN_ENTITLEMENTS")
74+
if err != nil {
75+
return nil, err
76+
}
77+
78+
if pathutil.IsRelativePath(entitlementsPath) {
79+
entitlementsPath = filepath.Join(filepath.Dir(w.Path), entitlementsPath)
80+
}
81+
82+
entitlements, _, err := xcodeproj.ReadPlistFile(entitlementsPath)
83+
if err != nil {
84+
return nil, err
85+
}
86+
87+
log.TDebugf("Fetched %s scheme code sign entitlements", scheme)
88+
return entitlements, nil
89+
}
90+
6591
// FileLocations ...
6692
func (w Workspace) FileLocations() ([]string, error) {
6793
var fileLocations []string

0 commit comments

Comments
 (0)