ios - 在 Podfile 中包含文件

标签 ios cocoapods

我有一个应用程序,其中包含许多使用 cocoapods 链接的模块。链接的模块在运行时被检测到。现在我希望能够从构建服务器中添加和删除模块。我现在需要做的是在安装之前删除依赖项或向 Podfile 添加依赖项。

我认为如果我可以将每个目标的依赖项写在一个单独的文件中并将它们包含在 Podfile 中,那就太好了。这样我就不需要在构建时修改 Podfile。我在 C 中寻找类似 #include 预处理器指令的东西,但我了解到 ruby​​ 中的 include 和 require 函数的工作方式大不相同。到目前为止,我最好的成功是尝试 load,但它失败了 Invalid 'Podfile' file: undefined method 'pod' for main:Object.

有没有可能包含一个文件?

最佳答案

不确定这是否受支持,但如果您在模块文件中创建一个从主 Podfile 调用的函数,它确实有效。 播客文件:

platform :ios, '9.0'

use_frameworks!

load 'ModulePods.rb'

abstract_target 'CommonPods' do
    module_pods
    pod 'SAMKeychain'

    target 'Target' do
        pod 'RealmSwift
    end
end

ModulePods.rb:

def module_pods
    pod 'ReachabilitySwift', '4.1.0'
end

关于ios - 在 Podfile 中包含文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39191258/

相关文章:

ios - UICollectionViewController : [UICollectionViewController loadView] loaded the "identifier" nib but didn't get a UICollectionView

iphone - OpenGL ES 2.0 中的地球日/夜侧着色器

ios - 在构建测试目标期间未导入 Cocoapod

ios - 如何将 `Facebook-iOS-SDK`导入到桥接头中?

ios - InAppPurchase 无效的产品标识符 - 是由于待处理的银行详细信息吗?

ios - EXC_BAD_ACCESS 和 stringByAppendingString

ios - iphone 多语言支持

git - 我应该将 Pod 添加到 VCS 吗?

ios - Cocoapods ld : library not found for -lPods-Projectname

ios - Cocoapod : "The document could not be saved. The file doesn’ t exist"的 Xcode 错误