本文介绍了dyld:未加载库:@ rpath/CoreNFC.framework/CoreNFC,iOS11和Xcode 9 Beta的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 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
有人知道如何解决此问题吗?
Does anyone knows how to fix this?
推荐答案
由于@Chinchan Zu的评论,我将一些答案合并在一起以解决此问题
I combined some answers together to fix this thanks to @Chinchan Zu's comment
首先,如本屏幕截图所示,您可以选择在链接的框架和库"中将其导入NFCCore.
First you make import to NFCCore in "Linked Frameworks and Libraries" as optional as in this screenshot
然后在代码内部,使用此#if检查包装代码.这是我使用的课程
Then inside your code you wrap your code with this #if check. Here is the class I used
#if canImport(CoreNFC)
import Foundation
import CoreNFC
#endif
class NFCManagar: NSObject {
#if canImport(CoreNFC)
var session: NFCNDEFReaderSession?
#endif
var items = [Item]()
var completion: ((_ success: Bool, _ error: Error?)-> Void)?
func beginScanning(items: [Item], completion: @escaping (_ success: Bool, _ error: Error?)-> Void) {
self.completion = completion
self.items.removeAll()
self.items.append(contentsOf: items)
#if canImport(CoreNFC)
session = NFCNDEFReaderSession(delegate: self, queue: nil, invalidateAfterFirstRead: true)
session?.alertMessage = "Hold your iPhone near check in/out device."
session?.begin()
#endif
}
}
#if canImport(CoreNFC)
extension NFCManagar: NFCNDEFReaderSessionDelegate {
// MARK: - NFCNDEFReaderSessionDelegate
/// - Tag: processingTagData
func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) {
debugPrint("Nfc is detected")
}
/// - Tag: endScanning
func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error) {
// Check the invalidation reason from the returned error.
if let readerError = error as? NFCReaderError {
// Show an alert when the invalidation reason is not because of a success read
// during a single tag read mode, or user canceled a multi-tag read mode session
// from the UI or programmatically using the invalidate method call.
if (readerError.code != .readerSessionInvalidationErrorFirstNDEFTagRead)
&& (readerError.code != .readerSessionInvalidationErrorUserCanceled) {
debugPrint("Nfc didInvalidateWithError \(error)")
}
}
// A new session instance is required to read new tags.
self.session = nil
}
}
#endif
这篇关于dyld:未加载库:@ rpath/CoreNFC.framework/CoreNFC,iOS11和Xcode 9 Beta的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!