gpt4 book ai didi

ios - 'NSInvalidArgumentException',原因 : '+[FIRInstanceIDCheckinPreferences preferencesFromKeychainContents:]: ' unrecognized selector sent to class '

转载 作者:行者123 更新时间:2023-12-02 10:40:51 25 4
gpt4 key购买 nike

当我尝试使用 Firebase 中的 MLModelInterpreter 在我的 Xcode 项目中加载 tflite-File 时,在 Launchsreen 完全可见后出现以下错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[FIRInstanceIDCheckinPreferences preferencesFromKeychainContents:]: unrecognized selector sent to class 0x10235ca58

我的代码基于 Firebase 的教程,因此我很惊讶它不起作用。这是代码:
import Firebase


var interpreter: ModelInterpreter?

func convertTheModel(){


guard let modelPath = Bundle.main.path( forResource: "model", ofType: "tflite", inDirectory: ""
)
else {
print("not able to load model")
return

}

let localModel = CustomLocalModel(modelPath: modelPath)
interpreter = ModelInterpreter.modelInterpreter(localModel: localModel)

let ioOptions = ModelInputOutputOptions()
do {
try ioOptions.setInputFormat(index: 0, type: .float32, dimensions: [1, 22])
try ioOptions.setOutputFormat(index: 0, type: .float32, dimensions: [1, 1])
} catch let error as NSError {
print("Failed to set input or output format with error: \(error.localizedDescription)")
}



let inputs = ModelInputs()
var inputData = Data()

do {
for _ in 0 ..< 22 {

// require fixed-point values or the original bytes.
var RandomNumber = Float.random(in: 0 ..< 1)

// Append normalized values to Data object.
let elementSize = MemoryLayout.size(ofValue: RandomNumber)
var bytes = [UInt8](repeating: 0, count: elementSize)
memcpy(&bytes, &RandomNumber, elementSize)
inputData.append(&bytes, count: elementSize)
}
try inputs.addInput(inputData)
} catch let error {
print("Failed to add input: \(error)")
}


interpreter!.run(inputs: inputs, options: ioOptions) { outputs, error in
guard error == nil, let outputs = outputs else { return }

print(outputs)
}

}



经过一番调试后,我隐约猜测错误是由这行代码引起的: interpreter = ModelInterpreter.modelInterpreter(localModel: localModel)
附加信息

在上述问题之前,我遇到了另一个问题:在构建项目时,编译器显示此错误:
/Users/Path/Application_Name/Update/Pods/GoogleMobileVision/Detector/Frameworks/GoogleMobileVision.framework/GoogleMobileVision(VisionExtension.pbobjc_0848a2b53cac8a49ea32ab4e6cb931d4.o)
ld: 46 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code

以下是我所做的总结:
  • 我清理了 buildingfolder
  • 重新安装所有 pod:pod deintegrate并且比 pod install
  • 将 No Common Blocks 设置为 no
  • 删除所有 -ObjC,如 this Link描述。

  • 我的 Podfile 是:
    platform :ios, '13.0'

    target 'My Project' do
    # Comment the next line if you don't want to use dynamic frameworks
    use_frameworks!

    # Pods for My Project
    pod 'Firebase/Database'
    pod 'Firebase/Auth'
    pod 'GoogleMobileVision/FaceDetector'
    pod 'Firebase/Firestore'
    pod 'Firebase/MLModelInterpreter'


    end



    如果有人可以提供帮助,我将不胜感激

    编辑

    如果有人有其他解决方案可以将 tflite 文件(或 h5 文件:查看我以前的问题)加载到 Xcode 项目中,这也会有所帮助

    @保罗·伯斯特里安

    这是我粘贴 -ObjC 的位置:
    enter image description here

    最佳答案

    -ObjC 必须在应用程序的 Other Linker Flags 中让 Firebase 正常工作。见 https://github.com/firebase/firebase-ios-sdk/issues/4776有关此问题的更多详细信息。

    关于ios - 'NSInvalidArgumentException',原因 : '+[FIRInstanceIDCheckinPreferences preferencesFromKeychainContents:]: ' unrecognized selector sent to class ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61168491/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com