在 Xcode 上使用 App 和扩展复制 WatchOS2 的目标 [英] Duplicating target for WatchOS2 with App and Extension on Xcode

查看:20
本文介绍了在 Xcode 上使用 App 和扩展复制 WatchOS2 的目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 WatchOS2 目标和扩展的项目.我想复制 WatchOS App 目标和扩展.但是,当我复制 WatchOS App 目标时,它仍然链接到旧扩展.由于我们不再可以访问 WatchOS 应用程序的构建阶段,因此我无法在嵌入应用程序扩展阶段更改它.

I have a project with a WatchOS2 target along with an Extension. I want to duplicate both the WatchOS App target and the extension. However, when I duplicate the WatchOS App target it is still linked to the old extension. Since we no longer have access to build phases for WatchOS App I cannot change it in the Embed App Extension Phase.

  • WatchAppTarget1(嵌入扩展 - WatchAppExtension1)
  • WatchAppExtension1
  • WatchAppTarget1(嵌入扩展 - WatchAppExtension1)
  • WatchAppExtension1
  • WatchAppTarget-Duplicate(嵌入扩展仍然指向 - WatchAppExtension1)
  • WatchAppExtension-重复

无论如何更改 WatchOS 应用程序目标以接受重复的扩展作为其嵌入的选择(手动编辑 .pbxproj 除外)

Is there anyway of changing the WatchOS App Target to accept the duplicated Extension as its choice to embed (other than manually editing the .pbxproj)

推荐答案

现在,我在浪费了大量时间后发现实现这一目标的最不刺激的方法是将 WatchOS 应用程序更改为一个框架,因此 Xcode 提供了构建阶段部分.

For now least irritating way I found to achieve this after wasting lots of hours is by changing the WatchOS app to behave like a framework so Xcode provides the Build phases section.

在文本编辑器中打开 project.pbxproj,转到类似/* Begin PBXNativeTarget section */ 的部分,找到您的 WatchOS 目标(您想要的目标)要更改)在配置中,它应该有一行:

Open the project.pbxproj in a text editor, go to the section which goes like/* Begin PBXNativeTarget section */ find your WatchOS target (the one you want to change) in the configuration, it should have a line :

productType = "com.apple.product-type.application.watchapp2";

将其更改为:

productType = "com.apple.product-type.application";productType = "com.apple.product-type.framework";

现在在 Xcode 中打开项目,你应该是苹果,看到 Build Phases 部分,去那里删除Target Dependencies"和Embed App Extension"中的旧扩展引用,并用新的替换它.完成后返回 project.pbxproj 并撤消更改并使 WatchOS 目标返回 productType = "com.apple.product-type.application.watchapp2";

Now open the project in Xcode you should be apple to see the Build Phases section, go there and remove the old extension references in "Target Dependencies" and "Embed App Extension" and replace it with the new ones. Once you are done go back to the project.pbxproj and undo your change and make the WatchOS target back to productType = "com.apple.product-type.application.watchapp2";

有时您可能需要为 WatchOS 和 iOS 应用程序制定新的构建方案,但这应该可以解决问题!

Sometimes you might have to make a fresh build scheme for both the WatchOS and the iOS app, but this should do the trick!

这篇关于在 Xcode 上使用 App 和扩展复制 WatchOS2 的目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