提问人:NLanese 提问时间:11/1/2023 最后编辑:NLanese 更新时间:11/9/2023 访问量:68
没有这样的模块“FirebaseStorage”Swift 文件,Capacitor 插件
No such module 'FirebaseStorage' Swift File, Capacitor Plugin
问:
我正在 Xcode 14.3.1 上开发适用于 iOS 的 Capacitor 插件,除了让 Firebase 在我的 Swift 文件中工作之外,我什么都没有遇到;即 FirebaseStorage,它只是拒绝被识别。我面临的错误是,尽管它在其他任何地方都显示安装了 FirebaseStorage。No such module 'FirebaseStorage
使这变得非常困难的是,我的项目是一个插件,因此它需要根据提供给插件的不同输入动态连接到不同的 Firebase 项目。话虽如此,我的Firebase在文件中的配置如下所示PluginSwift.swift
// Initializes Firebase Connection if Firebase is the used Storage
func initializeFirebase(
firebaseStorageUrl: String, // Access URL ro Firebase
googleAppID: String, // This can be found in the google-services.json (Android) or GoogleService-Info.plist (iOS) files
gcmSenderID: String,
capPluginCall: CAPPluginCall
){
// Sets up appropriate values for finding the Firebase Storage Proejct
let fileopts = FirebaseOptions(googleAppID: googleAppID, gcmSenderID: gcmSenderID)
fileopts.storageBucket = firebaseStorageUrl
// Sets up the Firebase Connection
FirebaseApp.configure(options: fileopts)
}
func firebaseDownloadPkPass(
capPluginCall: CAPPluginCall,
path: String
){
// Connects to the Storage, provided the Firebase App connected
let storage = Storage.storage()
// Creates a Reference to the Storage Object, so the storage can be interacted with as a variable
let storageRef = storage.reference()
// Finds the specific file
let fileRef = storageRef.child(path)
// Downloads the File
fileRef.getData(maxSize: 10 * 1024 * 1024) { data, error in
if let error = error {
capPluginCall.reject("Error in Downloading the File. The Pass, however, was successfully created in Firebase Storage. It will not be added to this device until installed \n \(error.localizedDescription)")
}
else {
if let returnData = data?.base64EncodedString(){
capPluginCall.resolve(["newPass": returnData])
}
else{
capPluginCall.reject("Issue occurred in resolving the pkpass to string for return.")
}
}
}
}
在文件顶部进行以下导入...
import Foundation
import Capacitor
import PassKit
import JavaScriptCore
//import Amplify
import FirebaseCore
import FirebaseAuth
// import FirebaseFirestore // This line SOMETIMES works and sometimes doesn't. Seemingly random
import FirebaseStorage // This line ALWAYS throws the error in question, No such module 'FirebaseStorage' Swift File, Capacitor Plugin
令人讨厌的是我的插件内部,这构建得很好。如果我打开工作区,我可以运行它并且没有问题。但是,当我尝试在另一个名为的应用程序上测试此插件时,它每次都会抛出上述错误。capacitor-wallet-access
capacitor-wallet-access/ios
ionicPluginTestApp
的 Podfile 如下所示...ionicPluginTestApp
require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers'
platform :ios, '13.0'
use_frameworks!
# workaround to avoid Xcode caching of Pods that requires
# Product -> Clean Build Folder after new Cordova plugins installed
# Requires CocoaPods 1.6 or newer
install! 'cocoapods', :disable_input_output_paths => true
def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
pod 'CapacitorWalletAccess', :path => '../../../../Packages/Capacitor/capacitor-wallet-access'
end
target 'App' do
capacitor_pods
pod 'Firebase'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
pod 'Firebase/Auth'
pod 'Firebase/Core'
# Add your Pods here
end
post_install do |installer|
assertDeploymentTarget(installer)
end
Xcode 中的两个项目都通过 Xcode 中的部分添加了相应的 Firebase 库,如下图所示。显示的项目是主应用程序,即应用程序。我在FirebaseFirestore无法正常工作时遇到了类似的困难,导致错误,但是我能够通过更改添加到该部分的FirebaseFirestore来解决这个问题。它最初是旁边有文件夹图标而不是建筑物图标的那个。但是,该修复程序并不能解决FirebaseStorage的问题,并且使我完全无能为力。Libraries and Frameworks
General
ionicPluginTestApp
No such module 'Firebase'
Libraries and Frameworks
该插件也拥有我认为它应该拥有的一切,通过 XCode 添加了几乎相同的 Podfile 和 Firebase。同样,在插件的 podspec 文件中,我有......
(添加行s.dependency 'Firebase', '~> 10.17.0'
)
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = 'CapacitorWalletAccess'
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.homepage = package['repository']['url']
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '13.0'
s.dependency 'Capacitor'
s.dependency 'Firebase', '~> 10.17.0'
s.swift_version = '5.1'
end
我试过>,我试过删除和重新引入FirebaseStorage,以及整个。Product
Clean Build Folder...
firebase-sdk-ios
还有其他人遇到过这种情况吗?
答: 暂无答案
评论