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

Building for iOS fails #36

Open
thijskuilman opened this issue Oct 3, 2021 · 22 comments
Open

Building for iOS fails #36

thijskuilman opened this issue Oct 3, 2021 · 22 comments
Assignees

Comments

@thijskuilman
Copy link

thijskuilman commented Oct 3, 2021

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 
@AhmedAbogameel
Copy link

i'm facing the same thing on ios 15

@thijskuilman
Copy link
Author

thijskuilman commented Oct 4, 2021

@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.

@ragingallan
Copy link

I will definately try this later 🤞Thanks!

@ragingallan
Copy link

ragingallan commented Oct 6, 2021

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
Copy link

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
Copy link

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 ?

@definitelyme
Copy link

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

This works!! Thanks

@definitelyme
Copy link

@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

@swatiElegant
Copy link

nw_protocol_copy_ws_definition_block_invoke [C1.1:1] nw_ws_validate_server_response

I also facing same issue

@ragingallan
Copy link

check this issue #39 there is a working workaround there

@swatiElegant
Copy link

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?

@ragingallan
Copy link

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

@adham-ashraf77
Copy link

#41
can you put this request too ?

@GauravCalidig
Copy link

Any updates on this?

@swatiElegant
Copy link

@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
Copy link

swatiElegant commented Oct 11, 2022

@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.

@Hyxio
Copy link

Hyxio commented Jan 24, 2023

I'm facing this error

[] nw_protocol_copy_ws_definition_block_invoke [C18.1:1] nw_ws_validate_server_response

@ZakwanIbrahim3321
Copy link

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

@melchorlapinigjr
Copy link

melchorlapinigjr commented Mar 22, 2023

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?

@ZakwanIbrahim3321
Copy link

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

@LakshithWithana
Copy link

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

@Korefey
Copy link

Korefey commented Feb 12, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests