2

I'm in the middle of some "Proof of Concept" project regarding Cocoapods, .xcassets, Swift 3, "cross-project loading images" (from pod bundles onto the main storyboard), etc...

My main problem right now is "images living inside an imported .xcasset (via pod install/update) are selectable and appear inside Interface Builder main project storyboard, but won't show in the simulator".

In runtime, the simulator running my main app yields something like this: Could not load the "cx_green_tick" image referenced from a nib in the bundle with identifier "MyCompany.ios-appbase" when it tries to render the selected image. And then nothing appears on the expected placeholder space, just empty space.

MyCompany.ios-appbase is the bundle name of my main app.

cx_green_tick is the logical name of some image resource happily living inside my "Commons" imported project Media.xcasset folder. This image resource consists of 3 proper .png files with their @1x, @2x, @3x names, etc...

My Commons Pod Project (the one containing the .xcasset files/folders I want to use in my main project) has a .podspec file with the following resources definition (among many other things):

s.resources = [ 'Commons/**/*.{png,jpeg,jpg,storyboard,xib,ttf,otf}' , 'Commons/**/*.{xcassets, imageset, json}' ]

Once I'm in the root folder of my main project, I just type "pod update/install" and I can see how the different pods I defined in my main app Podfile start to download and get perfectly stored into the expected Pods folder of my main project.

Then, inside Xcode, I can see how inside the Pods/Commons/Media.xcassets container there's the expected cx_green_tick image resource, with its 3 proper resolutions.

Then I change onto my main app Main.storyboard and select the cx_green_tick image resource to be used onto a UIImageView placeholder. Whenever I do it, I can see how this green tick image appears inside IB. But if I run the simulator, this image doesn't appear on its placeholder.

I'm using Swift 3.0, XCode 8, deployment target is iOS 9. All my involved Podfiles have the use_frameworks! keyword/line active.

I've REALLY been googling this for many hours (yesterday and today) but I can't see any hint on how to do it without having to do the image load by hand, programmatically. (In case it's something achievable, which I'm not really sure after all this)

BTW: If I load this image programmatically, explicitly selecting the bundle where the image resource lives inside Media.xcassets, the image appears without any problem in the simulator.

That could be a partial solution, but our main goal was not having to perform image loading by hand. Specially when (apparently) IB shows this image onto its image_name resources combo list on the top part of the screen for the UIImageView placeholder.

Any hint?

(If something is unclear, please ask and I'll try to reword it somehow )

Greetings and thanks in advance.

Isaac
  • 1,794
  • 4
  • 21
  • 41

0 Answers0