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

Sam*_*Sam 5 ios cocoapods swift

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

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

 s.dependency "UserSDK" 
Run Code Online (Sandbox Code Playgroud)

UserSDK 是我想在自定义模块中使用的 pod。它有自己的依赖项 FirebaseCore,例如FirebaseMessaging UserSDK podspec

在我的 CustomModule.swift 文件中有

import Foundation
import UserSDK
Run Code Online (Sandbox Code Playgroud)

要使用自定义库,请通过 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
Run Code Online (Sandbox Code Playgroud)

错误在此输入图像描述

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

Nay*_*ave 3

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

\n
    \n
  • Deployment_Target

    \n
  • \n
  • Source Files

    \n

    inherit! :search_pathsPodfile之前end

    \n
  • \n
\n

参考: https: //ronakshah.org/How-To-Make-A-Cocoapod-With-Dependencies

\n

并针对您的具体错误添加以下内容podfile

\n
pod \'Firebase/Core\'\npod \'Firebase/Messaging\'\n
Run Code Online (Sandbox Code Playgroud)\n

或者参考:\n Xcode 错误:缺少必需的模块“Firebase”

\n

Swift 应用程序:\xe2\x80\x9c 导入静态库的框架时缺少所需模块\xe2\x80\x9d

\n