我们的应用程序使用CoreNFC扫描NFC标签,如果不支持NFC,则可以使用QR。这工作得很好,我们能够在模拟器中运行该应用程序以进行(ui)测试。
直到Xcode12/iOS14 GM生成为止。在iOS13(或更低版本)中,在模拟器上运行它不会有任何问题。
但是在Xcode12在iOS14模拟器iPhone11上运行它时,我们将得到以下结果:
dyld: launch, loading dependent libraries
DYLD_SHARED_CACHE_DIR=/Users/xxx/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/xxx/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
模拟器崩溃对我来说很有意义,因为模拟器无法扫描NFC标签,但这是我所做的:#if canImport(CoreNFC)
放在import CoreNFC
周围,它是底层的NFC代码。 -weak_framework "CoreNFC"
添加到“其他链接器标志”构 build 置显然,通过注释掉代码部分并删除框架链接来删除对CoreNFC框架的任何引用,会使崩溃消失。但这不是一个合适的选择。
在iOS13模拟器“设备”上从Xcode12运行它的效果很好。所以我似乎无法弄清楚是什么原因导致了这种现象
最佳答案
这对我有用。 💯
如果您想避免为单个文件下载11.25GB Xcode 12.2 beta的麻烦。我有文件要分享。
您可以执行以下命令来下载并将其放置在Xcode包中:
sudo curl https://storage.googleapis.com/mobile-simulator-build/libnfshared.dylib -o /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libnfshared.dylib
希望对你有帮助关于ios - Xcode12 CoreNFC模拟器库未加载,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63915728/