xamarin-macios
xamarin-macios copied to clipboard
"Codesign exited with code 1" issue when try to build an iOS app using visual studio 2022 for mac, Rider and VS Code
From @mmuresan on Mon, 12 Feb 2024 19:57:51 GMT
Description
I am running Visual Studio for Mac, Rider and VS Code on an M2 Mac laptop. The Maui application I have is not building, when selecting an attached iPad and then build. The error I get is "Codesign exited with code 1" This is NOT tooling related, as I get exactly the same error building from Visual Studio for Mac, Rider and VS Code. I saw in the past multiple people reporting this bug, but they were dismissed and redirected to VS for Mac team and this is definitely not related to any IDE we are using. This is not happening with newly created applications.
Steps to Reproduce
Unfortunately, the application is very complex and the only thing that I can produce is a build log, or anything that the team might need to be able to unblock this.
Link to public reproduction project repository
No response
Version with bug
8.0.6
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
iOS, macOS
Affected platform versions
iOS 15
Did you find any workaround?
I tried quite a lot of things and no workaround yet.
Relevant log output
No response
Copied from original issue dotnet/maui#20530
From @drasticactions on Tue, 13 Feb 2024 01:56:32 GMT
This is a tooling issue. This repo is for the MAUI UI project and it doesn't control the bundling and deployment of applications to devices. That's handled by the .NET SDK and/or IDE tooling. Whatever issue you are hitting is, most likely, not something that can be fixed within this repo. That's why they get redirected elsewhere, so teams with more knowledge of it can address it and help.
Here are some steps to help debug this further:
- Try building an iOS app that doesn't use the MAUI UI framework (
dotnet new ios
). Can you build and deploy that? - Try building a new template MAUI app, does that deploy?
- Can you deploy an app with Xcode to that device? Just to make sure you can deploy at all.
@rolfbjarne Would you know of other ways to debug this?
From @rolfbjarne on Tue, 13 Feb 2024 06:49:52 GMT
The first step would be to get a build log, preferrably a binlog (https://github.com/xamarin/xamarin-macios/wiki/Diagnosis#binary-build-logs). The codesigning task will output more information than just "Codesign exited with code 1"
, you can inspect the binlog to see this. Alternatively you can upload it here and we can have a look at it.
From @mmuresan on Tue, 13 Feb 2024 12:18:52 GMT
To answer to all of your questions/suggestions, on the same Mac M2 laptop: "Try building an iOS app that doesn't use the MAUI UI framework (dotnet new ios). Can you build and deploy that?"
- it works with the old Xamarin app (the one I have converted to Maui), build and deploy to Simulator and iPad "Try building a new template MAUI app, does that deploy?"
- I can build and deploy a new Maui app, both on Simulator and on iPad "Can you deploy an app with Xcode to that device? Just to make sure you can deploy at all."
- any app I create with XCode it builds and gets deployed to iPad and Simulator
This particular error is strictly related to the upgraded Maui app from Xamarin.
Just to reiterate, I get exactly the same error when I use any of these tools, installed on my Mac:
- Visual Studio for Mac
- Rider
- VS Code This is the reason I think it is really not likely tooling related, but some setting in the Maui app that makes this happening.
I can create and deploy an Android app from the same Solution/set of projects, from both Mac and Windows development machines, so it is not the app/libraries, but some settings inside the app that makes the building going sideways.
From @mirceamuresanse on Tue, 13 Feb 2024 19:53:09 GMT
This is the part from the log that shows the code signing failure, but it doesn't say why it failed. /Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app/Frameworks/Runtimecore.framework: signed bundle with Mach-O thin (arm64) [com.esri.arcgis.runtime.core]
The stamp file 'obj/Debug/net8.0-ios/ios-arm64/codesign/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app/Frameworks/Runtimecore.framework/.stampfile' does not exit for the item '/Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app/Frameworks/Runtimecore.framework', and it will be created
Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp=none --sign 4BC5B175C60B2E255E6B1E465FF35EA5B197FC41 --entitlements /Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/obj/Debug/net8.0-ios/ios-arm64/Entitlements.xcent /Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app
Tool /usr/bin/codesign execution finished (exit code = 1).
/Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app: code object is not signed at all
In subcomponent: /Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app/System.Net.Security.dll
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.2.8004/tools/msbuild/iOS/Xamarin.Shared.targets(2256,3): error : /usr/bin/codesign exited with code 1:
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.2.8004/tools/msbuild/iOS/Xamarin.Shared.targets(2256,3): error : /Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app: code object is not signed at all
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.2.8004/tools/msbuild/iOS/Xamarin.Shared.targets(2256,3): error : In subcomponent: /Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app/System.Net.Security.dll
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.2.8004/tools/msbuild/iOS/Xamarin.Shared.targets(2256,3): error : Failed to codesign '/Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app': /Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app: code object is not signed at all
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.2.8004/tools/msbuild/iOS/Xamarin.Shared.targets(2256,3): error : In subcomponent: /Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app/System.Net.Security.dll
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.2.8004/tools/msbuild/iOS/Xamarin.Shared.targets(2256,3): error :
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.2.8004/tools/msbuild/iOS/Xamarin.Shared.targets(2256,3): error :
Done executing task "Codesign" -- FAILED.
Done building target "_CodesignAppBundle" in project "SE.Geospatial.Mobile.Viewer.csproj" -- FAILED.
Done building project "SE.Geospatial.Mobile.Viewer.csproj" -- FAILED.
Done executing task "MSBuild" -- FAILED. Done building target "DispatchToInnerBuilds" in project "SE.Geospatial.Mobile.Viewer.csproj" -- FAILED.
Done building project "SE.Geospatial.Mobile.Viewer.csproj" -- FAILED.
@mirceamuresanse I've seen something like this before, but I don't think we ever figured out what the problem was before it went away for the customer in question, so I don't know what's happening.
So can you provide the following to try to track:
-
A complete list of the files in the app bundle. You can do this by executing something like this from a terminal:
ls -laR /Users/mirceamuresan/Documents/SEMaui/SE.Geospatial.Mobile.Viewer/SE.Geospatial.Mobile.Viewer/bin/Debug/net8.0-ios/ios-arm64/SE.Geospatial.Mobile.Viewer.app > filelist.txt
and then attaching the
filelist.txt
file here. -
Your csproj (all of them if you have multiple projects in the solution).
- Here it is.
- When you say all of the projects, are you talking about the list of projects? Here is the full list (main projects is first), the rest of them are just dependencies for the first project:
- SE.Geospatial.Mobile.Viewer
- SE.Geospatial.Designer.ComponentModel.Rendering
- SE.Geospatial.Mobile.Viewer.Kernel
- SE.Geospatial.XamForms.Common
Let me know if you need anything else in order to debug this issue. Right now I'm stuck for the last month or so. I tried all that I could find on the internet, but nothing helped. On top of this issue, deploying the app to a Simulator doesn't work due to this issue: https://github.com/dotnet/maui/issues/15144 These 2 issues blocks me to continue my work with Maui on iOS
@mirceamuresanse I see you have a Resources/Images/moveicon.png
file in the app bundle, can you try removing that png file from your csproj to see if that fixes it? IIRC having a Resources
subfolder in the app bundle can cause signing trouble.
Good news. After removing the MoveIcon from the project resources and changed all the images in the Resources\Images folder to Maui Image, Embedded Resources, the app is finally compiling. No more Codesigning errors.
So apparently, as rule of thumb, for iOS ONLY rules:
- no embedded resources of type file, image and so on, in the project Properties folder
- no image should be set as EmbeddedResource in the Resources\Images folder
This is weird, and definitely a bug, as it works fine in Windows and Android platforms.
I'm not sure which Microsoft team should this bug be addressed by, as I got so dizzy already getting moved from one team to another :-)
That's great! I'll close this then.
FWIW I've filed an issue to see if we can at least show a better error message here (https://github.com/xamarin/xamarin-macios/issues/20135).
I recently moved my SQLite file from the Raw folder with no compile type to EmbeddedResource for Android and saw no issues there and felt that was an elegant solution. when I tried this on iOS I started seeing this issue. What is the best way to load an SQLite file for MAUI that works well with both platforms?