我的 iOS 應用程式的 CocoaPods Podfile 使用 post_install 鉤子將生成的 Acknowledgements.plist 檔案復制到我的應用程式的設定包中。然而,該檔案包含了我想排除的(專有)私有 pod。
問題
我知道我可以手動修改復制的Acknowledgements.plist 檔案中的專案。我將如何以編程方式從該檔案中排除特定的私有 pod?
代碼
這是post_install鉤子,將Acknowledgements.plist復制到Settings bundle。
post_install do |installer|
raw_acknowledgements = File.read('Pods/Target Support Files/Pods-MyApp/Pods-MyApp-Acknowledgements.plist')
formatted_acknowledgements = raw_acknowledgements.gsub(/(?<!>) (?<!
)
( *)(?![ *])(?![ -])(?!
)(?!<)/, ' '/span>)
# 在檔案被復制之前,我如何排除特定的pod?
File.open('MyApp/Supporting Files/Settings.bundle/Acknowledgements.plist', "w" ) { |file| file.put formatted_acknowledgements }
end
Update
我在下面添加了一個答案,目前是可行的。然而,我愿意接受另一個不涉及修改許可證或使用插件的答案。
uj5u.com熱心網友回復:
選項1
通過從Podspec中洗掉LICENSE檔案和license物件,可以從生成的Acknowledgements.plist中排除私有pods。在私有的podspec.json檔案中,license物件看起來類似于這樣:
"license"/span>。 { "type"。 "專有", "檔案"。 "LICENSE" }
如果不同時洗掉LICENSE檔案,這個方案將無法作業。
方案2
另一個不需要修改私有 pod 許可證的解決方案是使用 CocoaPods Acknowledgements 插件。在安裝了cocoapods-acknowledgements gem之后,在你的Podfile中添加如下內容:
plugin 'cocoapods-acknowledgements'。
:settings_bundle => true。
:target => ['MyApp'] 。
:exclude => ['PrivatePodA'/span>, 'PrivatePodB'/span>]
注意,這個解決方案不需要問題中的post_install掛鉤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/307617.html
標籤:
上一篇:大三時候看了這份路線,進阿里了!進大廠保姆教程!建議收藏!
下一篇:添加附件會破壞郵件內容軌道
