Named Colors are duplicated in Storyboard file

Originator:guillaume.algis
Number:rdar://35172913 Date Originated:25-oct.-2017 04:04 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 9.0.1 (9A1004), macOS 10.12.6 (16G29)
Classification:Other Bug Reproducible:I didn't try
 
Summary:
This happened a few time since I started using Named Colors [1] in my Storyboard in Xcode 9: I make modifications, tweak colors here and there (using named colors) and save. When opening the .storyboard file after that, Xcode prompts a warning dialog saying it found some inconsistency in the file.

Each time its "Multiple resources have the same name: <Color name here> (See attached screenshot).

And checking in a text editor, the file do have the namedColor tag for the color duplicated. Here a diff after Xcode "repaired" the storyboard file:

    --- a/EMR/Views/Patient Record/Consultation/Prescription/Prescription.storyboard
    +++ b/EMR/Views/Patient Record/Consultation/Prescription/Prescription.storyboard
    @@ -1898,9 +1898,6 @@
             <namedColor name="Lighter Grey">
                 <color red="0.94901960784313721" green="0.94901960784313721" blue="0.94901960784313721" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
             </namedColor>
    -        <namedColor name="Lighter Grey">
    -            <color red="0.94901960784313721" green="0.94901960784313721" blue="0.94901960784313721" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
    -        </namedColor>
             <namedColor name="Tonic Orange">
                 <color red="0.92941176470588238" green="0.47058823529411764" blue="0.23921568627450981" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
             </namedColor>

You can see the color "Lighter Grey" was represented twice in the same file hence the error.

[1] http://martiancraft.com/blog/2017/06/xcode9-assets/#color-assets

Steps to Reproduce:
I actually have no idea why this occurs, this seems random but happened a few times since I started using Xcode 9 / Named Colors.

Expected Results:
Xcode saves the Named Colors reference just once per color in the .storyboard file.

Actual Results:
Xcode saves the same colors multiple times in the same file, making it complain the next time it'll parse the file.

Version:
Xcode 9.0.1 (9A1004), macOS 10.12.6 (16G29)

Notes:
Attached are a screenshot of the error, and one of the storyboards affected (not the most lightweight of my app, sorry ^^).

Also, I'm sure it's not caused by a SCM operation, I'm currently working alone on this project and never had a merge on the branch I got the error on :)

Comments

I'm having the same issue with Xcode 10.2.1 (10E1001)

This happens to me too I also have no idea what is causing it other than using Named Colors.... I feels very similar to the bug in XCode where XCode will randomly dork with your storyboard files changing things like ToolsVersion and floating point coordinates.

I am using XCode Version 9.3 (9E145)


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!