gpt4 book ai didi

cocoapods - 是否在任何地方记录了 CocoaPods 用于 "pod try"命令的启发式方法?

转载 作者:行者123 更新时间:2023-12-04 07:53:26 26 4
gpt4 key购买 nike

在 CocoaPods v.0.29 中,添加了“pod try”命令(参见 http://blog.cocoapods.org/CocoaPods-0.29/)。从文档(粗体强调我的):

In other words the command automates the following steps:

  1. Checkout the source of the Pod in a temporary directory.
  2. Search for any project looking like a demo project using some simple heuristics.
  3. Install any CocoaPods dependencies if needed by the located project.
  4. Open the workspace/project in Xcode.


我在 Google 和 StackOverflow 上都搜索过,但没有找到任何关于 CocoaPods 用于定位演示项目的特定启发式方法的文档。 CocoaPods 定位演示项目的过程和/或包含演示项目和方案的最佳实践是否记录在任何地方?我正在整理一个库,我希望很快将它变成 CocoaPod,并希望确保我的示例项目实际上可以与 CocoaPods 一起正常工作。

感谢您的时间。

最佳答案

我也在寻找这个,我唯一得到的是 source of the pod-try plugin :

# Picks a project or workspace suitable for the demo purposes in the
# given directory.
#
# To decide the project simple heuristics are used according to the name,
# if no project is found this method raises and `Informative` otherwise
# if more than one project is found the choice is presented to the user.
#
# @param [#to_s] dir
# The path where to look for projects.
#
# @return [String] The path of the project.
#
def pick_demo_project(dir)
projs = projects_in_dir(dir)
if projs.count == 0
raise Informative, 'Unable to find any project in the source files' \
" of the Pod: `#{dir}`"
elsif projs.count == 1
projs.first
elsif (workspaces = projs.grep(/(demo|example).*\.xcworkspace$/i)).count == 1
workspaces.first
elsif (projects = projs.grep(/demo|example/i)).count == 1
projects.first
else
message = 'Which project would you like to open'
selection_array = projs.map do |p|
Pathname.new(p).relative_path_from(dir).to_s
end
index = choose_from_array(selection_array, message)
projs[index]
end
end

我不知道 Ruby,但它似乎获取了所有 XCode 项目/工作区的列表(Pods 项目和具有姊妹工作区的项目除外)并选择:
  • 如果只找到一个项目,则为唯一项目。
  • 如果只找到一个这样的项目,则唯一在文件名中包含“演示”或“示例”的工作区。
  • 如果只找到一个这样的项目,则文件名中唯一包含“演示”或“示例”的项目。
  • 什么都没有,但让您从找到的所有项目中进行选择。

  • 如果有人对此有更正 - 欢迎他们,因为我不是 Ruby 人。

    关于cocoapods - 是否在任何地方记录了 CocoaPods 用于 "pod try"命令的启发式方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25396075/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com