问题描述
我创建了一个新框架 CocoaPod
,这是我的“podspec”文件的副本:
Pod::Spec.new do |s|
# 1
s.platform = :ios
s.ios.deployment_target = '12.0'
s.name = "IdFramework"
s.summary = "IdFramework is a framework containing functionality."
s.requires_arc = true
# 2
s.version = "0.1.0"
# 3
s.license = { :type => "MIT",:file => "LICENSE" }
# 4 - Replace with your name and e-mail address
s.author = { "Idan Israel" => "myEmail" }
# 5 - Replace this URL with your own GitHub page's URL (from the address bar)
s.homepage = "link"
# 6 - Replace this URL with your own Git URL from "Quick Setup"
s.source = { :git => "{link to my framework on Github}",:tag => "#{s.version}" }
# 7
s.framework = "UIKit"
s.dependency 'Firebase'
# 8
"IdFramework/**/*"
# 9
# 10
s.swift_version = "4.2"
end
'podspec' 上传成功,我可以在 GitHub
上看到来源。
我创建了一个新项目,我试图在其中使用我新创建的 CocoaPod
。 Podfile
的外观如下:
# Uncomment the next line to define a global platform for your project
# platform :ios,'12.0'
source 'https://github.com/CocoaPods/Specs.git'
source '{Link to my source code on GitHub}'
target 'TestingPods' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for TestingPods
pod 'IdFramework','~> 0.1.0'
end
这是我在框架内的代码:
import Foundation
import Firebase
public class FirebaseConfig {
public static func setupFirebase() {
let arguments = ProcessInfo.processInfo.arguments as [String]
var plistFileName = "GoogleService-Info-"
if let environment = arguments.first?.split(separator: " ").last {
plistFileName += environment
guard let plistPath = Bundle.main.path(forResource: plistFileName,ofType: "plist"),let options = FirebaSEOptions(contentsOfFile: plistPath) else {
return
}
if FirebaseApp.app() == nil{
FirebaseApp.configure(options: options)
}
}
}
}
CocoaPod
及其所有依赖项均已正确安装,我还可以在 IdFramework
中的 Pods
下看到 Xcode
- 但是,当我尝试导入 {{1} } - 我收到一条 IdFramework
错误消息。
我尝试了以下方法:
-
No such module 'IdFramework'
然后是pod deintegrate
。 - 检查
pod install
下的Pods
,并构建两个项目。 - 确保
Manage Schemes
和iOS version
都匹配。 - 彻底清理我的项目并重建。
以上都不适合我,问题仍然存在。可能是什么问题?
解决方法
将#8 替换为:
s.source_files = "IdFramework/**/*"