【问题标题】:Import Objective-C vendored framework from parent pod using Swift (for a mixed project)使用 Swift 从父 pod 导入 Objective-C 供应商框架(用于混合项目)
【发布时间】:2018-12-07 21:03:15
【问题描述】:

我的 podspec 设置如下:

Pod::Spec.new do |spec|
  spec.name         = "TMGAdvertising"
  spec.default_subspecs = ["Core"]
  *** [extra stuff removed] ***

  spec.subspec 'Core' do |tmgadvertising|
    *** [extra stuff removed] ***
  end

  spec.subspec 'Inneractive' do |inneractive|
    inneractive.dependency "TMGAdvertising/Core"
    inneractive.private_header_files  = "TMGAdvertising/AdNetworkSupport/Inneractive/SDK/*.h", "TMGAdvertising/AdNetworkSupport/Inneractive/Adapters/*.h"
    inneractive.public_header_files  = "TMGAdvertising/AdNetworkSupport/Inneractive/InneractiveWrapper.h"
    inneractive.source_files  = ["TMGAdvertising/AdNetworkSupport/Inneractive/Adapters/*.{h,m,swift}", "TMGAdvertising/AdNetworkSupport/Inneractive/SDK/*.{h,m,swift}", "TMGAdvertising/AdNetworkSupport/Inneractive/InneractiveWrapper.{h,m,swift}"]
    inneractive.vendored_frameworks = "TMGAdvertising/AdNetworkSupport/Inneractive/SDK/*.framework"
    inneractive.pod_target_xcconfig = { 'OTHER_LDFLAGS' => ['-ObjC'] }
  end
end

我在 Obj-C 中为 Inneractive 框架编写包装类没有问题(位于 TMGAdvertising 中)。这是我的示例 Obj-C 包装器之一:

#import "InneractiveWrapper.h"
@import IASDKCore;

@implementation InneractiveWrapper

+ (void)initializeSDK:(NSString *)appId {
    [[IASDKCore sharedInstance] initWithAppID:appId];    
}

@end

问题是我不想用 Objective-C 编写我的包装器——我更喜欢用 Swift 编写它们。

通常我可以使用桥接头来完成此操作(这是在直接集成到应用程序之前的设置方式),但由于这是一个子规范,我的理解是这是不可能的。

我的问题是:有什么方法可以直接将这个供应商的 Inneractive 框架导入位于 TMGAdvertising pod 中的 Swift 文件中?

【问题讨论】:

    标签: objective-c swift xcode cocoapods


    【解决方案1】:

    据我所知,您应该能够在桥接头中导入该文件。

    @import IASDKCore;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      • 1970-01-01
      • 2018-09-17
      • 1970-01-01
      • 1970-01-01
      • 2015-12-24
      • 1970-01-01
      相关资源
      最近更新 更多