ios – 将运行脚本构建阶段从podspec添加到Xcode项目
发布时间:2020-12-15 02:02:34 所属栏目:百科 来源:网络整理
导读:我正在为我的库编写Cocoapods规范,该库必须修改Xcode项目,并将“运行脚本构建阶段”添加到项目的目标中。我以为可以使用 post_install钩。 但是,“pod spec lint”表示这个钩子已被弃用: - WARN | [iOS] The post install hook of the specification DSL
我正在为我的库编写Cocoapods规范,该库必须修改Xcode项目,并将“运行脚本构建阶段”添加到项目的目标中。我以为可以使用
post_install钩。
但是,“pod spec lint”表示这个钩子已被弃用: - WARN | [iOS] The post install hook of the specification DSL has been deprecated,use the `resource_bundles` or the `prepare_command` attributes. 我不知道如何用* resource_bundles *或* prepare_command *替换post_install钩子。 另一个问题是如何修改Xcode项目以添加构建阶段,但实际上只有当“post_hook问题”被解决时。 解决方法
使用Xcodeproj ruby?? gem(它是Cocoapods的一部分)来编写一个修改Xcode项目的脚本。
然后使用prepare_command调用此脚本。 require 'xcodeproj' path_to_project = "${SOURCE_ROOT}/${PROJECT_NAME}.xcodeproj" project = Xcodeproj::Project.open(path_to_project) main_target = project.targets.first phase = main_target.new_shell_script_build_phase("Name of your Phase") phase.shell_script = "do sth with ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/your.file" project.save() 文件:http://rubydoc.info/gems/xcodeproj/frames 您可以通过运行…获取构建设置变量及其值的列表 xcodebuild -project [ProjectName].xcodeproj -target "[TargetName]" -showBuildSettings 更新: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |