I added "-D MYOWNFLAG" to Other Swift Flags in Build Settings of Xcode. Now, in my Run Script found in Build Phases, I want to check for the existence of the flag "MYOWNFLAG" and execute something (e.g. change Info.plist setting value) if it exists.
Is this possible? If yes, what is the best way to do this?
Integrate SwiftLint with Xcode In order to integrate SwiftLint with Xcode project target to get warnings and errors displayed in the Xcode IDE, you just need to add a new “Run Script Phase” with following script - If you don’t know how to add a “Run Script Phase” in your project target, here an image for your reference -
When Xcode Cloud executes a new build, the custom build scripts are automatically detected and run at their designated time in the timeline. To create the ci_scripts directory, navigate to the Project Navigator in Xcode and Control-click your project, choose New Group to create the group and its corresponding directory, and name it ci_scripts.
Use the following convention to manage you build phase scripts: There must be one shell script per build phase. For example, put all your build phase scripts in a directory named build-phases, e.g. build-phases/codecheck.sh, build-phases/codegen.sh, etc. In Xcode build phase UI instead of having an inline script, you have this now:
The problem is that shell scripts ran in Xcode build phases do not source the user shell profile. Then run the build phase by building Xcode project. None of the messages from shell profiles will show up. The reason is that a shell ran from Xcode build phase is non-interactive shell.
Should be able to use wildcards in conjunction with the $OTHER_SWIFT_FLAGS
env variable.
if [[ $OTHER_SWIFT_FLAGS == *"-D MYOWNFLAG"* ]]; then
echo "execute something (e.g. change Info.plist setting value)"
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With