ionic-team / CapacitorWatch

Build apps for watches with Capacitor
MIT License
43 stars 6 forks source link

Cannot find "CapWatchSessionDelegate" in scope #30

Closed CrixuAMG closed 1 year ago

CrixuAMG commented 1 year ago

After following the steps as defined, I tried to build an app and got the error in the subject of this issue. Can anyone assist with this issue? Perhaps I am missing some step?

Thanks!

CrixuAMG commented 1 year ago

I forgot to add relevant information, hope this helps:

Xcode 15 beta 6 (15A5219j)

Dependencies:

  "dependencies": {
    "@capacitor/android": "^5.2.3",
    "@capacitor/core": "^5.2.3",
    "@capacitor/ios": "^5.2.3",
    "axios": "^1.4.0",
    "core-js": "^3.8.3",
    "lodash-es": "^4.17.21",
    "register-service-worker": "^1.7.2",
    "vue": "^3.2.13",
    "vue-router": "^4.0.3",
    "vue3-qr-reader": "^1.0.0"
  },
  "devDependencies": {
    "@capacitor/cli": "^5.2.3",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-pwa": "~5.0.0",
    "@vue/cli-plugin-router": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "sass": "^1.32.7",
    "sass-loader": "^13.3.2"
  }

Error comes from the AppDelegate.swift file.

Please let me know if you require anything else!

giralte-ionic commented 1 year ago

It seems like you're missing @capacitor/watch from your dependancies.

CrixuAMG commented 1 year ago

@giralte-ionic it is present in my package.json, as shown below.

"dependencies": {
    ...
    "@capacitor/watch": "^0.1.7",
    ...
}

When I try to build my app using this package it results in the following exception:

✔ Copying web assets from dist to android/app/src/main/assets/public in 12.58ms
✔ Creating capacitor.config.json in android/app/src/main/assets in 573.42μs
✔ copy android in 20.29ms
✔ Updating Android plugins in 1.08ms
[info] Found 1 Capacitor plugin for android:
       @capacitor/watch@0.1.7
✔ update android in 26.78ms
✔ Copying web assets from dist to ios/App/App/public in 17.18ms
✔ Creating capacitor.config.json in ios/App/App in 709.13μs
✔ copy ios in 22.78ms
✔ Updating iOS plugins in 1.53ms
[info] Found 1 Capacitor plugin for ios:
       @capacitor/watch@0.1.7
✖ Updating iOS native dependencies with pod install - failed!
✖ update ios - failed!
[error] Analyzing dependencies
        Searching for inspections failed: undefined method `map' for nil:NilClass

        ――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

        ### Command
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod install
    ```

    ### Report

    * What did you do?

    * What did you expect to happen?

    * What happened instead?

    ### Stack

    ```
    CocoaPods : 1.12.1
    Ruby : ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]
    RubyGems : 3.4.10
    Host : macOS 13.5 (22G74)
    Xcode : 14.3.1 (14E300c)
    Git : git version 2.40.0
    Ruby lib dir : /opt/homebrew/Cellar/ruby/3.2.2_1/lib
    Repositories : trunk - CDN - https://cdn.cocoapods.org/
    ```

    ### Plugins

    ```
    cocoapods-deintegrate : 1.0.5
    cocoapods-plugins     : 1.0.0
    cocoapods-search      : 1.0.1
    cocoapods-trunk       : 1.6.0
    cocoapods-try         : 1.2.0
    ```

    ### Podfile

    ```ruby
    require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers'

    platform :ios, '13.0'
    use_frameworks!

    # workaround to avoid Xcode caching of Pods that requires
    # Product -> Clean Build Folder after new Cordova plugins installed
    # Requires CocoaPods 1.6 or newer
    install! 'cocoapods', :disable_input_output_paths => true

    def capacitor_pods
    pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
    pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
    pod 'CapacitorWatch', :path => '../../node_modules/@capacitor/watch'
    end

    target 'App' do
    capacitor_pods
    # Add your Pods here
    end

    post_install do |installer|
    assertDeploymentTarget(installer)
    end
    ```

    ### Error

    ```
    RuntimeError - `PBXProject` attempted to initialize an object with unknown ISA `XCLocalSwiftPackageReference`
    from attributes: `{"isa"=>"XCLocalSwiftPackageReference",
    "relativePath"=>"../../node_modules/@capacitor/watch/CapWatch-Watch-SPM"}`
    If this ISA was generated by Xcode please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object.rb:359:in
    `rescue in object_with_uuid'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object.rb:349:in
    `object_with_uuid'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object.rb:300:in
    `block (2 levels) in configure_with_plist'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object.rb:299:in
    `each'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object.rb:299:in
    `block in configure_with_plist'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object.rb:296:in
    `each'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project/object.rb:296:in
    `configure_with_plist'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project.rb:272:in
    `new_from_plist'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project.rb:213:in
    `initialize_from_file'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/xcodeproj-1.22.0/lib/xcodeproj/project.rb:113:in `open'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1194:in
    `block (2 levels) in inspect_targets_to_integrate'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1193:in
    `each'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1193:in
    `block in inspect_targets_to_integrate'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in
    `section'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:1188:in
    `inspect_targets_to_integrate'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/analyzer.rb:107:in
    `analyze'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:422:in `analyze'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:244:in `block in
    resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in
    `section'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:243:in
    `resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:162:in `install!'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command/install.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/bin/pod:55:in `<top (required)>'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `load'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `<main>'
    ```

    ――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

    [!] Oh no, an error occurred.

    Search for existing GitHub issues similar to yours:
    https://github.com/CocoaPods/CocoaPods/search?q=%60PBXProject%60+attempted+to+initialize+an+object+with+unknown+ISA+%60XCLocalSwiftPackageReference%60+from+attributes%3A+%60%7B%22isa%22%3D%3E%22XCLocalSwiftPackageReference%22%2C+%22relativePath%22%3D%3E%22..%2F..%2Fnode_modules%2F%40capacitor%2Fwatch%2FCapWatch-Watch-SPM%22%7D%60%0AIf+this+ISA+was+generated+by+Xcode+please+file+an+issue%3A+https%3A%2F%2Fgithub.com%2FCocoaPods%2FXcodeproj%2Fissues%2Fnew&type=Issues

    If none exists, create a ticket, with the template displayed above, on:
    https://github.com/CocoaPods/CocoaPods/issues/new

    Be sure to first read the contributing guide for details on how to properly submit a ticket:
    https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

    Don't forget to anonymize any private data!

    Looking for related issues on cocoapods/cocoapods...

error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

giralte-ionic commented 1 year ago

try adding import CapacitorWatch to the top of your AppDelegate.swift file. The top should look like so:

import UIKit
import Capacitor
import WatchConnectivity
import CapacitorWatch

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

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

0.1.8 fixes the missing import statement in the documentation, please let me know if this solved your issue

CrixuAMG commented 1 year ago

Thanks for the update! I'll try it out as soon as I'm able to and I'll let you know if it works!

giralte-ionic commented 1 year ago

@CrixuAMG any feedback? I would like to close this issue

CrixuAMG commented 1 year ago

My apologies for the late answer, it's been very busy and as such I've missed the notification from github. I haven't been able to fully test it yet, but will close the issue for now to test it at a later moment. Thanks for the update and your patience!