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

Conflicts between connectivity_plus and Reachability on iOS #563

Closed
tengyeekong opened this issue Oct 14, 2021 · 12 comments · Fixed by #634
Closed

Conflicts between connectivity_plus and Reachability on iOS #563

tengyeekong opened this issue Oct 14, 2021 · 12 comments · Fixed by #634
Labels
bug Something isn't working connectivity_plus Connectivity Plus Hacktoberfest Issues taking part in Hacktoberfest ios

Comments

@tengyeekong
Copy link

System info

Issue occurs on: iOS
Plugin name: connectivity_plus
Plugin version: ^2.0.2

Steps to Reproduce

App launched and stuck at splash screen.

Logs

Screenshot 2021-10-14 at 3 48 39 PM

Screenshot 2021-10-14 at 3 47 29 PM

@tengyeekong tengyeekong added the bug Something isn't working label Oct 14, 2021
@mhadaily mhadaily added the Hacktoberfest Issues taking part in Hacktoberfest label Oct 16, 2021
@fdastgir
Copy link

Getting same issue

@alexbatalov
Copy link
Contributor

I've just checked connectivity_plus example on both simulator and iPhone and I cannot reproduce your issue. Please create the following app and post your results.

$ flutter create --platforms ios demo
$ cd demo
$ flutter pub add connectivity_plus
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/material.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final connectivity = await Connectivity().checkConnectivity();

  runApp(MyApp(connectivity: connectivity));
}

class MyApp extends StatelessWidget {
  const MyApp({
    Key? key,
    required this.connectivity,
  }) : super(key: key);

  final ConnectivityResult connectivity;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('$connectivity'),
        ),
      ),
    );
  }
}

@tengyeekong
Copy link
Author

I've just checked connectivity_plus example on both simulator and iPhone and I cannot reproduce your issue. Please create the following app and post your results.

$ flutter create --platforms ios demo
$ cd demo
$ flutter pub add connectivity_plus
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/material.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final connectivity = await Connectivity().checkConnectivity();

  runApp(MyApp(connectivity: connectivity));
}

class MyApp extends StatelessWidget {
  const MyApp({
    Key? key,
    required this.connectivity,
  }) : super(key: key);

  final ConnectivityResult connectivity;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('$connectivity'),
        ),
      ),
    );
  }
}

Same result.
If run from Android Studio then the app closed after the splash screen, no error in the log.
If run from Xcode then the app stuck at the splash screen and show "Symbol not found: OBJC_CLASS$_Reachability" error in Xcode log.
This issue should be causing by using different Reachability classes. "connectivity_plus" using Reachability, and the native iOS using ReachabilitySwift.

@alexbatalov
Copy link
Contributor

alexbatalov commented Oct 20, 2021

Indeed connectivity_plus is using Reachability and connectivity_plus_macos is using ReachabilitySwift, but those are different projects for different platforms and they do not overlap.

In the demo app above:

$ flutter clean
$ flutter pub get

Open simulator:

$ open -a Simulator.app

Run it:

$ flutter run

Post your results. If it won't start due to the same issue, try flutter run --verbose, cleanup private information and post the output somewhere (it's huge).

@miquelbeltran
Copy link
Member

miquelbeltran commented Nov 29, 2021

Weird enough, I also got this error today for a project that simply worked like a week ago. Similar issue as reported originally, same error, clean didn't do anything.

Error:

(lldb) dyld[11380]: Symbol not found: _OBJC_CLASS_$_Reachability
  Referenced from: /private/var/containers/Bundle/Application/DE61E60B-1A26-430B-9991-50B615F82B6E/Runner.app/Frameworks/connectivity_plus.framework/connectivity_plus
  Expected in: /private/var/containers/Bundle/Application/DE61E60B-1A26-430B-9991-50B615F82B6E/Runner.app/Frameworks/Reachability.framework/Reachability

the used version of connectivity_plus is 1.4.0, because it is a dependency from another package.

Relevant part of my doctor:

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.11.2

[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-x64, locale en-DE)
    • Flutter version 2.5.3 at /Users/miquel/dev/tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (6 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

The minimal example from @alexbatalov worked for me so I could not reproduce the issue there.

I also tried to override the dependency to 2.0.3, but the same issue stays.

Running with --verbose didn't give me any relevant info besides what has been already been reported.

Also, running the example inside the connectivity_plus project worked without issues :/

@miquelbeltran
Copy link
Member

miquelbeltran commented Nov 30, 2021

I think I got a solution.

The problem is when you have both the cocoa pods Reachability and ReachabilitySwift in the same project.

In my case I was using PusherSwift v8.0.0 which depends on ReachabilitySwift 5.0, this causes a problem with connectivitu_plus which uses Reachability 3.2.

Thankfuly PusherSwift no longer uses ReachabilitySwift so this issue is now gone for me.

Edit: The Reachability 3.2 pod was last released in 2014! https://cocoapods.org/pods/Reachability and I am not sure if we should be using it, instead, we should switch to ReachabilitySwift 5.0 or we should try to use the framework provided methods instead of depending on a 3rd party.

@miquelbeltran
Copy link
Member

hey all, I was able to migrate the iOS plugin from Reachability to ReachabilitySwift, which got rid of the incompatibilities with other plugins. We also have now a shinny swift implementation (shamelessly stolen from the MacOS implementation). I tested this on my project and the solution works.

You can try the version 2.1.0 or just grab it with flutter pub upgrade.

@StasKalishenko
Copy link

But what to do with this problem if your other plugins or native code uses Objective-C implementation of Reachability? Objective-C and Swift implementations can't work together at the same time and project is broken until removing one of them. Migrating to Swift variant of Reachability you are braking compatibility with other stuff.

@miquelbeltran
Copy link
Member

But what to do with this problem if your other plugins or native code uses Objective-C implementation of Reachability?

You will have to migrate them or use an old version of this plugin.

@fengkaijia
Copy link

But what to do with this problem if your other plugins or native code uses Objective-C implementation of Reachability?

You will have to migrate them or use an old version of this plugin.

That really does not sound like a good idea since half of the project relying on this library will need to freeze on a legacy version. Maybe remove Reachability.swift at all, similar to what this project did: snowplow/snowplow-ios-tracker#437 (comment)

@kapil708
Copy link

kapil708 commented Mar 5, 2024

I solved it check the link.
https://stackoverflow.com/a/78105848/5374771

@latifmge
Copy link

thats because connectivity_plus.
i read at
in version 6.0.2, i think they fix it.
6.0.2
REFACTOR(connectivity_plus): remove ReachabilityConnectivityProvider and ReachabilitySwift dependency (#2813). (f9ad927f)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working connectivity_plus Connectivity Plus Hacktoberfest Issues taking part in Hacktoberfest ios
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants