Swift编译器错误:缺少必需的模块;

时间:2020-05-18 14:21:31

标签: ios swift cocoapods

我想创建依赖于其他容器的自定义容器。我有podspec文件

 ...
 s.source_files = "ios/**/*.{h,c,m,swift}"
 s.requires_arc = true

 s.dependency "UserSDK" 

UserSDK是要在自定义模块中使用的Pod。它具有自己的依赖性,例如FirebaseCoreFirebaseMessaging UserSDK podspec

在我的CustomModule.swift文件中具有

import Foundation
import UserSDK

要使用自定义库,请通过pod文件添加它;

# Uncomment the next line to define a global platform for your project
# platform :ios, '11.0'

target 'MyTarget' do

pod 'FBLazyVector', :path => "../modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../modules/react-native/'
pod 'React-Core', :path => '../modules/react-native/'
pod 'React-CoreModules', :path => '../modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../modules/react-native/'
pod 'React-RCTActionSheet', :path => '../modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../modules/react-native/'

pod 'CustomModule', :path => "../CustomModule"

end

错误enter image description here

如果我将use_frameworks!添加到podfile中的目标上,它可以工作,但是其他依赖项不起作用

1 个答案:

答案 0 :(得分:3)

podspec文件中,缺少几个字段,我猜

  • Deployment_Target

  • Source Files

    inherit! :search_paths之前在Podfile中使用end

引用:https://ronakshah.org/How-To-Make-A-Cocoapod-With-Dependencies

,对于您的特定错误,请在podfile

中添加以下内容
pod 'Firebase/Core'
pod 'Firebase/Messaging'

或参考: Xcode error: Missing required module 'Firebase'

Swift app: “Missing required module” when importing framework that imports static library