Swift Package IBDesignable Views not rendering in Interface Builder

Does anyone know why I get the following error in Interface Builder when I try to refresh a view created in a Swift Package?

Build Failed ❌ The built product "Users/*MyName/Library/Developer/Xcode/DeriverData/*PackageBuildDirectory/Build/Intermediates.noIndex/IBDesignables/Products/Debug-iphonesimulator/*PackageName" does not exist in the file system. Make sure your built products contains either an application or a framework product."

I can trigger this warning simply by creating a new package, marking a blank UIView as IBDesignable, and bringing it onto a storyboard in the same package. I saw someone suggest that this was happening when they had their project directory on the macOS Desktop which was syncing to iCloud, but my project is on the local HD.

I also have a similar issue with Images. I can add an image to my assets catalog, create a UIImageView in Interface Builder, and select it in the image drop-down menu. But when I run the application I get the error: Could not load the "ImageName" image referenced from a nib in the bundle with identifier "com.myCompany.MyApp" It's so strange that Xcode is able to show me the image in Interface Builder, but then fail to retrieve it at runtime. I can load the asset just fine from code.

I posted this issue on Stackoverflow here https://stackoverflow.com/questions/72155202/assets-from-swift-package-shows-runtime-warning-could-not-load-image-reference?noredirect=1#comment127492702_72155202

My other option was to build this as a Framework project ("old school") but I've never actually attempted to do this. I'm a bit concerned about binary size since there are numerous image assets. Im also not sure how git work with embedded frameworks. Would be great to have this app as one repository.

Any help would be greatly appreciated.

:-)

Using Xcode 13.2.1

I have noticed that IBDesignable have a whimsical behaviour in Xcode.

It may not work for some time and suddenly worked again. And without any use of iCloud.

The best I have found, but does not work all time:

  • Build clean folder (in case)
  • compile and run
  • quit Xcode
  • reopen project.
Swift Package IBDesignable Views not rendering in Interface Builder
 
 
Q