防止在 Xcode 中使用 iOS iPhone 应用程序部署(禁用)WatchKit 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30426501/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:11:37  来源:igfitidea点击:

Prevent deploying (disable) WatchKit App with iOS iPhone App in Xcode

iosxcodewatchkit

提问by Gaurav Sharma

We've got an Xcode project with build configurations for the Apple Watch as well. Our Apple Watch app isn't ready yet, so we'd like to release with it disabled. What's the best way to disable Apple Watch functionality in a build?

我们也有一个包含 Apple Watch 构建配置的 Xcode 项目。我们的 Apple Watch 应用程序还没有准备好,所以我们想在禁用它的情况下发布。在构建中禁用 Apple Watch 功能的最佳方法是什么?

回答by vomako

Remove the WatchKit extension

删除 WatchKit 扩展

To make sure that your WatchKit extension is no longer visible, you have to do two things:

为了确保你的 WatchKit 扩展不再可见,你必须做两件事:

1) Remove the WatchKit extension from "Target Dependencies"

1) 从“目标依赖项”中删除 WatchKit 扩展

  • (To go to Target Dependencies: in the project navigator, click the project file. Then click the target of the iPhone app. Go to the Build Phases tab.)
  • (转到 Target Dependencies:在项目导航器中,单击项目文件。然后单击 iPhone 应用程序的目标。转到 Build Phases 选项卡。)

2) Remove the WatchKit extension from "Embed App Extensions" (in Xcode 7+, "Embed Watch Content")

2) 从“Embed App Extensions”中移除 WatchKit 扩展(在 Xcode 7+ 中,“Embed Watch Content”)

  • (In Build Phases, go to Embed App Extensions. Remove the WatchKit extension entry from the list Embed App Extensions.)
  • (在 Build Phases 中,转到 Embed App Extensions。从 Embed App Extensions 列表中删除 WatchKit 扩展条目。)

Finally, you may have to clean your build folder. Then build and run your iPhone application.

最后,您可能需要清理构建文件夹。然后构建并运行您的 iPhone 应用程序。

To re-add the WatchKit extension:

重新添加 WatchKit 扩展:

For watchOS1: FIRST, add your WatchKit extension to Target Dependencies. This re-creates the .appexfile that you can now add to the list under Embed App Extensions by pressing the plus button and choosing "App NameWatchKit Extension.appex".

对于 watchOS1:首先,将 WatchKit 扩展添加到目标依赖项。这将重新创建.appex文件,您现在可以通过按加号按钮并选择“ App NameWatchKit Extension.appex”将其添加到 Embed App Extensions 下的列表中。

For watchOS2: Just add your WatchKit extension to Target Dependencies.

对于 watchOS2:只需将您的 WatchKit 扩展添加到目标依赖项。

Remarks:

评论:

  • I have tried the whole process of removing and recreating the extension both in the simulator and on the actual devices (iPhone and Apple Watch). It worked in both cases.
  • I have also tried to do either A or B but that was not sufficient.
  • I used Xcode version 6.3.2
  • 我已经尝试了在模拟器和实际设备(iPhone 和 Apple Watch)上删除和重新创建扩展的整个过程。它在两种情况下都有效。
  • 我也试过做 A 或 B,但这还不够。
  • 我使用 Xcode 版本 6.3.2