@@ -2,6 +2,7 @@ package pathfilters
22
33import (
44 "fmt"
5+ "strings"
56
67 "github.com/bitrise-io/go-utils/pathutil"
78 "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj"
@@ -73,7 +74,7 @@ var AllowIphoneosSDKFilter = SDKFilter("iphoneos", true)
7374var AllowMacosxSDKFilter = SDKFilter ("macosx" , true )
7475
7576// SDKFilter ...
76- func SDKFilter (sdk string , allowed bool ) pathutil.FilterFunc {
77+ func SDKFilter (expectedSDK string , allowed bool ) pathutil.FilterFunc {
7778 return func (pth string ) (bool , error ) {
7879 found := false
7980
@@ -106,6 +107,7 @@ func SDKFilter(sdk string, allowed bool) pathutil.FilterFunc {
106107 return false , fmt .Errorf ("not Xcode project nor workspace file: %s" , pth )
107108 }
108109
110+ supportedPlatformsMap := map [string ]bool {}
109111 sdkMap := map [string ]bool {}
110112 for _ , projectFile := range projectFiles {
111113 project , err := xcodeproj .Open (projectFile )
@@ -119,22 +121,39 @@ func SDKFilter(sdk string, allowed bool) pathutil.FilterFunc {
119121 buildConfigurations = append (buildConfigurations , target .BuildConfigurationList .BuildConfigurations ... )
120122 }
121123
122- for _ , buildConfiguratioon := range buildConfigurations {
123- sdk , err := buildConfiguratioon .BuildSettings .String ("SDKROOT" )
124+ for _ , buildConfiguration := range buildConfigurations {
125+ sdk , err := buildConfiguration .BuildSettings .String ("SDKROOT" )
124126 if err == nil {
125127 sdkMap [sdk ] = true
126128 }
129+
130+ if sdk != "auto" {
131+ continue
132+ }
133+
134+ supportedPlatformsValue , err := buildConfiguration .BuildSettings .String ("SUPPORTED_PLATFORMS" )
135+ if err == nil {
136+ supportedPlatforms := strings .Split (supportedPlatformsValue , " " )
137+ for _ , platform := range supportedPlatforms {
138+ supportedPlatformsMap [platform ] = true
139+ }
140+ }
127141 }
128142
129143 for projectSDK := range sdkMap {
130- if projectSDK == sdk {
144+ if projectSDK == expectedSDK {
131145 found = true
132146 break
133147 }
134148 }
135- }
136149
137- fmt .Printf ("Found %v SDK's from %v project files." , len (sdkMap ), len (projectFiles ))
150+ for platform := range supportedPlatformsMap {
151+ if platform == expectedSDK {
152+ found = true
153+ break
154+ }
155+ }
156+ }
138157
139158 return (allowed == found ), nil
140159 }
0 commit comments