xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.42k stars 507 forks source link

Nuget reference causes App's iOS Asset Catalogue to be overwritten with the Assets.car from the Nuget package #6095

Open vsfeedback opened 5 years ago

vsfeedback commented 5 years ago

Steps to Reproduce

  1. Create a new iOS project. Set it up to submit to app store and submit blank. It should pass.
  2. Add a reference to ImageCropper.Forms nuget
  3. Errors in submission due to asset catalog error:

image

Expected Behavior

Arbitrary nuget shouldn't cause us to generate the asset catalog incorrectly.

Actual Behavior

It does.

Environment

https://gist.github.com/chamons/ae41c1ee5f59a49b853dcf6e87ec3c08

Build Logs

https://gist.github.com/chamons/4955721fbc5eec31c896258b59c9ff29

chamons commented 5 years ago

This is the text from the original developer community post:

VSF_TYPE_MARKDOWNI have a Xamarin Forms app with an iOS build. The app builds and submits successfully to the Apple App Store without any issue, until I add a reference to this nuget package: https://www.nuget.org/packages/ImageCropper.Forms.Fix/ https://github.com/stormlion227/ImageCropper.Forms

When this package is added, builds submitted to the app store fail with an error stating that the build doesn't include required icon files. However, the same icon files that were accepted previously, in the same asset catalogue that worked previously, are included in the new build.

According to this github issue: https://github.com/stormlion227/ImageCropper.Forms/issues/16 for some reason, including this package causes the iOS asset catalogues to not be compiled correctly, and submitting a clean build with this package referenced will fail. However, building the iOS project again (not a rebuild this time) does cause the asset catalogue to be built correctly, and allows the build to upload to the app store successfully.

Referencing a nuget package shouldn't cause the asset catalogue compile to fail.

This issue has been moved from https://developercommunity.visualstudio.com/content/problem/550021/nuget-reference-causes-ios-asset-catalogue-to-not.html VSTS ticketId: 857814 These are the original issue comments:

Visual Studio Feedback System on 4/29/2019, 02:38 AM (22 days ago):

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Emanuel Fernandez Dell'Oca [MSFT] on 4/29/2019, 09:10 AM (22 days ago):

Hi!

Could you provide Detailed build outputs for both rebuild and a build after that? You can change the build output verbosity from Tools -> Options -> Projects and Solutions -> Build and Run -> MSBuild project build output verbosity.


To workaround this you are building the project right after rebuilding it without making any change in between both builds, right?


Thanks for reporting!


Use these instructions to respond to More Info requests from Visual Studio: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio-2017?view=vs-2017#when-further-information-is-needed-need-more-info .

Dhiren Sham on 5/9/2019, 02:47 AM (12 days ago): Hi Emanuel

Sorry for the delayed response. I submitted a new build yesterday and am attaching the logs. I'm building on VS4M Community version 8.0.5 with Xamarin.Mac 5.6.0.2. Xcode 10.2.1.

I first did a complete Rebuild of the iOS project, and tried to submit, which failed as I expected. I then did a number of subsequent builds, either just doing another build without modifying code or by adding a blank line in one of the cs files to introduce a zero-effect change. None of these builds were accepted by the App Store either, with the same error (missing icon). Finally, I didn't make any changes to the code, but I edited the Info.Plist and changed the Build version number, did a build, and that one was accepted.

So it appears that the asset catalogue gets broken on a rebuild, but editing the info.plist triggers it to be recompiled correctly.

Please let me know if I can provide more information. I'll update this issue if I identify any additional insight that might help. Emanuel Fernandez Dell'Oca [MSFT] on 5/9/2019, 10:01 AM (12 days ago):

Thanks for those build outputs and the detailed steps! 


Could you also attach the exact error you get from Apple? At a glance, I could not find anything suspicious on those outputs, but maybe the error will give us a hint.

Dhiren Sham on 5/13/2019, 09:33 AM (8 days ago): Hi Emanuel

