2017-08-14 12 views
1

cocoapodsポッドにビルド設定を追加する方法はありますか?直接ポッドプロジェクトやその他の自動生成されたものを変更しないで、pod installの後もそのまま残りますか?具体的には、クラッシュを避けるために、MixpanelポッドにDISABLE_MIXPANEL_AB_DESIGNER=1を設定する必要があります。Cocoapodsポッド安定ビルド設定

私は何かhereを見つけたが、(私の知る限り理解として)podspecファイルはポッドの所有者ではなく、ユーザーによって作成されるため、&は奇妙に見える時代遅れです。

+0

'post_install'フックはここで使用できますか? https://guides.cocoapods.org/syntax/podfile.html#post_install – Hodson

+0

@ Hodson確かに、あなたのコメントに基づいて答えを投稿しました。 – nrx

答えて

0

ありがとう、@ホドソン、それは解決策です。少しdocumentationから変形例、我々はちょうどあなたのpodfileにこのコードを追加

post_install do |installer| 

    #Specify what and where has to be added 
    targetName = 'Mixpanel' 
    settingKey = 'DISABLE_MIXPANEL_AB_DESIGNER' 
    settingValue = 1 

    #Find the pod which should be affected 
    targets = installer.pods_project.targets.select { |target| target.name == targetName } 
    target = targets[0] 

    #Do the job 
    target.build_configurations.each do |config| 
     config.build_settings[settingKey] = settingValue 
    end 
end 

を取得します。明らかに、同じ方法で、自動生成されたポッドプロジェクトに変更を加えることができ、紛失することはありません。

関連する問題