Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

No more than one component displaying, including the default components

オープン
#42 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
swift, typescript
領域
mobile-dev

調査の方向性

初回ビルド時の表示失敗とデータ更新失敗を再現し、その後、watchappApp.swift、AppDelegate.swift、およびレポートに示されている Watch.updateWatchUI と Watch.updateWatchData の呼び出しを調べます。デフォルトの Watch UI とカスタムの Watch UI の動作を比較し、報告されたデータ更新エラーを診断の出発点として使用します。すべての意図したコンポーネントが表示され、報告されたエラーなしで Watch データが更新されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

When I run the app for the first time after build, it only shows 'Capacitor WATCH' - no button. and when i update the ui with my own items, it only displays the first item in the list.

Here's my .tsx:

const [t1, setT1] = useState("");

  async function uploadWatchUI1() {
    const watchUI = `Text("Capacitor n")
         Button("Add One", "inc")`;

    await Watch.updateWatchUI({ watchUI: watchUI });
  }

  async function updateData1() {
    var stateData = {
      variable: "data1",
    };

    await Watch.updateWatchData({ data: stateData });
  }

  async function updateData2() {
    var stateData = {
      variable: "data2",
    };

    await Watch.updateWatchData({ data: stateData });
  }

  useEffect(() => {
    Watch.addListener("runCommand", (data: { command: string }) => {
      console.log("PHONE got command - " + data.command);
      setT1(`Button was Pressed: ${data.command}`);
    });
  });

watchappApp.swift:

import SwiftUI
import WatchConnectivity
import iOS_capWatch_watch

@main
struct watchddgg_Watch_AppApp: App {
    var body: some Scene {
        WindowGroup {
            CapWatchContentView()
                .onAppear {
                    assert(WCSession.isSupported(), "This sample requires Watch Connectivity support!")
                    WCSession.default.delegate = WatchViewModel.shared
                    WCSession.default.activate()
                }
        }
    }
}

AppDelegate.swift:

import UIKit
import Capacitor
import WatchConnectivity
import CapacitorWatch
import CapacitorBackgroundRunner

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        assert(WCSession.isSupported(), "This sample requires Watch Connectivity support!")
        WCSession.default.delegate = CapWatchSessionDelegate.shared
        WCSession.default.activate()
        
        BackgroundRunnerPlugin.registerBackgroundTask()
        BackgroundRunnerPlugin.handleApplicationDidFinishLaunching(launchOptions: launchOptions)
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
        // Called when the app was launched with a url. Feel free to add additional processing here,
        // but if you want the App API to support tracking app url opens, make sure to keep this call
        return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
    }

    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        // Called when the app was launched with an activity, including Universal Links.
        // Feel free to add additional processing here, but if you want the App API to support
        // tracking app url opens, make sure to keep this call
        return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
    }
}

I have iOS-capWatch-watch added under Frameworks, Libraries, and Embedded Content:

Screenshot 2024-06-04 at 12 02 54 PM

Here's the error I get when I update the watch data:

Screenshot 2024-06-04 at 12 04 01 PM
主要言語
Swift
スター
49
フォーク
11
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ionic-team/CapacitorWatch のほかの issue

ionic-team/CapacitorWatch の issue をすべて見る

似ている issue

Swift の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。