Reputation: 377
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!?
Upvotes: 24
Views: 11086
Reputation: 5053
This issue still persists for Xcode 15.2 on M2.
I managed to solve it by excluding x86_64.
Upvotes: 0
Reputation: 327
For Mac M1 you should install pods using this command.
arch -x86_64 pod install
This will solve this problem.
Upvotes: 0
Reputation: 176
Same issue on XCode 14.3
This is how I solved id:
arm64
x86_64
Upvotes: 6
Reputation: 2882
I had this problem on Xcode 14.0 with my M1 Mac. My code had some IBDesignables for UIView to expose cornerRadius, borderWidth, and borderColor as a UIView extension. Xcode was throwing up the warnings described in this thread, and warning of instability to render the storyboard too.
My app's deployTarget was 15.0, but after reading the comment above about how deployTarget needs to be at least 13.0 to solve the problem, I discovered that it was my cocoapods that could have a lower deployTarget!
So by adding the below to by Podfile to force all my Cocoapods to have at least iOS 13 deploy target, all those storyboard warnings about IBDesignables and general instability to render and archtecture mismatch went away! (I'm showing also ONLY_ACTIVE_ARCH force to NO but I already had this one in place - so though that wasn't the fix, per se, I think you'll want it too).
Don't forget to then delete your Pods dir (and DerivedData) and do a pod install.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
Upvotes: 2
Reputation: 2340
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.
Upvotes: 3
Reputation: 81
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!
Upvotes: 8
Reputation: 38475
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.
Upvotes: 8