ios - Xcode12 CoreNFC 模拟器库未加载

标签 ios swift ios14 xcode12 core-nfc

我们的应用程序使用 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
模拟器崩溃对我来说很有意义,因为模拟器无法扫描 NFC 标签,但这就是我所做的:
  • 我已经链接到 CoreNFC 框架并将其设为可选,如下所述:Xcode 10, Swift 4 app with CoreNFC crashes in review on iOS 12
  • #if canImport(CoreNFC)附近import CoreNFC它是底层的 NFC 代码。
  • 清理构建文件夹并删除派生数据。
  • 创建了一个空的 Xcode12 项目:https://github.com/basvankuijck/CoreNFCCrashProject ,同样的结果。
  • 删除了所有列出的模拟器并重新添加了一个
  • 已添加 -weak_framework "CoreNFC"到其他链接器标志build设置

  • 显然,通过注释掉代码部分和删除框架链接来删除对 CoreNFC 框架的任何引用,会使崩溃消失。但这不是一个合适的选择。
    在 iOS13 模拟器“设备”上从 Xcode12 运行它可以完美运行。所以我似乎无法弄清楚是什么导致了这种行为

    最佳答案

    Apple obviously forgot to add libnfshared.dylib for whatever reason in the final version of Xcode 12 for iOS 14 simulators. A working workaround until Apple fixes this is to copy the missing lib from Xcode 12 beta 6 over (download the beta from Apple's developer download section). The missing lib can be found here and must go into the same directory for final Xcode 12


    这对我有用。 💯
    如果您想避免为单个文件下载 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/

    相关文章:

    iOS Facebook SDK isSessionValid 返回 null

    ios - 更新 tableview 后不起作用。为什么会这样?

    ios - ResourceManager.write Data(for...不会在 iOS 14 上运行

    ios - 有没有人在 TestFlight env 上成功向您的用户发布 ios App Clip,用于生产环境?

    firebase - react native 应用程序中 firebase 日志的 iOS 14.5 应用程序跟踪透明度

    iphone - “no valid ' aps-environment ' entitlement string” 注册推送通知时

    ios - UIView 转换后拖动行为错误

    ios - 应用程序使用 https - ITSAppUsesNonExemptEncryption 的正确值是多少

    xcode - Swift 3 - 无法覆盖 'imagePickerController'

    swift - 奇怪的 String.unicodeScalars 和 CharacterSet 行为