Using @IBDesignable with Xcode 14.2

I have this issue whenever I add @IBDesignable to the class of a custom view I'm creating, and add that custom view to a UIViewController in Main.storyboard (i.e the interface builder).

The custom view does not render in Main.storyboard, and I get the error "Failed to launch designables agent becaise tool was shutting down. Check the console for a more detailed description and please file a bug report at feedbackassistant.apple.com." in the attributes inspector of the custom view.

I have tried all the solutions I could find on the net, and followed all the tutorials I could find for how to create a custom view. I even tried copy + paste code of custom views that others claimed was what worked for them, but the issue still remains. I'm not sure what the issue exactly is.

Among the solutions I tried:

  • Adding both required init?(coder: NSCoder) and override init(frame: CGRect), and adding calls for their super functions
  • Adding override func awakeFromNib() and override func prepareForInterfaceBuilder(), as well as calls to their super functions
  • Deleting any variables that load a UIColor from the assets, because some mentioned that not specifying the correct bundle caused the issue, and I wanted to test if removing the calls (to kill the root) would resolve the problem, but it didn't
  • Adding an @IBInspectable attribute, because someone mentioned that @IBDesignable had to be accompanied by one at least
  • Using Xib instead of generating the views from the code, and specifying the bundle to be used to get the views explicitly (instead of leaving it as the main bundle)
  • Customizing the appearance of the view, including size and constraints, in prepareForInterfaceBuilder(), because someone mentioned that getting the views from the xib doesn't mean they're properly configured to be displayed on the storyboard
  • Converting from Cocoapads to SPM, because it was a known issue with cocoapads that I couldn't resolve no matter what I did
  • Deleting the project's Derived Data folder, cleaning the build folder, building the project and refreshing all views
  • Adding $(FRAMEWORK_SEARCH_PATHS) to the Runpath Search Paths in the build target's settings

For debugging, I tried the following:

  • Debugging the view hierarchy, but I got nothing
  • Debugging the selected view, while I was selecting the custom view in Main.storyboard, and I also got nothing
  • Checking the Console.app for any crash reports, but I found no related crash reports
  • Checking ~/Library/Logs/DiagnosticReports for any related crashes or otherwise logs, but I didn't find anything as well

All I can conclude is that this somehow and/or for some reason not considered a crash (even if the warning I get in the issue navigator specifies that the "agent crashed") and thus not recorded in the logs.

I know that this doesn't really stop my app from working and I can run it just fine, with or without the @IBDesignable annotation, but designing my custom view would take significantly longer that way, as I would have to re-launch the app every time I make even the slightest modification to the code.

Can someone help me if you managed to get this working well on the latest versions of Xcode?

Just a minor point, don't bother converting to SPM. SPM just does not work well with interface builder. I managed to finally run SPM build tool plugins with Xcode 14.2. You know what? Interface builder ignores them. It seems the Interface Builder compile job is not maintained much any more.

Using @IBDesignable with Xcode 14.2
 
 
Q