从窗格访问父项目OTHER_SWIFT_FLAGS [英] access parent project OTHER_SWIFT_FLAGS from pod

查看:436
本文介绍了从窗格访问父项目OTHER_SWIFT_FLAGS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为私有框架构建自定义pod,在我的主项目中,我使用自定义OTHER_SWIFT_FLAGS。

Building a custom pod for a private framework, in my main project i use custom OTHER_SWIFT_FLAGS.

从理论上讲,在

到目前为止,我的尝试失败了,有任何提示吗?
看起来像项目( https://guides.cocoapods.org/syntax/ podfile.html#project )应该是要走的路,但是没有文档。

So far my attempts failed, any hint? Looks like project(https://guides.cocoapods.org/syntax/podfile.html#project) should be the way to go but again, no documentation.

推荐答案

所以基本上看起来像这样。
访问xcode项目,然后访问pod并遍历每个配置以设置适当的值。

So basically it looks like this. Accessing the xcode project, then accessing the pod and looping through each config to set the proper value.

post_install do |installer|
require 'xcodeproj'
project_path = 'pathTo/myProj.xcodeproj' # path to your xcode project
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
    if target.name == 'myTarget' # name of the target in your main project containing the custom flag
        installer.pods_project.targets.each do |podTarget|
            if podTarget.name == 'myPod' #name of your pod
                target.build_configurations.each do |targetConfig|
                    podTarget.build_configurations.each do |podConfig|
                        podConfig.build_settings["OTHER_SWIFT_FLAGS"] = targetConfig.build_settings["OTHER_SWIFT_FLAGS"]
                    end
                end

            end
        end
    end
end

这篇关于从窗格访问父项目OTHER_SWIFT_FLAGS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