繁体   English   中英

有没有可以修改 Podfile 的命令行工具?

[英]Is there a command line tool that can modify the Podfile?

我想使用 Cocoapods 为我的项目添加一个框架。 但我不想手动更改 Podfile。 我想使用命令行来编辑 Podfile,如下所示:

some_command ./Podfile --add AFNetworking --target MyTarget

可能吗?

不幸的是,没有这样的命令。

您可以做的更接近的是创建一个.sh文件,该文件打开Podfile并在其上写入。 例子:

podwrite.sh

#!/bin/sh

FILE="Path/To/Podfile"

/bin/cat <<EOM >$FILE
source 'https://github.com/CocoaPods/Specs.git'

target 'MyTarget' do
  use_frameworks!
  pod 'AFNetworking'
end

EOM

通过终端调用:

sh podwrite.sh

podfile 上的 Output:

source 'https://github.com/CocoaPods/Specs.git'

target 'MyTarget' do
  use_frameworks!
  pod 'AFNetworking'
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM