Get current Scheme Name from Run Script Phase

后端 未结 3 2033
渐次进展
渐次进展 2021-02-05 04:41

Is there a way of grabbing the current scheme from a run script phase?

I\'ve tried $(SCHEME_NAME) but it doesn\'t exist.

3条回答
  •  迷失自我
    2021-02-05 05:14

    You can write the scheme name to the info.plist file and read it back in Run Script Phase, in Edit Scheme menu, choose Build -> Pre-actions and add the following script:

    /usr/libexec/PlistBuddy -c "Set :SchemeName \"$SCHEME_NAME\"" "$INFOPLIST_FILE"
    

    and then add the key SchemeName of type string in the info.plist, and its initial value is empty.

    Finally, in the run script phase add the following:

    SCHEME_NAME=$(/usr/libexec/PlistBuddy -c "Print SchemeName" "$INFOPLIST_FILE")
    
    

提交回复
热议问题