【问题标题】:XCode project: how to remove / add files from terminal (script, command, etc)XCode 项目:如何从终端删除/添加文件(脚本、命令等)
【发布时间】:2014-05-04 04:11:04
【问题描述】:

有没有办法在不使用 XCode 的情况下从 XCode 项目中删除文件或向 XCode 项目中添加文件?也就是说,是否有任何终端命令或程序可以做到这一点?我知道我可以通过 cp mvrm 添加/删除文件,但它们不会反映在实际的项目文件中。 谢谢!

【问题讨论】:

  • 我不这么认为,但 Xcode 支持 AppleScript,并且可能可以通过这种方式添加/删除文件。
  • 如果你知道 Ruby:github.com/CocoaPods/Xcodeproj

标签: ios xcode command-line terminal xcodeproj


【解决方案1】:

有一个名为 xcodeproj 的 Ruby Gem,它允许在命令行中操作 XCodeProject。

查看Using the Xcodeproj Ruby Gem,它提供了将文件添加到项目的示例。

# Open the existing Xcode project
project_file = product_name + '.xcodeproj'
project = Xcodeproj::Project.new(project_file)

# Add a file to the project in the main group
file_name = 'Message.m'
group_name = product_name
file = project.new_file(file_name, group_name)

# Add the file to the main target
main_target = project.targets.first
main_target.add_file_references([file])

# Save the project file
project.save_as(project_file)

【讨论】:

    【解决方案2】:

    使用this复制它们后尝试构建

    不知道会不会好用,但值得一试:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-08
      • 1970-01-01
      • 1970-01-01
      • 2011-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多