SwiftUI preview issue (have 'x86_64', need 'arm6) on Xcode 14

Hi,

we recently starting moving toSwiftUI and unable to preview. we are getting a below crash.

App is running using Rosetta on M1 Mac Xcode 14 iOS 16

All we did is to enable swift previews in build settings.

Crash report for SwiftUI preview:

PotentialCrashError: Update failed

XCPreviewAgent may have crashed. Check ~/Library/Logs/DiagnosticReports for any crash logs from your application.

==================================

|  RemoteHumanReadableError

|  

|  LoadingError: failed to load library at path "/Users/vamsianguluru/Library/Developer/Xcode/DerivedData/BapineMobile-fiuoxganfwfeexgxiewzascqsimr/Build/Intermediates.noindex/Previews/BapineApp/Products/Debug-iphonesimulator/BiometricLogin.framework/BiometricLogin": Optional(dlopen(/Users/vamsianguluru/Library/Developer/Xcode/DerivedData/BapineMobile-fiuoxganfwfeexgxiewzascqsimr/Build/Intermediates.noindex/Previews/BapineApp/Products/Debug-iphonesimulator/BiometricLogin.framework/BiometricLogin, 0x0000): tried: '/Users/vamsianguluru/Library/Developer/Xcode/DerivedData/BapineMobile-fiuoxganfwfeexgxiewzascqsimr/Build/Intermediates.noindex/Previews/BapineApp/Products/Debug-iphonesimulator/BiometricLogin.framework/BiometricLogin' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Users/vamsianguluru/Library/Developer/Xcode/DerivedData/BapineMobile-fiuoxganfwfeexgxiewzascqsimr/Build/Intermediates.noindex/Previews/BapineApp/Products/Debug-iphonesimulator/BiometricLogin.framework/BiometricLogin' (errno=2), '/Users/vamsianguluru/Library/Developer/Xcode/DerivedData/BapineMobile-fiuoxganfwfeexgxiewzascqsimr/Build/Intermediates.noindex/Previews/BapineApp/Products/Debug-iphonesimulator/BiometricLogin.framework/BiometricLogin' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/BiometricLogin.framework/BiometricLogin' (errno=2))

|  

|  ==================================

|  

|  |  MessageSendFailure: Message send failure for <ServiceMessage 17: update>

I'm facing the same issue here. We are using cocoapods and the component we want to preview is inside its own Pod. If we move it to the main project instead, it works. My guess is that we need to provide some additional build settings to make it work.

I was having a similar issue.

You can verify if this is your issue by pulling up Activity Monitor -> CPU -> Xcode and see if the "Kind" is Apple or Intel or follow the directions here

If it's Intel and you recently downloaded the latest version of Xcode on an M1 Mac you might be confused. This can be the case if you're launching using Rosetta (might have been something you set awhile ago and it persists when you replace the app downloaded from the web, can't comment on if the App Store version persists this or not).

To fix it Go to the directory containing the Xcode app, right click, get info and uncheck the "Open using Rosetta"

Unfortunately turning off rosetta isn't an option for us, we are using couple of third party libraries still don't support new M1. so we need to wait until they support.

I am currently facing the same issue and unchecking "opening with Rosetta" makes no difference.

Any news here ? 🙏

I ran into something similar with googles MLKit. This is a bit of a brute force for all pods but it gets the job done.

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        if config.name == 'Debug'
          config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
        end
      end
    end
  end
end
SwiftUI preview issue (have 'x86_64', need 'arm6) on Xcode 14
 
 
Q