The behavior is not altogether clear to me either. Since XCode does show a preview of images, it&#39;s fair to think that there&#39;s some sort of compile-time validation going on.<br><br>I would not be opposed to image and file literals changing their behavior so that when a user drags a file into the IDE the file contents are what are embedded via a data URL, rather than a file path. I do know that in a Playground, when you choose a file for a file literal, an alias is made to that file stored in a different folder for Playground resources, and it&#39;s that alias which is referenced in the resulting URL. This seems brittle to me.<br><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 19, 2016 at 13:55 David Sweeris &lt;<a href="mailto:davesweeris@mac.com">davesweeris@mac.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Dec 19, 2016, at 11:48 AM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="gmail_msg" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_-7793509295677051993Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg">On Mon, Dec 19, 2016 at 1:44 PM, David Sweeris via swift-evolution<span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span><span dir="ltr" class="gmail_msg">&lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt;</span><span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span>wrote:<br class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><span class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Dec 19, 2016, at 11:36 AM, David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-7793509295677051993m_-8872252158133612552Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Dec 19, 2016, at 11:21 AM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-7793509295677051993m_-8872252158133612552Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">```swift</span></div><div class="gmail_msg"><span style="font-family:Menlo;font-size:18px;font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">let</span><span style="font-family:Menlo;font-size:18px;font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span>x = #imageLiteral(resourceName:&quot;nothere.jpg&quot;)</span></div><div class="gmail_msg"><div style="margin:0px;font-size:18px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">print(x)</span></div></div><div style="margin:0px;font-size:18px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">```</span></div><div style="margin:0px;font-size:18px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg">This compiles. It crashes at runtime. I don&#39;t see why URLs should be any different.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">— E</div></div></div></blockquote><br class="gmail_msg"></div><div class="gmail_msg">They shouldn’t be. The print function can already handle things that aren’t `CustomStringConvertible`:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="gmail_msg"><div class="gmail_msg"><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)" class="gmail_msg"><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="gmail_msg">struct</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span>Foo {}</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span>x =<span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">Foo</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">()</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">Foo</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="gmail_msg">self</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)" class="gmail_msg">is</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span></span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">CustomStringConvertible</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,132,0)" class="gmail_msg">//says `false`</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(61,29,129)" class="gmail_msg">print</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">x</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">)<span class="m_-7793509295677051993Apple-converted-space gmail_msg"> </span></span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">//says `&quot;Foo()\n&quot;`</span></div></div></div></blockquote><div class="gmail_msg">so, IMHO, that’s a bug.</div></div></div></blockquote><br class="gmail_msg"></div></span><div class="gmail_msg">Oh, hey, wait a second… I didn’t catch the meaning of the resource name, and thought you meant it was crashing on the print statement. I still think it’s a bug, because the compiler should be able to check if the resource exists.</div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I think the point here is that what exists at compile time may not exist at runtime and vice versa, so while a warning might be elegant, it&#39;s not helpful for the compiler to refuse to proceed on the basis that the image does not yet exist. At the end of the day, an image literal hardcodes the path to an image, not the image itself. Whether it ought to is another kettle of fish.</div></div></div></div></div></blockquote><br class="gmail_msg"></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">Ah, ok, I didn’t realize that image literals weren’t actually created until runtime... In that case, I retract my statement that they shouldn&#39;t be any different, because they while they both may be called “literals&quot;, they use that word to mean to two quite different things.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">- Dave Sweeris</div><br class="gmail_msg"></div></blockquote></div>