本文介绍了Apple Watch的预建操作以更改情节提要customModule引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个项目,其中有3个不同版本的同一应用程序(不同的品牌等),效果很好.从那以后,我添加了3个新的Apple Watch目标(每个应用版本" 1个),其中2个引用了主" Apple Watch目标中的文件.

I currently have a project with 3 different versions of the same app (different branding and such), which is working just fine. I've since then added 3 new Apple Watch targets (1 for each app "version"), where which 2 of them reference the files in the "master" Apple Watch target.

只要我记得为每个故事板视图更改模块引用,一切就可以正常工作,以便它映射到相应监视包扩展目标中的正确接口控制器.

Everything works fine as long as i remember to change the module reference for each storyboard view, so that it maps to the correct interface controller in the corresponding watchkit extension target.

但是,记住每次我需要运行/构建应用程序版本/目标时都要进行切换是一件痛苦的事情,而不是长期的解决方案.

However, remembering to switch this every time i need to run/build a app version/target is a pain and not really a long term solution.

我创建了以下命令,希望在正确的时间运行该命令,以便在编译故事板之前对其进行更改.

I've created the following command which I want to be run at the correct time, such that it changes the storyboard references before it is compiled.

perl -pi.bak -e 's/customModule=\"(.*?)\">/customModule=\"watchMyTarget_Extension\">/g' ${SRCROOT}/watch/Base.lproj/Interface.storyboard

我还得出结论,因为我不想让git抱怨文件更改,所以我可能想在应用程序编译后重置更改.这就是为什么上述脚本创建一个.bak文件的原因.因此,在编译完成并打包/运行在设备或其他设备上之后,我想运行

I also concluded that I would probably want to reset the change after the app was compiled, since I don't want to have a file change for git to complain about. Which is why the aforementioned script creates a .bak file. So after the compilation is done and packed/run on device or whatever, I want to run

mv ${SRCROOT}/watch/Base.lproj/Interface.storyboard.bak ${SRCROOT}/watch/Base.lproj/Interface.storyboard

我尝试将脚本放置在目标的(watchTarget,而不是appTarget)构建方案中,Build->Pre/Post Actions似乎没有任何作用.然后,我尝试将其放入Run->Pre/Post Actions,在某种程度上可以正常工作,但是似乎在将应用程序推送到模拟器并因此导致应用程序崩溃之前启动了后期操作(无法运行以查看设备日志"或类似的内容) ).

I've tried placing the scripts in the target's (watchTarget, not appTarget) build scheme, Build->Pre/Post Actions which didn't seem to have any effect. And I tried putting it in Run->Pre/Post Actions which worked to some degree, but it seemed like the post action kicked in before the app was pushed to the simulator and thus crashing the application ("could not run see device logs" or something like that).

那么我到底需要把这些脚本放在哪里,以便它们在构建过程中的正确时间运行?

So where on earth do I need to put these scripts to have them run at the correct time in the build process?

推荐答案

您应该在目标的构建阶段中使用add New Run Script Phase,将其放置在Compile Sources之前

you should use add New Run Script Phase in your target's Build Phases, place it before the Compile Sources

步骤:(来自 Apple )

  1. 在项目编辑器中,选择要添加目标的目标.运行脚本构建阶段.
  2. 单击项目编辑器顶部的构建阶段".
  3. 选择编辑器>添加构建阶段>添加运行脚本构建阶段.
  4. 在项目编辑器中显示运行脚本"部分.
  5. 在运行脚本"模板中配置脚本.
  1. In the project editor, select the target to which you want to add arun script build phase.
  2. Click Build Phases at the top of the project editor.
  3. Choose Editor > Add Build Phase > Add Run Script Build Phase.
  4. Disclose the Run Script section in the project editor.
  5. Configure the script in the Run Script template.

这篇关于Apple Watch的预建操作以更改情节提要customModule引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 07:40