Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Resolved] Failed to build with a lot of swift notes, warnings and errors (Phonegap Build) #397

Closed
abardik opened this issue Oct 3, 2019 · 27 comments
Assignees
Milestone

Comments

@abardik
Copy link

abardik commented Oct 3, 2019

I use iosrtc in Phonegap Build project and now try to upgrade the plugin from 4.0.2 to 5.0.*, but it failed with a huge amount of swift notes, warnings and errors. I set cli to 9.0.0 (cordova-ios 5.0.1), also tried cli 8.1.1 (cordova-ios 4.5.5), but result is the same.

The amount of warnings and errors is just huge. So, I copy just some of them here:

/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginRTCPeerConnection.swift:492:72: warning: using '!' here is deprecated and will be removed in a future release
                let state_str = PluginRTCTypes.signalingStates[newState.rawValue] as String!
                                                                                     ^
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginRTCPeerConnection.swift:498:22: warning: expression implicitly coerced from 'String?' to 'Any'
                        "signalingState": state_str
                                          ^~~~~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginRTCPeerConnection.swift:498:22: note: provide a default value to avoid this warning
                        "signalingState": state_str
                                          ^~~~~~~~~
                                                    ?? <#default value#>

And some errors:

/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:107:29: error: type 'AVAudioSession.Port' (aka 'NSString') has no member 'builtInMic'
                if audioInput.portType == AVAudioSession.Port.builtInMic {
                                          ^~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:111:26: error: generic parameter 'S' could not be inferred
                if audioInput.portType == .bluetoothHFP || audioInput.portType == .bluetoothA2DP {
                                       ^
Swift.StringProtocol:2:24: note: in call to operator '=='
    public static func == <S>(lhs: Self, rhs: S) -> Bool where S : StringProtocol
                       ^
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:116:26: error: generic parameter 'S' could not be inferred
                if audioInput.portType == .usbAudio || audioInput.portType == .headsetMic {
                                       ^
Swift.StringProtocol:2:24: note: in call to operator '=='
    public static func == <S>(lhs: Self, rhs: S) -> Bool where S : StringProtocol
                       ^
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:137:32: error: type 'AVAudioSession.Category' (aka 'NSString') has no member 'playAndRecord'
                try audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: AVAudioSession.Mode.default, options: .allowBluetooth)
                                             ^~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginMediaStreamRenderer.swift:193:28: error: 'bringSubviewToFront' has been renamed to 'bringSubview(toFront:)'
                        self.webView.superview?.bringSubviewToFront(self.elementView)
                                                ^~~~~~~~~~~~~~~~~~~
                                                bringSubview        toFront: 
UIKit.UIView:17:15: note: 'bringSubviewToFront' was obsoleted in Swift 3
    open func bringSubviewToFront(_ view: UIView)

Please, give me an advice what to do to fix this issue?

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

@abardik I would bet you are not using the minimum required iOS target 10.2 that why you get this error.
See requirements https://github.com/cordova-rtc/cordova-plugin-iosrtc#requirements

Finally the warning are only warning and do not cause issues.
Make sure to remove and add iOS platform to trigger the hook on iOS.

cordova plugin remove cordova-plugin-iosrtc --verbose
cordova plugin add https://github.com/cordova-rtc/cordova-plugin-iosrtc#master --verbose
cordova platform remove ios --no-save
cordova platform add ios --no-save

Note: I use master in the example above so you can get the last version as 5.0.4 will be released soon.

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

Note, when you create an issue we ask you iOS and Xcode version on the template, make sure to provide it next time. https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/ISSUE_TEMPLATE.md

@abardik
Copy link
Author

abardik commented Oct 3, 2019

@hthetiot I can not use any of those commands in Phonegap Build. I just can modify config.xml. And for 4.0.2 it works fine:

	<preference name='phonegap-version' value='cli-9.0.0'/>
	<platform name="ios">
		<plugin name="cordova-plugin-iosrtc" spec="4.0.2"/>
	</platform>

But when I change spec to 5.0.* I got all those errors.
Is it possible to use 5.0.* with Phonegap Build like previous versions?
Thanks.

@abardik
Copy link
Author

abardik commented Oct 3, 2019

I did not provide iOS and xCode version because I don't use them. I use Phonegap Build:
https://build.phonegap.com

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

I did not provide iOS and xCode version because I don't use them. I use Phonegap Build:
https://build.phonegap.com

Ok, I see, well you still need to target iOS 10.2 + if you want to use 5.0.1+ to use new AVAudioSession API.

http://docs.phonegap.com/phonegap-build/configuring/preferences/#deployment-target

@hthetiot hthetiot added this to the 5.0.x milestone Oct 3, 2019
@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

Note: not sure it is the case, but you should not commit platforms/ios in your source, so it can be added and trigger the hook that does setup the min platform.

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

Note: We going to migrate to cordova@5+ to solve some hook issues, that may be related to why you dont get the hook fully trigger see https://github.com/cordova-rtc/cordova-plugin-iosrtc/pull/376/files

<engine name="ios" spec="~5.0.1" />

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

I did not provide iOS and xCode version because I don't use them. I use Phonegap Build:
https://build.phonegap.com

That change nothing actually, you can still run this command locally to update config.xml then push to get phonegap to build. We use Travis here to fully build the IPA and it's free and works great on 5.0.1+ and using last Xcode 10 and 11.

Closing the issue for now, if you comment i will continue to assist you.

@hthetiot hthetiot closed this as completed Oct 3, 2019
@abardik
Copy link
Author

abardik commented Oct 3, 2019

Phonegap Build shows the following:
image
So, I thought, that ios 5.0.1 is exactly what this plugin requires.
Thank you for the info, I'll try to make it working.

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

@abardik Thank you.

Keep us posted, I may add documentation if you find what the right way to have 5+ build on phonegap build, I still think the reason you have this error is because your ios Target is below 10.2.

May be your target is higher like iOS 13 and this API also changed, but people have built on iOS 13 succesfully so i doubt it, this may help us if you find the used target in your logs.

Try adding this it should fix your issue.

          <preference name="deployment-target" value="10.2" />

Note: Alternatively, 5.0.1 should still support iOs Target 9+

https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/CHANGELOG.md#version-502

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

I confirm they did rename bringSubview(toFront:) back to bringSubviewToFront after iOS 10.2 on swift 4.2+.

Screen Shot 2019-10-03 at 11 45 47 AM

Screen Shot 2019-10-03 at 11 47 27 AM

Screen Shot 2019-10-03 at 11 47 43 AM

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

<plugin name="cordova-plugin-iosrtc" spec="https://github.com/cordova-rtc/cordova-plugin-iosrtc#master" />

If you can't run cordova command locally.

@abardik
Copy link
Author

abardik commented Oct 3, 2019

I tried some combinations of:

<preference name="deployment-target" value="10.1"/>
<!--<plugin name="cordova-plugin-iosrtc" spec="5.0.1"/>-->
<plugin name="cordova-plugin-iosrtc" spec="https://github.com/cordova-rtc/cordova-plugin-iosrtc#master"/>

But still got those errors:

/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginGetUserMedia.swift:50:46: error: incorrect argument label in call (have 'for:', expected 'forMediaType:')
                        switch AVCaptureDevice.authorizationStatus(for: AVMediaType(rawValue: convertFromAVMediaType(AVMediaType.video))) {
                                                                  ^~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:77:14: error: type 'AVMediaType' (aka 'NSString') has no member 'video'
                mediaType: AVMediaType.video,
                           ^~~~~~~~~~~ ~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:83:83: error: type 'AVMediaType' (aka 'NSString') has no member 'audio'
                let hasAudio = device.hasMediaType(AVMediaType(rawValue: convertFromAVMediaType(AVMediaType.audio)))
                                                                                                ^~~~~~~~~~~ ~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:84:83: error: type 'AVMediaType' (aka 'NSString') has no member 'video'
                let hasVideo = device.hasMediaType(AVMediaType(rawValue: convertFromAVMediaType(AVMediaType.video)))
                                                                                                ^~~~~~~~~~~ ~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:142:29: error: type 'AVAudioSession.Port' (aka 'NSString') has no member 'builtInMic'
                if audioInput.portType == AVAudioSession.Port.builtInMic {
                                          ^~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:146:26: error: generic parameter 'S' could not be inferred
                if audioInput.portType == .bluetoothHFP || audioInput.portType == .bluetoothA2DP {
                                       ^
Swift.StringProtocol:2:24: note: in call to operator '=='
    public static func == <S>(lhs: Self, rhs: S) -> Bool where S : StringProtocol
                       ^
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:151:26: error: generic parameter 'S' could not be inferred
                if audioInput.portType == .usbAudio || audioInput.portType == .headsetMic {
                                       ^
Swift.StringProtocol:2:24: note: in call to operator '=='
    public static func == <S>(lhs: Self, rhs: S) -> Bool where S : StringProtocol
                       ^
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:172:32: error: type 'AVAudioSession.Category' (aka 'NSString') has no member 'playAndRecord'
                try audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: AVAudioSession.Mode.default, options: .allowBluetooth)
                                             ^~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift:181:9: error: value of type 'AVMediaType' (aka 'NSString') has no member 'rawValue'
        return input.rawValue
               ^~~~~ ~~~~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginMediaStreamRenderer.swift:193:28: error: 'bringSubviewToFront' has been renamed to 'bringSubview(toFront:)'
                        self.webView.superview?.bringSubviewToFront(self.elementView)
                                                ^~~~~~~~~~~~~~~~~~~
                                                bringSubview        toFront: 
UIKit.UIView:17:15: note: 'bringSubviewToFront' was obsoleted in Swift 3
    open func bringSubviewToFront(_ view: UIView)
              ^

** ARCHIVE FAILED **


The following build commands failed:
	CompileSwift normal armv7 /project/InRemote/Plugins/cordova-plugin-iosrtc/PluginGetUserMedia.swift
	CompileSwift normal armv7 /project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift
	CompileSwift normal armv7 /project/InRemote/Plugins/cordova-plugin-iosrtc/PluginMediaStreamRenderer.swift
	CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
	CompileSwift normal arm64 /project/InRemote/Plugins/cordova-plugin-iosrtc/PluginGetUserMedia.swift
	CompileSwift normal arm64 /project/InRemote/Plugins/cordova-plugin-iosrtc/PluginEnumerateDevices.swift
	CompileSwift normal arm64 /project/InRemote/Plugins/cordova-plugin-iosrtc/PluginMediaStreamRenderer.swift
(7 failures)
Error: xcodebuild: Command failed with exit code 65
    at ChildProcess.whenDone (/private/project/cordova/node_modules/cordova-common/src/superspawn.js:135:23)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
                                                                   forMediaType
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginGetUserMedia.swift:67:46: error: incorrect argument label in call (have 'for:', expected 'forMediaType:')
                        switch AVCaptureDevice.authorizationStatus(for: AVMediaType(rawValue: convertFromAVMediaType(AVMediaType.audio))) {
                                                                  ^~~~
                                                                   forMediaType
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginGetUserMedia.swift:89:180: error: type 'AVMediaType' (aka 'NSString') has no member 'video'
                                videoDevice = AVCaptureDevice.DiscoverySession.init(deviceTypes: [AVCaptureDevice.DeviceType.builtInWideAngleCamera, AVCaptureDevice.DeviceType.builtInDualCamera], mediaType: AVMediaType.video, position: AVCaptureDevice.Position.front).devices[0]
                                                                                                                                                                                                               ^~~~~~~~~~~ ~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginGetUserMedia.swift:95:204: error: type 'AVMediaType' (aka 'NSString') has no member 'video'
                                let videoDevices: [AVCaptureDevice] = AVCaptureDevice.DiscoverySession.init(deviceTypes: [AVCaptureDevice.DeviceType.builtInWideAngleCamera, AVCaptureDevice.DeviceType.builtInDualCamera], mediaType: AVMediaType.video, position: AVCaptureDevice.Position.unspecified).devices
                                                                                                                                                                                                                                       ^~~~~~~~~~~ ~~~~~
/project/InRemote/Plugins/cordova-plugin-iosrtc/PluginGetUserMedia.swift:192:9: error: value of type 'AVMediaType' (aka 'NSString') has no member 'rawValue'
        return input.rawValue
               ^~~~~ ~~~~~~~~

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

<preference name="deployment-target" value="10.2"/>
10.2 not 10.1 @abardik

Sorry i edited comment afterward that why you used wrong version.

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

See original comment on changes and 10.2 requirements

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

Note: we can confirm that the issue if you try to use 5.0.0 that still support ios target 9

@abardik
Copy link
Author

abardik commented Oct 3, 2019

I tried all of them: 10.1 and 10.2 with latest #master, and 9 with 5.0.0 and 5.0.1. The same result.

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

Sorry man cannot help you more.
The issue is the target version you can simpy confirm that by looking at this comment.

Try to provide you full build logs so we can see the target version and Xcode version.
Try to purge build cache if there is any.

Version 5 does work on last Xcode otherwise other people would have complained, the issue is with Phonegap build.

Alternativly try a sample app and see if it build on phone gap.

- "cordova create myApp org.apache.cordova.myApp myApp; cd myApp;"
  - "cordova plugin add cordova-plugin-iosrtc --verbose"
  - "cordova platform add ios"
  - "cordova build ios"

Then add proper signing and config in build.json and upload to phone gap build. But it look to me they dont even support last Xcode anyway.

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

See Adbobe support for iOS target.

Example:

Hi,

Thank You for reporting the issue!

Since the @available API has been made available since iOS 11, make sure that you are packaging the ANE for iOS version 11. You can do so by setting linkerOptions and sdkVersion in your platform.xml for packaging ANE. Below is a sample platform.xml for doing so:

<platform xmlns="http://ns.adobe.com/air/extension/30.0">

      <sdkVersion>11.0.0</sdkVersion>

      <linkerOptions>

          <option>-ios_version_min 11.0</option>

      </linkerOptions>

</platform>

https://community.adobe.com/t5/Air/available-in-XCode-causes-Undefined-symbols-error/m-p/9353855

Keep me posted, Sorry i cant help you more.
Travis or local build is the best, it's clear phonegap is not using latest required Xcode 10.3 (10G8) anyway.

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

AVMediaType' (aka 'NSString') has no member 'video'

"Changing the swift language version from "3.3" to "4.1" solved the issue for me."

https://stackoverflow.com/questions/45147649/error-type-string-has-no-member-video

That the proof that you are not using swift 4.2 @abardik

@abardik
Copy link
Author

abardik commented Oct 3, 2019

@hthetiot You were right, and I just didn't know how to configure Phonegap Build properly (never met issues like this before). It's done, finally, with the following preferences in config.xml:

<preference name='phonegap-version' value='cli-9.0.0'/>
<platform name="ios">
	<plugin name="cordova-plugin-add-swift-support"/>
	<preference name="swift-version" value="4.2"/>
	<preference name="deployment-target" value="10.2"/>
	<plugin name="cordova-plugin-iosrtc" spec="https://github.com/cordova-rtc/cordova-plugin-iosrtc#master"/>
</platform>

I think, it would be helpful to add a note about Phonegap Build with this config to the Installation part of README.

Thank you for the support and useful advices.

@hthetiot hthetiot modified the milestones: 5.0.x, 5.0.4 Oct 3, 2019
@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

I'm really happy you figured out.
I will update the documentation on 5.0.x and possibly look into cordova-plugin-add-swift-support to include what they do inside the plugin.xml and iosrtc hook (https://github.com/cordova-rtc/cordova-plugin-iosrtc/blob/master/extra/hooks/iosrtc-swift-support.js) to avoid the usage of an extras plugin like you did to set the swift version.

Thank you for your contribution.

Happy RTC.

Note: Will leave that issue open until phonegap build doc released and iosrtc hook updated to work like cordova-plugin-add-swift-support.

@hthetiot hthetiot reopened this Oct 3, 2019
@hthetiot hthetiot changed the title Failed to build with a lot of swift notes, warnings and errors (Phonegap Build) [Resolved] Failed to build with a lot of swift notes, warnings and errors (Phonegap Build) Oct 3, 2019
@abardik
Copy link
Author

abardik commented Oct 3, 2019

For the case, 5.0.1 can be compiled with the same config (it's regarding the breaking changes in WebRTC API in 5.0.2+ where old-API-style data channels and media connections are not working anymore).

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

@abardik I have added throw error on API Callbacks usage to help migration over Promise based WebRTC API see Changelogs preview for 5.0.4

Detect callbacks usage and throw error instead of been silent to assist 5.0.1 to 5.0.2 migration from callback based API.

See original changes on 5.0.2

Remove callback based API

For details about the callbacks issue see:

Note: Removing Callback API was part of the TODO list from original maintainer that I will complete as my duty.

JS: Remove callback based API (it's from 2014) and just use the new promise based API (currently both are implemented, but the code looks a bit hard to maintain this way).

@hthetiot
Copy link
Contributor

hthetiot commented Oct 3, 2019

@abardik Please don't add topics to this issue, it will confuse people and I requested on other issues to others that topic of issue been respected. Feel free to create other issue if needed. I will assist as I proven today but respecting the topic is important for me. Thank you.

@abardik
Copy link
Author

abardik commented Oct 4, 2019

@hthetiot Yes, I read about new API. Just mentioned it here in the context of 5.0.1 config for Phonegap Build.

@hthetiot
Copy link
Contributor

hthetiot commented Oct 5, 2019

The current case of using phonegap build and not adding platform after the plugin should be resolved by this PR. #402

@hthetiot hthetiot closed this as completed Oct 5, 2019
@hthetiot hthetiot modified the milestones: 5.0.x, 5.1.x, 5.0.5 Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants