当我启用在我的项目中添加的扩展时,我收到了一个错误,请告诉我如何解决这个问题,这里是屏幕截图误差图像
如果你需要任何其他细节,请问我,我会提供他们。
private func addAllBlockingPhoneNumbers(to context: CXCallDirectoryExtensionContext) {
for i in 0...numbers.count - 1
{
let allPhoneNumbers: [CXCallDirectoryPhoneNumber] = [ numbers[i] ]
for phoneNumber in allPhoneNumbers {
context.addBlockingEntry(withNextSequentialPhoneNumber: phoneNumber)
}
}
}
----------------------------
override func beginRequest(with context: CXCallDirectoryExtensionContext) {
context.delegate = self
numbers = DBManager.shared.selectContacts()
}
发布于 2017-10-22 04:19:40
我建议检查CXCallDirectoryExtensionContextDelegate
中的错误代码。将此代码放入requestFailed
函数中:
func requestFailed(for extensionContext: CXCallDirectoryExtensionContext, withError error: Error) {
let errorCode = (error as NSError).code
switch errorCode {
case CXErrorCodeCallDirectoryManagerError.Code.unknown.rawValue:
print("Extension could not be load for an unknown reason.")
case CXErrorCodeCallDirectoryManagerError.Code.noExtensionFound.rawValue:
print("Could not load extension. Extension not found")
case CXErrorCodeCallDirectoryManagerError.Code.loadingInterrupted.rawValue:
print("Could not load extension. Extension was interrupted while loading")
case CXErrorCodeCallDirectoryManagerError.Code.entriesOutOfOrder.rawValue:
print("Could not load extension. Call entries are out of order")
case CXErrorCodeCallDirectoryManagerError.Code.duplicateEntries.rawValue:
print("Could not load extension. Duplicate entries")
case CXErrorCodeCallDirectoryManagerError.Code.maximumEntriesExceeded.rawValue:
print("Could not load extension. Maximum entries exceeded")
case CXErrorCodeCallDirectoryManagerError.Code.extensionDisabled.rawValue:
print("Extension not enabled in Settings")
case CXErrorCodeCallDirectoryManagerError.Code.unexpectedIncrementalRemoval.rawValue:
print("Unexpected incremental removal")
case CXErrorCodeCallDirectoryManagerError.Code.currentlyLoading.rawValue:
print("Could not load extension. The extension is currently loading")
default:
print("Could not load extension.")
}
}
现在,用Xcode调试扩展。(详见此处.)当您试图在设置中启用扩展时,Xcode应该打印一条错误消息,说明出了什么问题。
发布于 2018-01-26 15:28:31
我也有同样的问题,当我将扩展的数据模型添加到目标目录构建阶段时,我能够排除错误并成功地链接Call Directory扩展。
选择您的项目>选择您的目标扩展>选择构建阶段>+编译源代码。
希望这能有所帮助!
https://stackoverflow.com/questions/46756239
复制相似问题