pusher_client icon indicating copy to clipboard operation
pusher_client copied to clipboard

Building for iOS fails

Open thijskuilman opened this issue 3 years ago • 22 comments

Steps to reproduce

  1. Install the latest Flutter version
  2. Create a new project
  3. Add pusher_client to the pubspec.yaml
  4. Execute flutter run (I'm building for the iPhone 12 Pro Max simulator)

Expected behavior

I'd expect the app to compile and run in the iOS simulator.

Actual behavior

I get the following error:

Failed to build iOS app
Error output from Xcode build:
↳
    objc[55793]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1f2527b78) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x113d702c8). One of the two will be used. Which one is undefined.
    objc[55793]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1f2527bc8) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x113d70318). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **


Xcode's output:
↳
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:59:25: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
            return try data.withUnsafeBytes { (bytes:UnsafePointer<UInt8>) -> Data in
                            ^
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:29: warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57: note: implicit argument conversion from '[UInt8]' to 'UnsafeMutablePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(_:)'
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                            ^~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57: note: use the 'withUnsafeMutableBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                            ^
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:33: warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
                    strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:61: note: implicit argument conversion from '[UInt8]' to 'UnsafeMutablePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(_:)'
                    strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                                ^~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:61: note: use the 'withUnsafeMutableBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
                    strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                                ^
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:140:14: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
            data.withUnsafeBytes { (ptr:UnsafePointer<UInt8>) -> Void in
                 ^
    Command CompileSwift failed with a nonzero exit code
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:59:25: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
            return try data.withUnsafeBytes { (bytes:UnsafePointer<UInt8>) -> Data in
                            ^
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:29: warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57: note: implicit argument conversion from '[UInt8]' to 'UnsafeMutablePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(_:)'
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                            ^~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57: note: use the 'withUnsafeMutableBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                            ^
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:33: warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
                    strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:61: note: implicit argument conversion from '[UInt8]' to 'UnsafeMutablePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(_:)'
                    strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                                ^~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:61: note: use the 'withUnsafeMutableBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
                    strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                                ^
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:140:14: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
            data.withUnsafeBytes { (ptr:UnsafePointer<UInt8>) -> Void in
                 ^
    Command CompileSwift failed with a nonzero exit code
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:59:25: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
            return try data.withUnsafeBytes { (bytes:UnsafePointer<UInt8>) -> Data in
                            ^
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:29: warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57: note: implicit argument conversion from '[UInt8]' to 'UnsafeMutablePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(_:)'
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                            ^~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:83:57: note: use the 'withUnsafeMutableBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
                strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                            ^
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:33: warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
                    strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:61: note: implicit argument conversion from '[UInt8]' to 'UnsafeMutablePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(_:)'
                    strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                                ^~~~~~~
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:145:61: note: use the 'withUnsafeMutableBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
                    strm.next_out = UnsafeMutablePointer<UInt8>(&buffer)
                                                                ^
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Starscream/Sources/Starscream/Compression.swift:140:14: warning: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
            data.withUnsafeBytes { (ptr:UnsafePointer<UInt8>) -> Void in
                 ^
    Command CompileSwift failed with a nonzero exit code
    ld: in /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Sodium/Sodium/libsodium/libsodium-ios.a(libsodium_la-aead_xchacha20poly1305.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
    warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the Runner editor. (in target 'Runner' from project 'Runner')
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'Starscream' from project 'Pods')
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'Sodium' from project 'Pods')
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'ReachabilitySwift' from project 'Pods')
    /Users/thijskuilman/AndroidStudioProjects/flutter_app/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'PusherSwiftWithEncryption' from project 'Pods')

Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.

Output of flutter doctor:

[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-arm, locale en-NL)
    • Flutter version 2.5.2 at /Users/thijskuilman/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 3595343e20 (3 days ago), 2021-09-30 12:58:18 -0700
    • Engine revision 6ac856380f
    • Dart version 2.14.3

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/thijskuilman/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Connected device (3 available)
    • iPhone 12 Pro Max (mobile) • 4EC79A64-B642-574118224945 • ios            
    • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 11.6 20G165 darwin-arm
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 

thijskuilman avatar Oct 03 '21 18:10 thijskuilman

i'm facing the same thing on ios 15

AhmedAbogameel avatar Oct 03 '21 20:10 AhmedAbogameel

@AhmedAbogameel @Waqar27324 I might have figured this out.

Solution

  1. First of all, update your ios/Podfile to contain the following line: platform :ios, '13.0'
  2. Add the following code to your post_install command within the Podfile:
 target.build_configurations.each do |config|
         config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
     end

For example, my post_install looks like this:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
     target.build_configurations.each do |config|
         config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
     end
  end
end
  1. Go to your pubspec.yaml. And replace the pusher_client dependency with my fork:
pusher_client:
    git:
      url: git://github.com/thijskuilman/pusher_client.git
  1. Go to your project root folder. Run flutter clean && flutter pub get && cd ios && pod install
  2. Try to run the app on your iOS device or simulator

What I did in the fork I replaced replaced PusherSwiftWithEncryption with PusherSwift (version > 9.0). Also updated the imports in the iOS code accordingly. See my commit for all changes: https://github.com/thijskuilman/pusher_client/commit/d95d362a74d3e0602e8959b3c8b992ec57adba24

What I've tested so far I successfully tested the following:

  • Connect with a PusherClient
  • onConnectionStateChange
  • onConnectionError
  • Channel subscribe
  • Channel event binding

I currently don't have an app that uses all capabilities of the pusher_client plugin, so I'm not able to test everything right now. But it seems to work perfectly fine now! @AhmedAbogameel @Waqar27324 could you test this solution in your project and let me know if it works for your projects as well? Anything I'm overlooking right now? If not, then I can submit a pull request for this package.

thijskuilman avatar Oct 04 '21 19:10 thijskuilman

I will definately try this later 🤞Thanks!

ragingallan avatar Oct 05 '21 02:10 ragingallan

definitely works @thijskuilman, only problem is I always got this error failed to connect to ws-ap1.pusher.com/XX.XXX.XX.XX (port 6001) from /:: (port 53350): connect failed: ETIMEDOUT (Connection timed out), I am expecting to connect to a defined domain not with pusher.com

ragingallan avatar Oct 06 '21 03:10 ragingallan

definitely works @thijskuilman, only problem is I always got this error failed to connect to ws-ap1.pusher.com/XX.XXX.XX.XX (port 6001) from /:: (port 53350): connect failed: ETIMEDOUT (Connection timed out), I am expecting to connect to a defined domain not with pusher.com

removing the cluster made me pass with this error

ragingallan avatar Oct 06 '21 04:10 ragingallan

have to drop it here tho, next thing after applying this is this error message

[] nw_protocol_copy_ws_definition_block_invoke [C1.1:1] nw_ws_validate_server_response did you passed by this too @thijskuilman ?

ragingallan avatar Oct 06 '21 13:10 ragingallan

pusher_client: git: url: git://github.com/thijskuilman/pusher_client.git

This works!! Thanks

definitelyme avatar Nov 14 '21 09:11 definitelyme

@AhmedAbogameel @Waqar27324 I might have figured this out.

Solution

1. First of all, update your `ios/Podfile` to contain the following line: `platform :ios, '13.0'`

2. Add the following code to your post_install command within the Podfile:
 target.build_configurations.each do |config|
         config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
     end

For example, my post_install looks like this:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
     target.build_configurations.each do |config|
         config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
     end
  end
end
1. Go to your `pubspec.yaml`.  And replace the pusher_client dependency with my fork:
pusher_client:
    git:
      url: git://github.com/thijskuilman/pusher_client.git
1. Go to your project root folder. Run `flutter clean && flutter pub get && cd ios && pod install`

2. Try to run the app on your iOS device or simulator

What I did in the fork I replaced replaced PusherSwiftWithEncryption with PusherSwift (version > 9.0). Also updated the imports in the iOS code accordingly. See my commit for all changes: thijskuilman@d95d362

What I've tested so far I successfully tested the following:

* Connect with a PusherClient

* onConnectionStateChange

* onConnectionError

* Channel subscribe

* Channel event binding

I currently don't have an app that uses all capabilities of the pusher_client plugin, so I'm not able to test everything right now. But it seems to work perfectly fine now! @AhmedAbogameel @Waqar27324 could you test this solution in your project and let me know if it works for your projects as well? Anything I'm overlooking right now? If not, then I can submit a pull request for this package.

Fantastic

definitelyme avatar Nov 14 '21 09:11 definitelyme

nw_protocol_copy_ws_definition_block_invoke [C1.1:1] nw_ws_validate_server_response

I also facing same issue

swatiElegant avatar Jan 17 '22 11:01 swatiElegant

check this issue https://github.com/chinloyal/pusher_client/issues/39 there is a working workaround there

ragingallan avatar Jan 17 '22 12:01 ragingallan

check this issue #39 there is a working workaround there

HI @ragingallan I have tried all thing and at the last I end up with nw_protocol_copy_ws_definition_block_invoke [C1.1:1] nw_ws_validate_server_response error ... when I use V8 plugin...it working fine...but only in debug mode, In Archive build it making error like multiple command product with "Reachability" and "ReachabilityShift" frameWork . Now I'm totaly confused that what should I do? any solution?

swatiElegant avatar Jan 17 '22 13:01 swatiElegant

mmm., I ended up not using any package that has conflict with Reachability.,

here's the package that I used: laravel_echo: ^1.0.0-beta.1 laravel_flutter_pusher: ^0.0.4

ragingallan avatar Jan 17 '22 14:01 ragingallan

https://github.com/chinloyal/pusher_client/pull/41 can you put this request too ?

adham-ashraf77 avatar Feb 16 '22 11:02 adham-ashraf77

Any updates on this?

GauravCalidig avatar Jul 19 '22 10:07 GauravCalidig

@GauravCalidig @adham-ashraf77 Yes in my case I'm using below packages laravel_echo: ^0.2.9 pusher_client: ^1.1.3

for "Reachability" and "ReachabilityShift" conflict I check all other packages who use this framework. Then I got "keyboard_visibility" plugin which had this conflict problem. then I remove this "Reachability" framework from keyboard_visibility.podspec file. this help me to get rid to build error

  1. other is I add "arm64" in Excluded Architectures in below pods
    • Sodium
    • PusherSwiftWithEncryption
    • pusher_client

finally code is working fine. let me know if you need more help

swatiElegant avatar Jul 19 '22 10:07 swatiElegant

@swatiElegant can you share this part "other is I add "arm64" in Excluded Architectures in below pods" how did you do it? Thanks for your help. Would appreciate that.

hi... If you working with laravel_echo and pusher client then you should have Sodium, PusherSwiftWithEncryption, pusher_client PODs (check in Xcode project) .. I'm sharing some screenshot where you can get your query.

IMG_20221011_182615 765 IMG_20221011_182616 116 IMG_20221011_182616 243 IMG_20221011_182615 920

second thing change IOS deployment target from 8.0 to 9.0 in above pods.
let me know or share here your error which you are facing ..if you find any difficulty.

swatiElegant avatar Oct 11 '22 13:10 swatiElegant

I'm facing this error

[] nw_protocol_copy_ws_definition_block_invoke [C18.1:1] nw_ws_validate_server_response

Hyxio avatar Jan 24 '23 15:01 Hyxio

after too many attempts. I did get some luck from this solution! but when I used this fork, I could not connect to the pusher. Then I reverted back to original plugin "pusher_client: ^2.0.0" , now my connections are stable and everything is working fine

ZakwanIbrahim3321 avatar Mar 20 '23 12:03 ZakwanIbrahim3321

after too many attempts. I did get some luck from this solution! but when I used this fork, I could not connect to the pusher. Then I reverted back to original plugin "pusher_client: ^2.0.0" , now my connections are stable and everything is working fine

@ZakwanIbrahim3321 Did you make it worked in both android and ios?

melchorlapinigjr avatar Mar 22 '23 22:03 melchorlapinigjr

after too many attempts. I did get some luck from this solution! but when I used this fork, I could not connect to the pusher. Then I reverted back to original plugin "pusher_client: ^2.0.0" , now my connections are stable and everything is working fine

@ZakwanIbrahim3321 Did you make it worked in both android and ios?

yes it's working on both android and iOS

ZakwanIbrahim3321 avatar Mar 24 '23 04:03 ZakwanIbrahim3321

I changed this line url: git://github.com/thijskuilman/pusher_client.git to url: https://github.com/thijskuilman/pusher_client.git then pub get worked

LakshithWithana avatar Aug 18 '23 20:08 LakshithWithana

@LakshithWithana Can you change org.jetbrains.kotlin:kotlin-gradle-plugin to more new please?

The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher. The following dependencies do not satisfy the required version: project ':pusher_client' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

Korefey avatar Feb 12 '24 19:02 Korefey