Bug 50791 - CodesignVerify execution failed
Summary: CodesignVerify execution failed
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild ()
Version: XI 10.4 (C9)
Hardware: Macintosh Mac OS
: Highest blocker
Target Milestone: (C9)
Assignee: Jeffrey Stedfast
Depends on:
Reported: 2016-12-25 21:36 UTC by Shay
Modified: 2017-01-27 12:35 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Failed Rebuild log (336.82 KB, text/plain)
2016-12-27 06:37 UTC, Shay
Successful build log (582.13 KB, text/plain)
2016-12-27 06:39 UTC, Shay

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Shay 2016-12-25 21:36:48 UTC
I have a large project that compiles after "Clean Up".
However, whenever I try to rebuild the project, I get the following error:

	Target _CodesignVerify:
		CodesignVerify Task
		  CodesignAllocate: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
		  Resource: bin/iPhone/Debug/build-iphone5.3-10.2/ClimbTagApp_iOS.app
		Tool /usr/bin/codesign execution started with arguments: --verify -vvvv -R='anchor apple generic and certificate 1[field.1.2.840.113635.] exists and (certificate leaf[field.1.2.840.113635.] exists or certificate leaf[field.1.2.840.113635.] exists)' bin/iPhone/Debug/build-iphone5.3-10.2/ClimbTagApp_iOS.app 
		bin/iPhone/Debug/build-iphone5.3-10.2/ClimbTagApp_iOS.app: code object is not signed at all
		In architecture: armv7
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: error : Tool exited with code: 1. Output: bin/iPhone/Debug/build-iphone5.3-10.2/ClimbTagApp_iOS.app: code object is not signed at all
In architecture: armv7

	Task "CodesignVerify" execution -- FAILED
	Done building target "_CodesignVerify" in project "/Users/shayo/Projects/iOS/ClimbTagApp.iOS.csproj".-- FAILED
Done building project "/Users/shayo/Projects/iOS/ClimbTagApp.iOS.csproj".-- FAILED



Cleaning the project and recompiling leads to a successful compilation.
This is very annoying - I basically need to run full compilation for every tiny change of the code.

Xamarin Studio information below:

=== Xamarin Studio Business ===

Version 6.2 (build 1686)
Installation UUID: 07360e74-2c80-443b-94a1-6221c776bc97
	Mono 4.8.0 (mono-4.8.0-branch/df81fe4) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000395

=== NuGet ===


=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 8.2 (11759)
Build 8C23

=== Xamarin.iOS ===

Version: (Xamarin Business)
Hash: 4d85810
Branch: master
Build date: 2016-12-17 15:04:15-0500

=== Xamarin.Mac ===

Version: (Xamarin Business)

=== Xamarin Inspector ===

Not Installed

=== Xamarin.Android ===

Version: (Xamarin Business)
Android SDK: /Users/shayo/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)
		7.0    (API level 24)

SDK Tools Version: 25.2.2
SDK Platform Tools Version: 24.0.3
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)

Android Designer EPL code available here:

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Build Information ===

Release ID: 602001686
Git revision: 3e8b559b32962db4d3860072ce79dee44f0c6a88
Build date: 2016-12-15 09:09:49-05
Xamarin addins: d83d393881f04cf1f62093120f1ed619e3a13c5b
Build lane: monodevelop-lion-cycle9

=== Operating System ===

Mac OS X 10.12.1
Darwin Shays-MacBook-Pro.local 16.1.0 Darwin Kernel Version 16.1.0
    Thu Oct 13 21:26:57 PDT 2016
    root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64
Comment 1 Sebastien Pouliot 2016-12-26 17:44:12 UTC
@Shay can you please attach a complete "rebuild" build log so we can see what went wrong (earlier) in the build ? thanks!
Comment 2 Shay 2016-12-27 06:37:42 UTC
Created attachment 19005 [details]
Failed Rebuild log
Comment 3 Shay 2016-12-27 06:39:17 UTC
Created attachment 19006 [details]
Successful build log
Comment 4 Sebastien Pouliot 2016-12-27 17:21:40 UTC
Comment 5 Sebastien Pouliot 2017-01-04 00:02:51 UTC
@Jeff any of the unit tests project in xamarin-macios shows the same issue. E.g.

1. Build monotouch-tests for iPhone/Release -> fine
2. Change a build option, e.g. switch LLVM;
3. Build monotouch-tests for iPhone/Release -> this error

The workaround is doing a Clean between builds.
Comment 6 Jeffrey Stedfast 2017-01-04 16:29:34 UTC
Based on the log, it looks like the timestamps on the files listed in the Inputs have not changed and so it is not resigning.

I probably just need to figure out what other file(s) need to be in that Inputs list.

Working on that now...
Comment 7 Jeffrey Stedfast 2017-01-04 17:31:07 UTC
Looks like I accidentally used "%(_NativeExecutable.Identity)" (which doesn't exist because _NativeExecutable is a *Property* and not an *Item*) instead of "$(_NativeExecutable)"
Comment 8 Jeffrey Stedfast 2017-01-04 17:34:41 UTC
That said, we should also add the Info.plist and embedded.mobileprovision to the Inputs as well as potentially the native libraries/frameworks (need more investigation into this...).
Comment 9 Jeffrey Stedfast 2017-01-04 19:07:31 UTC
When the .app contains frameworks, _CodeSignature/CodeResources includes hashes for them... so it looks like we need to include frameworks in the Inputs as well.
Comment 11 Rolf Bjarne Kvinge [MSFT] 2017-01-04 19:19:04 UTC
@Jeff, maybe we should read/parse _CodeSignature/CodeResources to get the list of inputs? If anything in that file listed in that file is changed, it will invalidate the signature.
Comment 12 Saurabh 2017-01-27 12:35:05 UTC
I can also reproduce this Issue with XI  with steps mentioned in comment#5 using iOS template project. Below is the build output for the same:
Build Output: https://gist.github.com/saurabh360/3a4a15f819441d2ac9deafa886294b91

I have checked the same Issue with latest Cycle 9 build(XI and Master build (XI This is working fine now.

Build Output: https://gist.github.com/saurabh360/0b7ce3b57d7205eccd9cad0014ff730a
Environment Info: https://gist.github.com/saurabh360/c7bc12cb288ca6f845445a5fd378bc92