For me, I was building on the Apple M2 chip. After several hours of attempts, I found that I could successfully build on a real device, but the build failed on the simulator. When I commented out the following code, the build also succeeded on the simulator.
# https://stackoverflow.com/questions/72344149/how-to-solve-xcode-build-error-undefined-symbols-for-architecture-x86-64
# Comment this line due to a build failure on Apple M2 Pro with an error: "VisionCamera.modulemap not found."
# config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"
close Xcode
rm -rf ~/Library/Developer/Xcode/DerivedData/* && rm -rf ~/Library/Caches/org.swift.swiftpm
start Xcode