gpt4 book ai didi

ios - 使用 Swift 和 Objective-C 构建 Cocoapod : How to Deal with Umbrella Header Issues?

转载 作者:行者123 更新时间:2023-11-28 08:34:28 27 4
gpt4 key购买 nike

我有一个现有的 Xcode 框架,它同时使用 Swift 和 Objective-C,我正试图让它像 Cocoapod 一样工作。到目前为止我的步骤是:

1) 我使用 pod lib create SMCoreLib 来初始化一个新文件夹 ( https://guides.cocoapods.org/making/using-pod-lib-create.html )。

2) 我将 Swift 和 Objective-C 代码从我的框架复制到这个新初始化的 pod 文件夹中的 SMCoreLib/Classes 文件夹中。我也将这段代码拖到_Pods.xcodeproj 中的相关组中。

3) 我对项目的 .podspec 文件进行了一些更改。如下(请注意,Github 存储库尚未更新这些更改;如果有人需要,我可以这样做):

Pod::Spec.new do |s|
s.name = 'SMCoreLib'
s.version = '0.0.2'
s.summary = 'Spastic Muffin Core Library for iOS'

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!

s.description = <<-DESC
Objective-C and Swift classes to support Spastic Muffin code.
DESC

s.homepage = "https://github.com/crspybits/SMCoreLib.git"
s.license = { :type => "GPL3", :file => "LICENSE.txt" }
s.author = { "Christopher Prince" => "<snip>" }

s.platform = :ios, "8.0"

s.source = { :git => "https://github.com/crspybits/SMCoreLib.git", :tag => "#{s.version}" }

s.ios.deployment_target = '8.0'

s.source_files = 'SMCoreLib/Classes/**/*'

s.resources = "SMCoreLib/Assets/**"

# s.resource_bundles = {
# 'SMCoreLib' => ['SMCoreLib/Assets/*.png']
# }

# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'

s.requires_arc = true

# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }

s.dependency 'AFNetworking'
s.dependency 'HPTextViewTapGestureRecognizer', '~> 0.1'
s.dependency 'Reachability'
end

我的问题是我在尝试构建 Example Xcode 项目和尝试检查 pod 时都失败了。构建示例 Xcode 项目时,出现以下错误:

Xcode errors

从命令行,当我这样做时:

pod lib lint --allow-warnings --verbose --no-clean

我收到以下错误:

- NOTE  | [iOS] xcodebuild:  <module-includes>:2:9: note: in file included from <module-includes>:2:
- ERROR | [iOS] xcodebuild: /Users/chris/Library/Developer/Xcode/DerivedData/App-bhqthebvswpzxeesjidsqpmmwovu/Build/Products/Release-iphonesimulator/SMCoreLib/SMCoreLib.framework/Headers/SMCoreLib-Swift.h:103:9: error: 'SMCoreLib/SMCoreLib.h' file not found
- NOTE | [iOS] xcodebuild: <unknown>:0: error: could not build Objective-C module 'SMCoreLib'

问题似乎是在自动生成的 SMCoreLib-Swift.h Generated Interface Header 中,找不到 SMCoreLib.h umbrella header。如果有任何建议,我将不胜感激。

最佳答案

我有一个破解这个问题的办法。我想要一个更好的。修复方法是将 SMCoreLib.h 文件放在:SMCoreLib/Classes/SMCoreLib.h。该文件包含单行:

#import "SMCoreLib-umbrella.h"

问题似乎是生成的接口(interface) header 不遵守模块映射中给定的伞形 header 的名称更改。 Cocoapods 创建此模块映射并更改名称。此 hack 修复存在于此项目的 Git 存储库 https://github.com/crspybits/SMCoreLib.git

关于ios - 使用 Swift 和 Objective-C 构建 Cocoapod : How to Deal with Umbrella Header Issues?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38192343/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com