The error I get is:
ERROR ITMS-90022: "Missing required icon file. The bundle does not contain an app icon for iPhone / iPod Touch of exactly '120x120' pixels, in .png format for iOS versions >= 10.0."
There is also a warning:
WARNING ITMS-90704: "Missing App Store Icon. iOS Apps must include a 1024x1024px App Store Icon in PNG format. Without providing the icon in the Asset Catalog or via App Store Connect, apps cannot be submitted for App Review or Beta App Review. Refer to https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/app-icon/ for more information."

I'm uploading a new set of build logs, without the intermediate builds that failed - this time it's the initial rebuild that failed, and then the build that succeeded immediately after.
rebuild.txt - build log of the rebuild - this failed app store submission
loader-rebuild.txt - application loader log for the failed upload
rebuild.ipa - ipa of the failed submission

I then only modified the build version in info.plist, and performed a build. This was accepted by the app store.
build.txt - build log
build.ipa - ipa of the accepted submission.

Please let me know if you need any additional information. Emanuel Fernandez Dell'Oca [MSFT] on 5/9/2019, 10:03 AM (12 days ago):

One more question, what version of Xamarin.iOS are you using?

Thanks!

Dhiren Sham on 5/13/2019, 09:37 AM (8 days ago): Sorry, forgot the versions:
VS for Mac Community 8.0.5 (build 9)
Xcode 10.2.1 (14490.122) Build 10E1001
Xamarin.iOS 12.8.0.2 (VS community) Branch d16-0 Hash f2248ae6
Mac OS X 10.14.4 Emanuel Fernandez Dell'Oca [MSFT] on 5/21/2019, 08:27 AM (5 hours ago):

Hi Dhiren,


Thanks to all the logs and IPA files you've attached I was able to find the root cause of this issue, the assembly Stormlion.ImageCropper.iOS.dll contains an Assets.car as an embedded resource, and as part of the build we copy it to the app bundle which ends up overriding your Assets.car. This file is a compiled Asset Catalog.


I'm not sure why that reference is including a compile Asset catalog as an embedded resource, but definitely we'll need to fix the iOS build to avoid overriding your assets. I'm directing this ticket to the Xamarin iOS team so they can fix this issue.


Thanks for your help!

These are the original issue solutions: (no solutions)

dlbroadfoot commented 5 years ago

This seems to be the same issue as https://xamarin.github.io/bugzilla-archives/34/34762/bug.html and also discussed here: https://forums.xamarin.com/discussion/63222/class-library-asset-catalogs-overriding-app-asset-catalogs which didn't have a resolution

Also related to #5755

kberawala commented 4 years ago

Is there any temp solution/workaround for this ? any idea when this will be fixed ?

westito commented 4 years ago

I have the same issue, I use "ImageCropper.Forms" too, but not the NuGet one (I downloaded and added to project, because it is crashing on Android 28. Need to update the ImageCropperAndroid lib. The original Xamarin lib not maintained anymore). Whatever, the workaround is: Rename the ImageAsset catalog and reselect in Info.plist. This solves the problem for the next build. I do it before every AppStore release build.

westito commented 4 years ago

As of https://xamarin.github.io/bugzilla-archives/34/34762/bug.html and https://forums.xamarin.com/discussion/63222/class-library-asset-catalogs-overriding-app-asset-catalogs Xamarin.Forms.iOS can't handle xcassets in class libraries. There is an unecessary "Media.xcassets" in ImageCropper.Forms library that causes the problem. After I removed, everything works fine! You can find the updated library on my repo: https://github.com/westito/ImageCropper.Forms Download in your project and reference corresponding projects. I will upload to NuGet sometime.

westito commented 4 years ago

And here it is: You can use as NuGet package. Just import! https://www.nuget.org/packages/ImageCropper.Forms.Fix.v3/

kberawala commented 4 years ago

