Search code examples
ios-simulatorapple-m1sqlite.swift

SQLite.swift and M1 chip and simulator


I have a project where I use SQLite.swift. Recently I got a MacBook Pro with a M1 chip. After that the project runs fine on a device but when I try to run on simulator I get this error message from Xcode:

Could not find module 'SQLite' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator.

I use cocoa pods for adding SQLite.swift to my project. I tried to move it to SPM but the error is still present. After searching for this error I found a work around: Open Xcode with this option: Open using Rosetta, but this to me seems as a hack.

Can this be fixed somehow at the SQLite.swift level?

  • SQLite.swift version 0.13.0
  • Xcode 13.2.1

Thank you.


Solution

  • Your project is trying to build for x86_64 which will make it run under Rosetta translation. SQLite.swift is building correctly for arm64 and will run natively on the M1 in Simulator. Due to the mis-match the overall build is failing. You are absolutely correct that opening Xcode under Rosetta is a hack and you're paying a memory + performance penalty by doing that.

    I recommend checking your ARCHS and EXCLUDED_ARCHS build settings, along with your other dependencies. If you have a binary dependency that hasn't updated to support Simulator arm64 that might be causing Cocoapods to force the architecture to x86_64. Alternately you may have set those build settings long ago and never realized it.

    The correct way to set this up today is:

    1. Never touch ARCHS or SUPPORTED_ARCHS
    2. Unless you have a binary dependency that hasn't updated don't set EXCLUDED_ARCHS either

    By default Xcode will build for Simulator using your Mac's native architecture. In Debug builds it only builds that one architecture, for Release it builds all supported architectures (which may vary depending on what your Run Destination is). In this respect simulators are not any different from device builds.