voxeet / voxeet-uxkit-cordova

Dolby.io UXKit for Cordova
Other
1 stars 14 forks source link

[Feature] Add Capacitor compatibility by default #47

Open gabides opened 3 years ago

gabides commented 3 years ago

Describe the bug

Capacitor is a cross-platform framework, similar to cordova but with better performances https://capacitorjs.com/ Capacitor supports cordova plugins, but not all cordova plugins are compatible. The voxeet-cordova-plugin works fine for Android, but it isn't compatible by default for iOS, we had it working with some fixes scripts.

Expected Behaviour Inside package.json in your capacitor application, add cordova-voxeet-plugin :

Then run the following to build the project:

npm i
npx cap sync ios
npx cap open ios

Then in XCode set a new bundle id, you apple development Team, plug a device and try to build on the device. This should succeed if the plugin was compatible with Capacitor iOS.

Steps to Reproduce the Problem

Issue 1 :

npx cap sync ios fails with the following error :

✔ Copying web assets from www to ios/App/public in 12.25ms
✔ Copying native bridge in 1.36ms
✔ Copying capacitor.config.json in 1.43ms
  Found 1 Cordova plugin for ios
    cordova-plugin-voxeet (1.4.6)
✔ copy in 73.33ms
✔ Updating iOS plugins in 9.10ms
  Found 0 Capacitor plugins for ios:
✖ update ios: ENOENT: no such file or directory, stat '/Users/WORKDIR/capacitor-voxeet-test/node_modules/cordova-plugin-voxeet/src/ios/Carthage/Build/iOS/VoxeetUXKit.framework'
[error] Error: ENOENT: no such file or directory, stat '/Users/WORKDIR/capacitor-voxeet-test/node_modules/cordova-plugin-voxeet/src/ios/Carthage/Build/iOS/VoxeetUXKit.framework'
    at Object.statSync (fs.js:1086:3)
    at Object.statSync (/Users/WORKDIR/capacitor-voxeet-test/node_modules/graceful-fs/polyfills.js:308:16)
    at Object.copySync (/Users/WORKDIR/capacitor-voxeet-test/node_modules/fs-extra/lib/copy-sync/copy-sync.js:31:86)
    at /Users/WORKDIR/capacitor-voxeet-test/node_modules/@capacitor/cli/dist/ios/update.js:315:22
    at Array.map (<anonymous>)
    at /Users/WORKDIR/capacitor-voxeet-test/node_modules/@capacitor/cli/dist/ios/update.js:313:20
    at Array.map (<anonymous>)
    at copyPluginsNativeFiles (/Users/WORKDIR/capacitor-voxeet-test/node_modules/@capacitor/cli/dist/ios/update.js:259:20)
    at Object.updateIOS (/Users/WORKDIR/capacitor-voxeet-test/node_modules/@capacitor/cli/dist/ios/update.js:27:9)
    at async /Users/WORKDIR/capacitor-voxeet-test/node_modules/@capacitor/cli/dist/tasks/update.js:65:13 {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: '/Users/WORKDIR/capacitor-voxeet-test/node_modules/cordova-plugin-voxeet/src/ios/Carthage/Build/iOS/VoxeetUXKit.framework'
}

This error happens because the native ios frameworks of the plugin are not built. This is due to the fact that capacitor, unlike cordova, doesn't have any hook, so the frameworks build is not triggered when the plugin is added.

This could be solved two ways :

Issue 2 : If the above is fixed, another issue happen when building the app from XCode :

ld: warning: Could not find or use auto-linked framework 'VoxeetSDK'
ld: warning: Could not find or use auto-linked framework 'VoxeetUXKit'
ld: warning: Could not find or use auto-linked framework 'WebRTC'
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$__TtC9VoxeetSDK13VTJoinOptions", referenced from:
      objc-class-ref in CDVVoxeet.o
  "_OBJC_CLASS_$__TtC9VoxeetSDK19VTConferenceOptions", referenced from:
      objc-class-ref in CDVVoxeet.o
  "_OBJC_CLASS_$__TtC9VoxeetSDK17VTParticipantInfo", referenced from:
      objc-class-ref in CDVVoxeet.o
  "_OBJC_CLASS_$__TtC11VoxeetUXKit11VoxeetUXKit", referenced from:
      objc-class-ref in CDVVoxeet.o
  "_OBJC_CLASS_$__TtC9VoxeetSDK9VoxeetSDK", referenced from:
      objc-class-ref in CDVVoxeet.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This can be solved by disabling bitcode and running the following script : https://github.com/Yoobic/capacitor-voxeet-test/blob/master/plugin_fix2.sh

Any inputs here are welcome, not sure how to fix this another way, or to run the fix within the plugin's code.

Minimalistic code (recommended) Here is a repository to reproduce the 2 issues, with code showing the possible fixes (implemented inside the test project and not in the plugin's code): https://github.com/Yoobic/capacitor-voxeet-test

Another solution would be to directly create a capacitor plugin : https://capacitorjs.com/docs/plugins/creating-plugins