ln-12 / multiplatform-connectivity-status

A Kotlin multiplatform mobile library to monitor the connectivity status of the device
Apache License 2.0
61 stars 2 forks source link

What "context" should I use with ConnectivityStatus constructor on iOS? #5

Open iRhythmTuan opened 1 year ago

iRhythmTuan commented 1 year ago

I am trying to integrate the latest version 1.3.0 and run into the following error:

"Expected class ConnectivityStatus does not have default constructor"

Looks like ConnectivityStatus is now expecting an instance of "Context" class. How I create this context instance for iOS app? I looked at the sample app for iOS and noticed that ConnectivityStatus() also doesn't pass any parameter. Is the sample app updated to work with version 1.3.0? Can you update it if it's not? Thanks.

ln-12 commented 1 year ago

The sample works fine for me with version 1.3.0.

Please not that you cannot use the ConnectivityStatus class from your common module. As the sample shows, you have to define you own wrapper. That's because (as you already discovered) Android needs a context while iOS does not.

So in your common code you have to define a expect class which is implemented for iOS and Android:

Please check that you are not using ConnectivityStatus from you common module. If the error still remains, please upload a minimal example of your code.

iRhythmTuan commented 1 year ago

Thanks, I am able to compile on Android side now. However, when I've tried to compile it on iOS, I ran into the following error:

Undefined symbols for architecture x86_64: "_OBJCCLASS$_Reachability", referenced from: objc-class-ref in result.o ld: symbol(s) not found for architecture x86_64

I have properly import Reachability framework using pod.

How do I resolve this error?

Thanks

ln-12 commented 1 year ago

Did you try to run my sample?

morgan4080 commented 11 months ago

Thanks, I am able to compile on Android side now. However, when I've tried to compile it on iOS, I ran into the following error:

Undefined symbols for architecture x86_64: "_OBJCCLASS$_Reachability", referenced from: objc-class-ref in result.o ld: symbol(s) not found for architecture x86_64

I have properly import Reachability framework using pod.

How do I resolve this error?

Thanks

Was anyone able to get past this?