首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不支持指定多个post_install挂钩的无效Podfile文件

不支持指定多个post_install挂钩的无效Podfile文件
EN

Stack Overflow用户
提问于 2016-11-09 14:09:15
回答 6查看 12.6K关注 0票数 8

我使用CocoaPods1.1.1,在我的podfile中有多个post_install挂钩。我得到了一个错误:

代码语言:javascript
运行
复制
[!] Invalid `Podfile` file: [!] Specifying multiple `post_install` hooks is unsupported..
-------------------------------------------
 #
 >  post_install do |installer|
 #      installer.pods_project.targets.each do |target|

以前有没有人遇到过同样的问题?而且是的!我在我的一个目标中有一个post_install,在全局范围内有另一个。我可以搬进来,但为什么?

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2016-11-09 14:43:07

解决方案2022

当我从我的主要目标中删除我的代码并在全局范围的post_install块中移动时,它的工作就像魅力一样。

由于某种原因,如果添加多个post_install (例如,全局和1个目标),将它们移动到同一个全局块中,并添加用于管理目标的if-else语句。

票数 12
EN

Stack Overflow用户

发布于 2019-03-28 07:57:59

我暂时解决了这场冲突。把代码放进你的Podfile里。

代码语言:javascript
运行
复制
def multiple_post_install(flutter_application_path)
  #read podhelper from flutter_application_path
  flutter_podhelper = File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb'))

  #find the post_install end location by hardcoding
  post_install_string = 'post_install do |installer|'
  location = flutter_podhelper.index(post_install_string)
  location += post_install_string.length

  #declare your own hook func
  update_configs_func = %q[
  update_configs(installer)]

  #insert the func you declare
  flutter_podhelper.insert(location, update_configs_func)
  return flutter_podhelper
end

flutter_application_path = 'path/to/my_flutter/'
flutter_podhelper = multiple_post_install(flutter_application_path)
eval(flutter_podhelper, binding)

def update_configs(installer)
  #put your own custom code
end
票数 4
EN

Stack Overflow用户

发布于 2016-11-14 11:51:38

代码语言:javascript
运行
复制
def main_pods
pod 'CocoaLumberjack', '2.0.0'
pod 'MBProgressHUD', '0.9.1'

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|

        if target.name == 'Pods-AFNetworking'
            target.build_configurations.each do |config|
                config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
                config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << '_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_=1'
            end
        end

    end
end

结束

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40508957

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档