【问题标题】:Swift Compiler Error: Missing required modules;Swift 编译器错误:缺少必需的模块;
【发布时间】:2020-09-04 09:07:35
【问题描述】:

我想创建依赖于其他 pod 的自定义 pod。我有 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

错误

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

【问题讨论】:

  • 展示您如何将自定义 pod 嵌入到您的应用中。没有必要乱搞框架搜索路径。另外,requires_src 可能是 requires_arc 的拼写错误,dependency 拼写为两个 ns。
  • 您是否尝试重新安装 UserSDK pod?似乎缺少 ${PODS_ROOT}/Google/Headers... 尝试将其添加到标题路径
  • @Carla Camargo 是的,我试过了,在 pod 中也找不到 Google,但是有 FirebaseCore、FireabaseInstanceID 和 FirebaseMessaging,将其添加到标题路径不起作用
  • @Gereon 更新了我的问题。,还从框架搜索路径中删除了路径。好像你说的没必要
  • 请显示您的完整 pod 列表,或者理想情况下,您的完整 Podfile

标签: ios swift cocoapods


【解决方案1】:

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

  • Deployment_Target

  • Source Files

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

参考: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

【讨论】:

    猜你喜欢
    • 2020-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-23
    • 1970-01-01
    • 2021-06-18
    • 2011-09-26
    • 1970-01-01
    相关资源
    最近更新 更多