My current project throws IBDesignable errors when using Interface builder on an apple Silicon based machine.. i tried excluding arm64 architecture for debugging, as well as some other hints i found on the internet, but no success at all..
the project builds fine on simulators and on real devices as well, but interface builder seems to be unable to draw those IB Designables correctly on arm64 based systems...weird.
hope someone knows which flag to set to correct this error..bc it's driving me crazy :/
Error:
"dlopen(MYAPP.app, 1): no suitable image found. Did find MYAPP.app: mach-o, but wrong architecture"
Hope you guys can help me out, i know it's part of early adopter issues, but this has to be solvable some way!?
Same here. Xcode 12.4, macOS 11.2 on M1 MacBook Air.
Normally, InterfaceBuilder try to find binaries from:
~/Library/Developer/Xcode/DerivedData/[...]/Build/Products/${Configuration}-iphonesimulator
but on M1 Mac, InterfaceBuilder find here:
~/Library/Developer/Xcode/DerivedData/[...]/Build/Products/${Configuration}-iphoneos
I guess this is Xcode's bug...
As you know, ${Configuration}-iphoneos
is for iOS devices. not for Simulator. and InterfaceBuilder really needs artifacts for iOS Simulator.
Here is simple and not-so-good solutions:
cd ~/Library/Developer/Xcode/DerivedData/[...]/Build/Products/
cp -r ${Configuration}-iphonesimulator ${Configuration}-iphoneos
finally I could fix @IBDesignable
previews. but I couldn't recommend this solution very much...
(Additional below)
I wrote workaround shellscript: https://gist.github.com/dnpp73/4f9c12ad96909355a39b99e22e42eb14
(One More Additional below)
seems fixed on Xcode 13 beta. nice work Apple Interface Builder Team!
Here's how I've fixed it on my project.
All my IBDesignable views are in their own framework, which has no other dependencies (I already had this setup)
In Build Settings, change "Build Active Architecture Only" to "No" for debug builds.
In Build Settings, change "Supported Platforms" to include "macxos" as well as the iOS defaults, for debug builds
Frustratingly, even though I don't have any dependencies on the framework with my IBDesignable views in, I was getting some errors related to dependencies of my app - which I fixed by this answer: https://stackoverflow.com/a/42765750 which disabled "ONLY_ACTIVE_ARCH" for my cocoapod dependences.
In your storyboard you'll need to trigger a rebuild by choosing Editor->Refresh all views.
Update
XCode 13 solved the issue on M1. No need for additional setup in Build settings.
Those solution were very hacky and could also be interfering with the project health. I suggest to anyone who tried those solution to discard any changes as soon as possible before being forgotten.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With