This post is prompted by an email question about the Validate Built Product option in Xcode which I first mentioned a while back. In particular how can you tell if you are actually validating a build and in what situations the option actually has any effect?
Enabling Validate Build Product
First a recap, you can enable the build validation in the Build Settings for your target - right-click on the target in Xcode and select “Get Info”. You will find the option under the “Build Options” section:
Xcode build results
When you build your project Xcode shows the results in a separate “Build Results” tab and if all goes well you will see the reassuring message that the build succeeded with no issues:
What is missing is any indication that the validation was successful. In fact it is not obvious if validation actually took place at all. To see what really happened you need to look at the detailed build results. To do that you need to change the display from showing “Issues Only” to show “All Messages” using the drop down menu on the title bar of the build results window:
You will now see the detailed build log and if you scroll to the bottom of the log you should see that the last step was to validate the build:
One more tip on the build results window. If you really want to see the commands that Xcode executed you can click on any line and then using the icon that appears at the end of the line you can expand the line to show the complete details.
Of course, if the validation fails the problems are displayed as issues in the Build Results window making it obvious that you have a problem:
No Validation for the Simulator
One thing you need to be aware of is that build validation only works when you are building for a device. If you are building for the simulator the validation will not happen even if you have Validate Built Product selected. So if you want to test validation of your app ensure you build for a device.
Validating Application when submitting
If you use the Build and Archive option in Xocde to build your app for submission to iTunes Connect you should also remember to click on the Validate Application button before submitting. This will catch any last minutes slip-ups that might get you a rejection from the app store. The validation takes a few seconds but you always get back a dialog either telling you were successful or that something needs fixing.