2

I want to have a run script that looks at the number of previous warnings (probably during the compile phase), and generates an error which stops the run/buid if the number of warnings is too large.

I am working on an app that has a large amount of warnings that happen during compile. They do not stop the app from compiling, but I want to stop devs from adding more warnings as they add features.

I have looked everywhere, but so far have not found a way to use previous build output in the run script phase of the build. Is there any way of doing this? Some kind of env variable, or a way of monitoring the build output in a custom script as it happens?

I see a similar question here: Is there a way to access Xcodes current build output from a build phase run script? But it seems that the output is only available after the build is complete in that answer. Is there any other option that would allow the build to be failed before it finishes?

Any insight into the build system in Xcode would be appreciated! Cheers

Additional context:

All I need is for Xcode's default warnings to have a feature similar to SwiftLint's warning_threshold https://stackoverflow.com/a/52256459/7623867

Andrei T
  • 163
  • 1
  • 8

1 Answers1

1

I have looked into that problem as well for quite some time (I wanted to use warnings for quality measurement). The only way I have found is to compile the whole project with xcodebuild, with a command similar to:

xcrun xcodebuild -project MyProject.xcodeproj/ -scheme MyScheme -destination "platform=iOS Simulator" build -quiet | tee xcodebuild.log

and then counting the warnings using AWK or some other tool.

Here is an example.

Daniel
  • 20,420
  • 10
  • 92
  • 149
  • I have thought of doing this, but again this is outside of Xcode. I understand it can be part of the CI once a branch / PR is made, but I am looking for a quicker and local way of informing the developers that there are too many warnings. It is so strange that Xcode does not seem provide any way of inspecting build output as it happens. – Andrei T Aug 12 '22 at 17:29