We encountered an odd situation.
Our project is being developed for more than 3 years now since Xcode 4, and it never was a problem. We migrated the project every September, and everything was fine. However, in Xcode 8 we started to get an odd error: “Application does not have a valid signature” when building to iOS 10 device.
The thing is, it runs perfectly first time. If you press Stop and Run again, it will produce this error. However, if you clean the project, delete DerivedData or simply add a symbol to code and remove it (forcing rebuilding), it will run again as well. BUT. Even if you uninstall an app and press Run, you will still get this error, and app won't be even installed to device.
At first time I thought it's a CocoaPods issue. I removed it from the project, but it didn't help. Then I started to remove build phases one by one and localized the error cause.
We have build phase that updates field BuildDate in Info.plist (since the beginning of the project), we read this value in the app itself. It looks like that:
infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH" builddate=`date -u +"%Y-%m-%dT%H:%M:%S.000Z"` if [[ -n "$builddate" ]]; then /usr/libexec/PlistBuddy -c "Add :BuildDate $builddate" ${infoplist} /usr/libexec/PlistBuddy -c "Set :BuildDate $builddate" ${infoplist} fi
It is being executed after Copy Bundle Resources phase. It seems that if we remove this phase, it will never produce the invalid signature error. For me it seems like Apple added an integrity check after code sign, and since the resource has changed without Xcode knowing about it, checksum doesn't change, and integrity check fails.
Of course, we can add ENV check to execute this only when archiving the project, but it is handy to have this feature in Debug too. Any ideas how this could be achieved?