我使用CocoaPods1.1.1,在我的podfile中有多个post_install挂钩。我得到了一个错误:
[!] Invalid `Podfile` file: [!] Specifying multiple `post_install` hooks is unsupported..
-------------------------------------------
#
> post_install do |installer|
# installer.pods_project.targets.each do |target|
以前有没有人遇到过同样的问题?而且是的!我在我的一个目标中有一个post_install,在全局范围内有另一个。我可以搬进来,但为什么?
发布于 2016-11-09 14:43:07
解决方案2022
当我从我的主要目标中删除我的代码并在全局范围的post_install块中移动时,它的工作就像魅力一样。
由于某种原因,如果添加多个post_install (例如,全局和1个目标),将它们移动到同一个全局块中,并添加用于管理目标的if-else语句。
发布于 2019-03-28 07:57:59
我暂时解决了这场冲突。把代码放进你的Podfile里。
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
发布于 2016-11-14 11:51:38
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
结束
https://stackoverflow.com/questions/40508957
复制相似问题