Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

No more than one component displaying, including the default components

Abierto
#42 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
swift, typescript
Área
mobile-dev

Línea de trabajo

Reproduce los fallos de visualización y de actualización de datos de la primera compilación y, después, inspecciona watchappApp.swift, AppDelegate.swift y las llamadas a Watch.updateWatchUI y Watch.updateWatchData mostradas en el informe. Compara el comportamiento de la UI de Watch predeterminada y personalizada, y usa el error de actualización de datos informado como punto de partida para el diagnóstico. Se considera terminado cuando todos los componentes previstos se muestran y los datos de Watch se actualizan sin el error informado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Swift
Estrellas
49
Forks
11
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ionic-team/CapacitorWatch

Todos los issues de ionic-team/CapacitorWatch

Issues similares

Más issues de Swift

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.