7

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

4

2 回答 2

4

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

查看使用 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)
于 2017-03-13T17:29:22.530 回答
0

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

不知道它是否会起作用,但值得一试:)

于 2014-03-26T04:54:00.117 回答