简体   繁体   English

在Swift项目中使用CocoaPods作为模块添加Objective-C框架项目时,找不到iOS模块错误

[英]IOS Module not found error when adding Objective-C framework projects using CocoaPods as a module in Swift project

I have scenario where i have couple of SDKs and a test app. 我有几个SDK和一个测试应用程序的场景。 Here is the example. 这是例子。

SDKCore - “Objective-C Framework” SDKCore- “ Objective-C框架”

SDKUI - “Objective-C Framework” SDKUI- “ Objective-C框架”

  • SDKCore is added as a dependency using Cocoapods pod 'SDKCore', :path => '../SDKCore' and with flag 'use_frameworks' 使用Cocoapods pod 'SDKCore', :path => '../SDKCore'并使用标志'use_frameworks'将SDKCore添加为依赖项
  • SDKUIViewController uses methods from SDKCore. SDKUIViewController使用SDKCore中的方法。 I'm importing like this @import SDKCore; 我正在这样输入@import SDKCore;

Code

#import "SDKUIViewController.h"
@import SDKCore;

@interface SDKUIViewController ()

@end

@implementation SDKUIViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [SDKClass hitTest];
    self.view.backgroundColor = [UIColor redColor];
}

@end

SDKTestSwift SDKTestSwift

  • SDKCore is added as a dependency using Cocoapods pod 'SDKCore', :path => '../SDKCore' and with flag 'use_frameworks' 使用Cocoapods pod 'SDKCore', :path => '../SDKCore'并使用标志'use_frameworks'将SDKCore添加为依赖项
  • SDKUI is added as a dependency using Cocoapods pod 'SDKUI', :path => '../SDKUI' and with flag 'use_frameworks' 使用Cocoapods pod 'SDKUI', :path => '../SDKUI'并带有标志'use_frameworks' pod 'SDKUI', :path => '../SDKUI'将SDKUI添加为依赖项。

Problem is when i compile SDKTestSwift I'm getting Module SDKCore not found a compile error on one of the files from SDKUI (See attached) 问题是当我编译SDKTestSwift时,我得到的Module SDKCore not found其中一个文件上Module SDKCore not found编译错误(请参阅附件) 在此处输入图片说明

Really got stuck here. 真的卡在这里了。 Thanks a lot in advance. 非常感谢。

You can download the sample project from here . 您可以从此处下载示例项目

Sorry, I actually have misunderstood you from the start, your issue lying in your pod, not project, this happen because you didn't state that the SDKUI depend on SDKCore , thats why you cant use any code from SDKCore 抱歉,实际上我从一开始就误解了您的问题,您的问题在您的pod中,而不是项目中,这是因为您没有声明SDKUI依赖于SDKCore ,这就是为什么您不能使用SDKCore任何代码的SDKCore

To fix this, simply add s.dependency 'SDKCore' in your SDKUI.podspec and run pod install again, then it works 为了解决这个问题,只需添加s.dependency 'SDKCore'SDKUI.podspec和运行pod install一遍,然后它的工作原理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift 框架通过 Cocoapods 添加到 Objective-C 应用程序中 - “未找到模块” - Swift Framework Added via Cocoapods into Objective-C App - "Module not found" 在Swift内的objective-c框架中没有这样的模块错误 - No Such Module error in objective-c framework inside Swift No Such Module&#39;Insembles&#39;错误 - 导入objective-c框架以在swift项目中使用 - No Such Module 'Ensembles' Error - importing objective-c framework to use in swift project Objective-c 使用 cocoapods 添加 Swift 框架未找到文件 - objective-c use cocoapods add Swift framework not found file 在 objective-c 模块中使用 swift 时无法构建 Objective-C 模块 - Could not build Objective-C module, when using swift in objective-c module 添加Swift文件后构建Swift Cocoa Touch Framework时出错: <unknown> :0:错误:无法构建Objective-C模块 - Error building Swift Cocoa Touch Framework after adding Swift file: <unknown>:0: error: could not build Objective-C module 使用 CocoaPods 归档 iOS 项目时找不到模块错误 - Cannot find module error when archiving iOS project using CocoaPods 将自定义Objective-C框架添加到项目时的链接器错误 - Linker error when adding Custom Objective-C Framework to project iOS - 在Swift Code中使用Cocoapods objective-C - iOS - Using Cocoapods objective-C within Swift Code Objective-C 项目中的 Swift CocoaPods 库 - Swift CocoaPods Library in Objective-C Project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM