Bug 29016 - Image assets (Image.imageset) from a referenced iOS library project overwrite image assets from the app project itself in the final app bundle.
Summary: Image assets (Image.imageset) from a referenced iOS library project overwrite...
Status: RESOLVED DUPLICATE of bug 8409
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild ()
Version: XI 8.9.x (iOS 8.3)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Jeffrey Stedfast
URL:
: 40127 ()
Depends on:
Blocks:
 
Reported: 2015-04-13 00:31 UTC by Jon Goldberger [MSFT]
Modified: 2016-04-05 23:55 UTC (History)
2 users (show)

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


Attachments
Test Project (2.19 MB, application/zip)
2015-04-13 00:31 UTC, Jon Goldberger [MSFT]
Details
Diagnostic Build Output (205.10 KB, text/plain)
2015-04-13 00:34 UTC, Jon Goldberger [MSFT]
Details


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:
Status:
RESOLVED DUPLICATE of bug 8409

Description Jon Goldberger [MSFT] 2015-04-13 00:31:46 UTC
Created attachment 10729 [details]
Test Project

## Description

If an iOS app project is referencing an iOS library project, and the library project has any Image sets, the Image sets in the in the library project will get copied to the app bundle but the Image sets in the App project will not be. 

## Steps to reproduce.

1. Open the attached test project.

2. Deploy the TestLibraryIMageAssets App project to a device or simulator.

Expected result: I should see two images, the beach image from the library project and the image of Einstein from the App project. 

Actual result: Only the beach image from the library project is shown.


## Note:

This issue was discovered after fixing the issue in bug https://bugzilla.xamarin.com/show_bug.cgi?id=28955 . 

## My environment

=== Xamarin Studio ===

Version 5.8.3 (build 1)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Runtime:
	Mono 3.12.1 ((detached/0849ec7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010003

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: 8.9.1.3 (Business Edition)
Hash: f7736a4
Branch: 
Build date: 2015-04-09 04:22:08-0400

=== Xamarin.Android ===

Version: 4.20.2.1 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 1.12.0.14 (Business Edition)

=== Build Information ===

Release ID: 508030001
Git revision: 6e8e725e0d689351901c2c70453bfa4ea25e293b
Build date: 2015-04-06 20:31:47-04
Xamarin addins: 051cd5f8c1b5dbfc87eaef80a74aec03f34c60a8

=== Operating System ===

Mac OS X 10.10.3
Darwin Jons-iMac.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 1 Jon Goldberger [MSFT] 2015-04-13 00:33:51 UTC
Additional note:

Delete the LittleBeach.imageset from the library project., clean and rebuild. You will see that now you the image from the app project is shown but not (obviously) the image from the library project.
Comment 2 Jon Goldberger [MSFT] 2015-04-13 00:34:21 UTC
Created attachment 10730 [details]
Diagnostic Build Output
Comment 3 Jeffrey Stedfast 2015-04-13 11:52:54 UTC
There's no way to "fix" this. One of them will always overwrite the other. The code in git master will have the main project overwrite the library assets (there was a bug report about xib files a few weeks back that I've already fixed).

*** This bug has been marked as a duplicate of bug 8409 ***
Comment 4 Jeffrey Stedfast 2015-04-13 11:53:55 UTC
This is the commit to Xamarin.iOS:

commit 7c655ff9aa945a123b08b72fdd6bb2d56b124e3f
Author: Jeffrey Stedfast <jeff@xamarin.com>
Date:   Wed Mar 11 14:37:05 2015 -0400

    [msbuild] unpacked resources from assemblies should not overwrite project resources
    
    Fixes bug #8409 (re-reported after migrating to Unified)
Comment 5 Jeffrey Stedfast 2015-04-13 11:55:17 UTC
There's no way to merge image assets from 2 different projects. It's just not doable. I suggest you don't name your image assets such that they conflict with one another.
Comment 6 Jon Goldberger [MSFT] 2015-04-13 21:36:33 UTC
I thought this might be the case, but naming does not seem to be the issue. In the test project, the *.imageset folders did have different names and the image files in the image set were differently named. I tried changing the name of the Images.xcassets folder in one of the projects, but the results were the same. The point about naming seems to more relevant to resources that are _not_  an image set. Image sets seem to get compiled to an Asset.car file in the app bundle. This name seems to remain the same regardless of what you name the Images.xcasset folder or the Image Set subfolders.

I mention this mainly for the benefit of others so they don't get the impression that this issue can be avoided by naming their image sets differently. 

So the bottom line seems to be that you can only use image sets in the app project or in a referenced iOS library project, not both. If you have them in both, then the Image sets from the library project will be in the final app bundle rather than the image sets in the app project.

Images (or other resources) with build action BundleResource do not have this issue. As long as they are named differently resources from both the library project and the app project will end up in the final app bundle.
Comment 7 Jeffrey Stedfast 2015-04-14 07:40:17 UTC
Oh, right, Apple's insistence that the output be called Assets.car. Gah.

I'd add code to name them the same as their original asset name, but I doubt it would work (i.e. Images.xcassets -> Images.car).

I guess this means you just can't do it :-\

Does it work with Xcode apps?
Comment 8 Jon Goldberger [MSFT] 2016-04-05 21:16:21 UTC
*** Bug 40127 has been marked as a duplicate of this bug. ***
Comment 9 Jon Goldberger [MSFT] 2016-04-05 23:55:23 UTC
So, I could not get this to work with an XCode app following this guide fro using resources in an iOS Library project:
http://www.galloway.me.uk/tutorials/ios-library-with-resources/

So we will have to go with this being an unsupported scenario at this point.