iOS14 simulator crashes with CoreNFC framework

Our app uses CoreNFC to scan NFC tags or you can use QR if NFC is not supported. This worked pretty well and we were able to run the app in the simulator for (ui) testing purposes.
Until Xcode12 / iOS14 GM builds. In iOS13 (or lower) we wouldn't have any issues running it on a simulator.

But in Xcode12 running it on a iOS14 simulator iPhone11 we would get the following:

Code Block
dyld: launch, loading dependent libraries
DYLD_SHARED_CACHE_DIR=/Users/***/Library/Developer/CoreSimulator/Caches/dyld/19G73/com.apple.CoreSimulator.SimRuntime.iOS-14-0.18A372
DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
DYLD_LIBRARY_PATH=/Users/***/Library/Developer/Xcode/DerivedData/BeeSafe-awnlestrbvesqqbynrhmluzhbcsc/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSi
dyld: Library not loaded: /usr/lib/libnfshared.dylib
Referenced from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreNFC.framework/CoreNFC
Reason: no suitable image found. Did find:
/usr/lib/libnfshared.dylib: mach-o, but not built for platform iOS-sim


That the simulator crashes makes sense to me, since the simulator can't scan NFC tags, but this is what I've done:
  • I already linked to the CoreNFC framework and made it optional.

  • Put #if canImport(CoreNFC) around import CoreNFC and it's underlying NFC code.

  • Cleaning the build folder and deleting derived data.

  • Created an empty Xcode12 project: https://github.com/basvankuijck/CoreNFCCrashProject, same result.

  • Removed all the listed simulators and re-added one

  • Added -weak_framework "CoreNFC" to the Other Linker Flags build setting

Obviously removing any references to the CoreNFC framework by either commenting out code sections and removing the framework link, makes the crash disappear. But that's not a suitable option.

Running it from Xcode12 on an iOS13 simulator 'device' works perfectly. So I can't seem to figure out what is causing this behavior

Replies

I am experiencing this same issue as well. In addition to the workaround by using iOS 13 simulators, It does seem that running app on a physical device does work; however, that is not a viable solution.
Have them exact same issue this morning. Hopefully it's just a bug in Xcode Simulators and Apple gets a fix out soon.
We're having excactly the same problem
Post not yet marked as solved Up vote reply of mofe Down vote reply of mofe
Experiencing the same well-documented issue with XCode 12 GM on iOS 14 simulators. Compiles without any problems on iOS 13.x simulators but won't run on iOS 14 in a simulator.
I can confirm that the listed workarounds above do not work.
For me, it still worked with XCode 12 Beta 6 iOS14 simulators and now it stopped with the GM simulators. Maybe this helps in identifying the problem.
I have this problem too: in simulator 14.0 crashes while on iPhone with iOS 14.0 works fine... so, a simulator issue
We're having exactly the same problem!!!
I experienced the same problem today using Xcode 12.2 beta (12B5018i). FB8725004
We've got the same error.
Found a radar reporting this error: openradar.appspot.com/FB8699389
Still an issue in the final Xcode12 version. Tried re-creating simulators as was suggested but still no luck. Such a basic thing... yet no one at Apple tested something like this it seems. tsk tsk
I wondered why my SwiftUI previews had stopped working while working on an app. Was driving me mad trying to remove bits of code to see where the issue was coming from. But yes it's as soon as any CoreNFC code is referenced. Crash!
Same issue here. Weird thing is that dependency that uses CoreNFC installed via CocoaPods works. But breaks when I try to scan nfc
Same here +1
Updated to Xcode 12.0.1, problem NOT solved. 😂

One of the most weird bug I'v ever met on Xcode.
Same problem. :(