如何在 Xcode 中创建 Apple Watch 应用程序或配置 Apple Watch 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27755282/
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 06:26:55  来源:igfitidea点击:

How to create Apple Watch app in Xcode or configure Apple Watch app

iosxcodeapple-watch

提问by jayesh kavathiya

How to create iWatch app with Xcode? or how to configure iWatch in existing project?

如何使用 Xcode 创建 iWatch 应用程序?或者如何在现有项目中配置 iWatch?

回答by Tejas Ardeshna

You must have an existing iOS app to create a WatchKit app. The WatchKit app is implemented as a separate target of your Xcode project and is built and packaged inside your iOS app's bundle.

您必须有一个现有的 iOS 应用程序才能创建 WatchKit 应用程序。WatchKit 应用程序作为 Xcode 项目的单独目标实现,并在 iOS 应用程序的包中构建和打包。

To add a WatchKit app target to your existing iOS app project

将 WatchKit 应用程序目标添加到您现有的 iOS 应用程序项目

1) In Xcode, open the project for your iOS app.

1) 在 Xcode 中,打开 iOS 应用程序的项目。

2) Select File > New > Target, and navigate to the Apple Watch section.

2) 选择文件 > 新建 > 目标,然后导航到 Apple Watch 部分。

3) Select WatchKit App, then click Next.

3) 选择WatchKit App,然后点击下一步。

4)If you plan to implement a glance or custom notification interface, select the appropriate checkboxes. For notification interfaces, it is recommended that you select the Include Notification Scene checkbox, even if you do not plan on implementing that interface right away. Selecting that checkbox adds an additional file to your project for debugging your notification interfaces. If you do not select that option, later you must create the file manually.

4)如果您计划实施一目了然或自定义通知界面,请选择适当的复选框。对于通知界面,建议您选中包括通知场景复选框,即使您不打算立即实现该界面。选中该复选框会向您的项目添加一个额外的文件,用于调试您的通知界面。如果您不选择该选项,则稍后您必须手动创建该文件。

5) Click Finish.

5) 单击完成。

Xcode configures the targets for your WatchKit app and WatchKit extension and adds the needed files to your iOS project. The bundle IDs for both new targets are configured automatically, based on the bundle ID of your iOS app. The base IDs for all three bundles must match; if you change your iOS app's bundle ID, you must update the other bundle IDs accordingly.

Xcode 为您的 WatchKit 应用程序和 WatchKit 扩展配置目标,并将所需的文件添加到您的 iOS 项目。两个新目标的包 ID 都是根据您的 iOS 应用程序的包 ID 自动配置的。所有三个捆绑包的基本 ID 必须匹配;如果您更改 iOS 应用程序的包 ID,则必须相应地更新其他包 ID。

see apples doc: HERE

见苹果文档:这里

回答by jayesh kavathiya

I am answering my own question

我正在回答我自己的问题

  1. List item create a new project select single view app
  2. fill project detail finish.
  3. now select file > target > in IOS section showing a apple watch select this
  4. press next then press finish
  5. now xcode ask "Activate “yourProjectName WatchKit App” scheme?" select active
  1. 列表项创建新项目选择单视图应用
  2. 填写项目细节完成。
  3. 现在选择文件>目标>在显示苹果手表的IOS部分选择这个
  4. 按下一步然后按完成
  5. 现在 xcode 问“激活“yourProjectName WatchKit App”方案?选择活动

now in your target showing a WatchKit Extension

现在在您的目标中显示 WatchKit 扩展

for more info goto apple link here

有关更多信息,请转到此处的苹果链接

回答by iSwaroop

An Apple Watch app is just an extension of the main app running on a paired iPhone.You must have an existing iOS app to create a WatchKit app. The WatchKit app is implemented as a separate target of your Xcode project and is built and packaged inside your iOS app's bundle.

Apple Watch 应用程序只是在配对的 iPhone 上运行的主应用程序的扩展。您必须拥有现有的 iOS 应用程序才能创建 WatchKit 应用程序。WatchKit 应用程序作为 Xcode 项目的单独目标实现,并在 iOS 应用程序的包中构建和打包。

This guide gives complete/detailed information about apple watch development including how to create Apple Watch app with Xcode.

本指南提供了有关 Apple Watch 开发的完整/详细信息,包括如何使用 Xcode 创建 Apple Watch 应用程序。

Apple Watch documentation

Apple Watch 文档