我们的应用程序使用 CoreNFC 来扫描 NFC 标签,如果不支持 NFC,您可以使用 QR。这工作得很好,我们能够在模拟器中运行该应用程序以进行 (ui) 测试。
直到 Xcode12 / iOS14 GM 构建。在 iOS13(或更低版本)中,我们在模拟器上运行它不会有任何问题。
但是在 iOS14 模拟器 iPhone11 上运行它的 Xcode12 中,我们会得到以下结果:
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/xxx-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
Run Code Online (Sandbox Code Playgroud)
模拟器崩溃对我来说很有意义,因为模拟器无法扫描 NFC 标签,但这就是我所做的:
#if canImport(CoreNFC)周围import CoreNFC …我CoreNFC sample在Xcode 9.0 beta 2中运行代码时遇到此错误并且应用程序崩溃
dyld: Library not loaded: @rpath/CoreNFC.framework/CoreNFC
Referenced from: /var/containers/Bundle/Application/2837709C-C852-4811-B696-38F2725554D4/iOS-11-by-Examples.app/iOS-11-by-Examples
Reason: image not found
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
Core NFC可以在iPad上运行吗?
总而言之,iPad确实有NFC芯片,但Core NFC文档并没有说它支持它.
注意
iPhone 7和iPhone 7 Plus支持读取NFC NDEF标签.
在模拟器上运行此iOS11-NFC示例将始终Feature not supported在所有设备上运行.