@westito

As of https://xamarin.github.io/bugzilla-archives/34/34762/bug.html and https://forums.xamarin.com/discussion/63222/class-library-asset-catalogs-overriding-app-asset-catalogs Xamarin.Forms.iOS can't handle xcassets in class libraries. There is an unecessary "Media.xcassets" in ImageCropper.Forms library that causes the problem. After I removed, everything works fine! You can find the updated library on my repo: https://github.com/westito/ImageCropper.Forms Download in your project and reference corresponding projects. I will upload to NuGet sometime.

Thanks heaps

3esam commented 4 years ago

@westito thaanks i've downloaded the source code and it works like a charm!

And here it is: You can use as NuGet package. Just import! https://www.nuget.org/packages/ImageCropper.Forms.Fix.v3/

However i've failed trying the nuget package as it requires dotnetstandard v2.1, still not supported by xamarin. is it only me ?

mackayn commented 4 years ago

The main ImageCropper.Forms package says this issue is resolved....it isn't, spent days looking into this issue.

The worrying thing is, if you build the ipa ad-hoc locally and then deploy to a device via XCode the app icon appears.

If you build in devops and deploy via appcenter, the icon when appears when installing the app but when the side loading is complete, the icon disappears.

Remove image cropper and the issue goes away,t he Fix.V3 (which has a different API) doesn't fix the issue in DevOps builds

ryanlpoconnell commented 4 years ago

Same problem icon missing in iOS - ImageCropper.Forms nuget package causes the problem but we have had the main nuget package installed for years and it's been fine.

Now we can't build locally or via DevOps or App Center to get the icon working.

We are currently unable to release a new version of our App because of this.

Can someone at Xamarin please provide an update?

michael-hll commented 3 years ago

I have the same issue here, studdenly it doen't work for the publishing, after remoing ImageCropper.Forms reference then the publishing works fine. but my app doesn't work. So any work around?

kberawala commented 3 years ago

I moved to syncfusion for xamarin.

michael-hll commented 3 years ago

Thanks @chamons, from his comments I found this work around:

  1. First rebuild of your iOS project, the appstore will reject it with missing icons;
  2. Then just modify the info.plist (eg: just increasing the build number), then build the ios project again( remember not rebuild, but just build)
  3. publish again, apple store accept it.
mackayn commented 3 years ago

I moved to syncfusion for xamarin.

Same, it was a lot less grief in the long run.

jgold6 commented 2 years ago

This issue still exists.

Another possible workaround is a after build step, since what is happening is the nugets Assets.car is being copied into the app bundle AFTER the apps compiled Assets.car file, so the app's is overwritten.

So I was able to resolve this with an After Build custom command (this is for Visual Studio for Mac): Command: cp obj/iPhone/Release/actool/bundle/Assets.car bin/iPhone/Release/<AppBunbdleName>.app/Assets.car Working Directory:
$(ProjectDirectory)

UPDATE: As noted below, this copy command happens after signing, so the signature becomes invalid. It may be possible to use this mitigation if the .app/.ipa is resigned after the copy command?

But what it does show is that the nuget package is not causing the asset compile to fail, it just causes app's Assets.car file to be overwritten, presumably with one for the nuget package? Looking at the ImageCropper.Forms source code, I do see an empty image set named "sample1" and when I decompiled the Assets.car when this issue occurs, that is what I see , an image called "sample1".

harre096 commented 2 years ago

I'm not having success with the AfterBuild command as a mitigation. The IPA creation happens as part of the build so we'd have to figure out some trigger to run after the core build but before the IPA arcihive step. However michael-hll's workaround really does seem to work.

We haven't pinned down the RCA for us yet but presumably it is some nuget package then. Absolutely pumped to have a workaround though, this has been plauging our team for a long time.

rolfbjarne commented 1 year ago

This sounds like a duplicate of https://github.com/xamarin/xamarin-macios/issues/5755.