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

🐞[iOS] MissingPluginException in example app #189

Closed
4 tasks done
gebsl opened this issue Jul 15, 2020 · 52 comments
Closed
4 tasks done

🐞[iOS] MissingPluginException in example app #189

gebsl opened this issue Jul 15, 2020 · 52 comments
Assignees
Labels
bug Something isn't working iOS iOS specific

Comments

@gebsl
Copy link

gebsl commented Jul 15, 2020

  • I have read the README
  • I have done the setup for Android
  • I have done the setup for iOS
  • I have ran the sample app and it does not work there

Version

Technology Version
Workmanager version 0.2.3
Xcode version 11.5
Swift version 5.0
iOS deployment target 13.5.1 (iPhone SE 1st Generation)

Describe the error

When running the example app on a real iOS device through XCode (by pressing the "Run" icon), the app throws an exception when pressing the "Start the Flutter background service" button. Subsequently, background fetch won't work and the dispatch method is never called.

The exception in XCode's console is:

2020-07-15 23:46:23.059914+0200 Runner[9411:4096136] [VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method initialize on channel be.tramckrijte.workmanager/foreground_channel_work_manager)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
<asynchronous suspension>
#1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2      Workmanager.initialize (package:workmanager/src/workmanager.dart:100:30)
#3      _MyAppState.build.<anonymous closure> (package:workmanager_example/main.dart:87:33)
#4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
#5      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
#6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#7      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
#8      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
#9      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
#10     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
#11     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
#12     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
#13     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
#14     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
#15     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
#16     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
#17     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
#18     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
#19     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
#20     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
#21     _rootRunUnary (dart:async/zone.dart:1196:13)
#22     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#23     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
#24     _invoke1 (dart:ui/hooks.dart:275:10)
#25     _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)

Unfortunately I can not provide any debug information, when starting the app through flutter run, as there seems to be a bug with iOS hiding important exceptions from frameworks like flutter (see flutter/flutter#41133), so the only way to fetch information (at least the one I know about) is through XCode.

Except from running flutter pub get and flutter build ios (to resolve initial build error in XCode) I didn't changed anything in the example app.

Though, there is one thing I noticed that's different from the iOS setup guide: After unchecking and re-checking the capability "Background fetch" in XCode, following block is not added to file project.pbxproj (which, as I understood, should be added automatically by XCode):

SystemCapabilities = {
	com.apple.BackgroundModes = {
		enabled = 1;
	};
};

Unfortunately, adding it manually does not seem to have any effect.

Output of flutter doctor -v

[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.5 19F101, locale en-GB)
    • Flutter version 1.17.5 at /opt/flutter
    • Framework revision 8af6b2f038 (2 weeks ago), 2020-06-30 12:53:55 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).
      If the Android SDK has been installed to a custom location, set
      ANDROID_SDK_ROOT to that location.
      You may also want to add it to your PATH environment variable.


 
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.3

[!] Android Studio (not installed)
    • Android Studio not found; download from
      https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).

[✓] VS Code (version 1.47.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.2

 
[✓] Connected device (1 available)            
    • iPhone xxx xxxxxxxx • a196bfcb78b38a0f88a8xxxxxxxxxxxxxxxxxxx • ios •
      iOS 13.5.1
@gebsl gebsl added the bug Something isn't working label Jul 15, 2020
@lymanlai
Copy link

I have the same issue, I just read over the apple's https://developer.apple.com/documentation/backgroundtasks doc, I think the example missing the "Permitted background task scheduler identifiers" part,will test this tomorrow

@gebsl
Copy link
Author

gebsl commented Jul 16, 2020

As I understood, those identifiers are only needed for the API that was introduced in iOS 13 (Background Task API), which lets you specify tasks similar to Android's WorkManager. But for simple Background Fetch, those identifiers should not be needed.
But as I'm not a native iOS developer, my understanding might be wrong.

@Kymer
Copy link

Kymer commented Jul 16, 2020

Indeed, the identifier isn’t necessary because the plug-in uses the older background fetch API, not the iOS 13 task based API.

I’ll look into this next week.

@MuhammedRefaat
Copy link

@Kymer This iOS issue is not related to the example app only, I'm facing it in my app after implementation for the whole functionality, and when I tried with the example app I found it happening there also.
Worth to mention that in Android it's working perfectly.

@danielbruni
Copy link

Same problem here.

@gebsl
Copy link
Author

gebsl commented Jul 24, 2020

Please just thumb up the initial bug report instead of posting "Same here". This only pollutes the conversation and makes tracing important questions/answers difficult. Thanks!

@mamedshahmaliyev
Copy link

Finally i have found solution:

Make sure you have the followings in ios/Runner/GeneratedPluginRegistrant.m

#if __has_include(<workmanager/WorkmanagerPlugin.h>)
#import <workmanager/WorkmanagerPlugin.h>
#else
@import workmanager;
#endif

and inside (void)registerWithRegistry:(NSObject*) function:
[WorkmanagerPlugin registerWithRegistrar:[registry registrarForPlugin:@"WorkmanagerPlugin"]];

Keep in mind that ios/Runner/GeneratedPluginRegistrant.m file resets after every clean and build, so make sure that above is present before running app.

Also enable debug mode, when simulating background fetch from xcode.

@cormalenv
Copy link

cormalenv commented Jul 25, 2020

[WorkmanagerPlugin registerWithRegistrar:[registry registrarForPlugin:@"WorkmanagerPlugin"]];

I can confirm this works in XCode. Thanks! However....If we run it from another IDE such as AS, GeneratedPluginRegistrant.m is automatically rebuilt, even without clean, so the workaround fails. I don't know enough to correct this at the plugin level.

@mamedshahmaliyev
Copy link

[WorkmanagerPlugin registerWithRegistrar:[registry registrarForPlugin:@"WorkmanagerPlugin"]];

I can confirm this works in XCode. Thanks! However....If we run it from another IDE such as AS, GeneratedPluginRegistrant.m is automatically rebuilt, even without clean, so the workaround fails. I don't know enough to correct this at the plugin level.

You can do it from another IDE as well, after run wait for pod install to finish, then manually edit GeneratedPluginRegistrant.m before build has been finished.

@mamedshahmaliyev
Copy link

mamedshahmaliyev commented Jul 25, 2020

Found better and permanent solution:

add following inside AppDelegate.swift

WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin"))

this is how my ios/Runner/AppDelegate.swift looks like:

import Flutter
import workmanager
import devicelocale
import flutter_local_notifications
import shared_preferences

@UIApplicationMain

@objc class AppDelegate: FlutterAppDelegate {

    override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        GeneratedPluginRegistrant.register(with: self)
        
        WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin"))
        
        UNUserNotificationCenter.current().delegate = self

        UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15))

        WorkmanagerPlugin.setPluginRegistrantCallback { registry in
            // registry in this case is the FlutterEngine that is created in Workmanager's performFetchWithCompletionHandler
            // This will make other plugins available during a background fetch
            //GeneratedPluginRegistrant.register(with: registry)
            
            DevicelocalePlugin.register(with: registry.registrar(forPlugin: "com.example.devicelocale.DevicelocalePlugin"))
            FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"))
            FLTSharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"))
            
        }

        return super.application(application, didFinishLaunchingWithOptions: launchOptions)

    }
    
    override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        completionHandler([.alert, .sound, .badge]) // shows banner even if app is in foreground
    }

}

@cormalenv
Copy link

cormalenv commented Jul 26, 2020

Thanks @mamedshahmaliyev. Extending your results to AppDelegate.m (Obj-C), add:

#include "WorkmanagerPlugin.h"

and

[WorkmanagerPlugin registerWithRegistrar:[self registrarForPlugin:@"be.tramckrijte.workmanager.WorkmanagerPlugin"]];

AppDelegate.m ends up like this

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#include "WorkmanagerPlugin.h"

@implementation AppDelegate

void registerPlugins(NSObject<FlutterPluginRegistry>* registry) {
  [GeneratedPluginRegistrant registerWithRegistry:registry];
}

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   ...
    [GeneratedPluginRegistrant registerWithRegistry:self];
    [WorkmanagerPlugin registerWithRegistrar:[self registrarForPlugin:@"be.tramckrijte.workmanager.WorkmanagerPlugin"]];
    [WorkmanagerPlugin setPluginRegistrantCallback:registerPlugins];
   ...
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end

All seems to be good so far.

@gebsl
Copy link
Author

gebsl commented Jul 26, 2020

@mamedshahmaliyev's solution for swift works like a charm, thank you a lot!

@gareth-del
Copy link

Found better and permanent solution:

add following inside AppDelegate.swift

WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin"))

this is how my ios/Runner/AppDelegate.swift looks like:

import Flutter
import workmanager
import devicelocale
import flutter_local_notifications
import shared_preferences

@UIApplicationMain

@objc class AppDelegate: FlutterAppDelegate {

    override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        GeneratedPluginRegistrant.register(with: self)
        
        WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin"))
        
        UNUserNotificationCenter.current().delegate = self

        UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15))

        WorkmanagerPlugin.setPluginRegistrantCallback { registry in
            // registry in this case is the FlutterEngine that is created in Workmanager's performFetchWithCompletionHandler
            // This will make other plugins available during a background fetch
            //GeneratedPluginRegistrant.register(with: registry)
            
            DevicelocalePlugin.register(with: registry.registrar(forPlugin: "com.example.devicelocale.DevicelocalePlugin"))
            FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"))
            FLTSharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"))
            
        }

        return super.application(application, didFinishLaunchingWithOptions: launchOptions)

    }
    
    override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        completionHandler([.alert, .sound, .badge]) // shows banner even if app is in foreground
    }

}

Based on your solution I get "No such module 'workmanager'. Do you know why? Thanks alot!

@ivanjpg
Copy link

ivanjpg commented Aug 10, 2020

Same issue as @gareth-del.

I would like to add that even if platform :ios is set to 10.0 or 11.0 (as I had first), the pod for workmanager will not install. It is not present under Local Podspecs folder neither listed in Podfile.lock.

I already try to delete Podfile.lock and then pod install, refreshing flutter packages using flutter pub cache repair and did a cleaning with flutter clean; nothing works. I'm running Flutter 1.20.1

@suhail-zartek
Copy link

@ivanjpg same issue here.Did you get the solution?

@suhail-zartek
Copy link

@mamedshahmaliyev please give me a solution for no such module

@mamedshahmaliyev
Copy link

@suhail-zartek , unfortunately i have no such problem, the only thing that comes to my mind is, make sure that there is workmanager folder inside ios/.symlinks/plugins folder, i think import module_name should be the same as in ios/.symlinks/plugins folder. If there is no such ios/.symlinks/plugins/workmanager folder search for similar name otherwise it means pod install does not install the workmanager plugin...

@proninyaroslav
Copy link

I have the same problem with unavailable workmanager import in AppDeletage.swift

@cormalenv
Copy link

@suhail-zartek , unfortunately i have no such problem, the only thing that comes to my mind is, make sure that there is workmanager folder inside ios/.symlinks/plugins folder, i think import module_name should be the same as in ios/.symlinks/plugins folder. If there is no such ios/.symlinks/plugins/workmanager folder search for similar name otherwise it means pod install does not install the workmanager plugin...

Try running pod install from the ios folder in terminal if its not there.

@proninyaroslav
Copy link

Try running pod install from the ios folder in terminal if its not there.

It doesn't work. .symlink/plugins dir doesn't contain workmanager dir. I also clean build and repair package cache.

@proninyaroslav
Copy link

It doesn't work. .symlink/plugins dir doesn't contain workmanager dir. I also clean build and repair package cache.

It's also not contained in Podfile.lock.

@2math
Copy link

2math commented Aug 19, 2020

same here, happens after upgraded Flutter from 1.17.5 to 1.20

@cormalenv
Copy link

same here, happens after upgraded Flutter from 1.17.5 to 1.20

Agree. I upgraded to 1.20.x and ended up with so many problems I went back to 1.17.x.

@2math
Copy link

2math commented Aug 19, 2020

Small fix on my side was to force the register as non optional ! as the plugin expects. It appears on 1.20 this self.registrar returns optional ?

WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin")!)

@proninyaroslav
Copy link

@2math
But this will not solve the problem of missing .symlink/plugins/workmanager dir

@2math
Copy link

2math commented Aug 19, 2020 via email

@cormalenv
Copy link

Is this a podfile related issue associated with flutter 1.20.x?. Creating a new podfile (flutter build iOS) in 1.20.x results in no reference to symlinks in the podfile. Whilst running pod install seems to set up all my other plugins in the symlinks folder it doesn't set up workmanager. When migrating to 1.20 you might receive an error that your podfile was outdated. Removing and rebuilding has the same effect as creating a new. Restoring to my old podfile even under 1.20.x placed workmanager back into symlinks and then runs fine.

I dont know enough to say how this should be resolved but it seems the new podfile format works fine for most of the plugins I am using just not workmanager so could this be resolved by a plugin fix? For reference I am still using mamedshahmaliyev's fix to make this work also.

@gebsl
Copy link
Author

gebsl commented Aug 24, 2020

@cormalenv: Can described confirm your behaviour. New Podfile breaks compatibility with Workmanager. Using Podfile from Flutter 1.17 resolves the issue. However, Flutter 1.20 also seems to break compatibility with @mamedshahmaliyev fix.

@cormalenv
Copy link

cormalenv commented Aug 24, 2020

@gebsl Ill run some more tests tomorrow and get back to you. Reading your flutter 1.20 thread, it looks like we are now hitting the same issue. @mamedshahmaliyev's fix is a workaround for the original bug here which still exists so it shouldnt be closed but the thread seems to be migrating now to a 1.20 issue so we probably can move over to there.

@Adem68
Copy link

Adem68 commented Aug 24, 2020

If anyone needs old Podfile (before Flutter 1.20 version) you can look to example app's Podfile.

@cormalenv
Copy link

cormalenv commented Aug 25, 2020

@gebsl the only modification I made to @mamedshahmaliyev 's fix was @2math 's addition to register as non-optional

WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin")!)

Relevant sections of flutter doctor for reference in case.

[✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.6 19G73, locale en-AU)
    • Flutter version 1.20.2 at /.../development/flutter
    • Framework revision bbfbf1770c (11 days ago), 2020-08-13 08:33:09 -0700
    • Engine revision 9d5b21729f
    • Dart version 2.9.1

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.3

I still think everything here might be workarounds given I am not seeing these same issue in other plugins. If I get time I will look further at PR options.

@gebsl
Copy link
Author

gebsl commented Aug 25, 2020

@cormalenv: Thanks for the hint! Build seems to work on my side.

Summing up:

  1. Using Podfile shipped with Flutter 1.17 (instead of upgrading to 1.20's Podfile) (thanks to @Adem68)
  2. Registering the plugin as optional -> WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin")!) (thanks to @2math and @mamedshahmaliyev)

This seems to do the trick.

But totally agree with you, @cormalenv, this can only be temporary hacks for the plugin.

Unfortunately I'm too unexperienced in iOS development, so I won't be able to assist in finding the underlying problem in this plugin. Really appreciate your efforts!

@proninyaroslav
Copy link

If anyone needs old Podfile (before Flutter 1.20 version) you can look to example app's Podfile.

This issue is also with the connectivity package. Looks like 1.20 made changes to the plugin system, now requires action from plugin developers.

@barrinhos123
Copy link

barrinhos123 commented Sep 3, 2020

When I add
WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin")!) to AppDelgate.swift i get this error

Xcode build done.                                           35,8s
Failed to build iOS app
Exited (sigterm)
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.

Anyone has the same issue?

@proninyaroslav
Copy link

@barrinhos123
You should look at the build log in Xcode, Flutter is not verbose.

@barrinhos123
Copy link

@barrinhos123
You should look at the build log in Xcode, Flutter is not verbose.

Problem solved thank you!

@Masumi-M
Copy link

Masumi-M commented Sep 16, 2020

For me, the code bellow appeared in GeneratedPluginRegistrant.m by downgrading the "workmanager" to ^0.1.5.

#if __has_include(<workmanager/WorkmanagerPlugin.h>)
#import <workmanager/WorkmanagerPlugin.h>
#else
@import workmanager;
#endif

More specifically I executed the next command after changing the dependencies inside pubspec.yaml to workmanager: ^0.1.5.

$ rm -rf ios/Podfile.lock
$ rm -rf ios/Pods
$ rm -rf pubspec.lock
$ flutter clean
$ flutter pub get
$ flutter build ios --release

=====

[My Environments]

$ flutter --version
Flutter 1.20.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision fba99f6cf9 (33 hours ago) • 2020-09-14 15:32:52 -0700
Engine • revision d1bc06f032
Tools • Dart 2.9.2

@Masumi-M
Copy link

Masumi-M commented Sep 16, 2020

In addition, I will share my AppDelegate.swift script too.
(Thanks to @mamedshahmaliyev.)

I add the ! after registrar like this.
WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin")!)

import Flutter
import workmanager
import shared_preferences

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    
    GeneratedPluginRegistrant.register(with: self)
    WorkmanagerPlugin.register(with: self.registrar(forPlugin: "be.tramckrijte.workmanager.WorkmanagerPlugin")!)
    UNUserNotificationCenter.current().delegate = self
    UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*10))

    WorkmanagerPlugin.setPluginRegistrantCallback { registry in        
        FLTSharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin")!)
        
    }

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

@Theunodb
Copy link

I've tried all suggestions above to no avail.

@ngothanhtai
Copy link

I tried this PR and it works for me. #218

@MiguelSOliveira
Copy link

That PR does not work for me.. Same "no such module.... " error on xcode..

May I ask how you're using it @ngothanhtai ?

I've done the following

on pubspec.yaml:

workmanager:
    git:
      url: git@github.com:ened/flutter_workmanager.git

Then remove pods and pod install and it still does not appear on Podfile.lock.

@ngothanhtai
Copy link

@MiguelSOliveira I specified the commit ref in the pubspec

workmanager:
    git:
      url: git@github.com:ened/flutter_workmanager.git
      ref: 1c4e162ea4e71855856fb9e55a1545b3dae9a25d

@ujnamss
Copy link

ujnamss commented Nov 3, 2020

I am getting a permission error when trying to get this PR:

`pub get failed (server unavailable) -- attempting retry 6 in 32 seconds...

Git error. Command: git clone --mirror git@github.com:ened/flutter_workmanager.git /Users/ux/work/flutter/.pub-cache/git/cache/flutter_workmanager-b145eb908d4135eaccf9e2d27cfe2100402b3876

stdout:

stderr: Cloning into bare repository '/Users/ux/work/flutter/.pub-cache/git/cache/flutter_workmanager-b145eb908d4135eaccf9e2d27cfe2100402b3876'...

git@github.com: Permission denied (publickey).

fatal: Could not read from remote repository.`

@ivanjpg
Copy link

ivanjpg commented Nov 18, 2020

Hi @ujnamss:

You can avoid that error if you change the url from git@github.com:ened/flutter_workmanager.git to https://github.com/fluttercommunity/flutter_workmanager.

I hope this helps.

@ujnamss
Copy link

ujnamss commented Nov 25, 2020

Hi @ujnamss:

You can avoid that error if you change the url from git@github.com:ened/flutter_workmanager.git to https://github.com/fluttercommunity/flutter_workmanager.

I hope this helps.

Doesn't seem to work @ivanjpg - i still get Exception
Unhandled Exception: PlatformException(unhandledMethod("registerOneOffTask") error, Unhandled method registerOneOffTask, null, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)

#2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
#3 Workmanager.registerOneOffTask (package:workmanager/src/workmanager.dart:124:32)
#4 registerPoppinsRefreshTask (package:poppins/main.dart:49:15)
#5 main (package:poppins/main.dart:66:3)

@Tienisto
Copy link

Hi @ujnamss:
You can avoid that error if you change the url from git@github.com:ened/flutter_workmanager.git to https://github.com/fluttercommunity/flutter_workmanager.
I hope this helps.

Doesn't seem to work @ivanjpg - i still get Exception
Unhandled Exception: PlatformException(unhandledMethod("registerOneOffTask") error, Unhandled method registerOneOffTask, null, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)

#2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
#3 Workmanager.registerOneOffTask (package:workmanager/src/workmanager.dart:124:32)
#4 registerPoppinsRefreshTask (package:poppins/main.dart:49:15)
#5 main (package:poppins/main.dart:66:3)

"One Off Tasks" and "Periodic Tasks" only works on Android. See https://github.com/fluttercommunity/flutter_workmanager/blob/master/IOS_SETUP.md

As @ngothanhtai said, this is the fix for now:

workmanager:
    git:
      url: git@github.com:ened/flutter_workmanager.git
      ref: 1c4e162ea4e71855856fb9e55a1545b3dae9a25d

@2math
Copy link

2math commented Dec 21, 2020

I was pushed to migrate into new iOS build system and confirm this is the only solution for now to have workmanager in the symlink

  #currently ^0.2.3 not working with new build system
  workmanager:
    git:
      url: https://github.com/fluttercommunity/flutter_workmanager
      ref: 1c4e162ea4e71855856fb9e55a1545b3dae9a25d

@rahulzs
Copy link

rahulzs commented Mar 1, 2021

Finally i have found solution:

Make sure you have the followings in ios/Runner/GeneratedPluginRegistrant.m

#if __has_include(<workmanager/WorkmanagerPlugin.h>)
#import <workmanager/WorkmanagerPlugin.h>
#else
@import workmanager;
#endif

and inside (void)registerWithRegistry:(NSObject*) function:
[WorkmanagerPlugin registerWithRegistrar:[registry registrarForPlugin:@"WorkmanagerPlugin"]];

Keep in mind that ios/Runner/GeneratedPluginRegistrant.m file resets after every clean and build, so make sure that above is present before running app.

Also enable debug mode, when simulating background fetch from xcode.

GeneratedPluginRegistrant

Can you please share the GeneratedPluginRegistrant.m file.

@julianknaup
Copy link

Since the WorkManager is described in this way: "Flutter WorkManager is a wrapper around Android's WorkManager and iOS' performFetchWithCompletionHandler" and performFetchWithCompletionHandler is deprecated for apps supporting iOS 13 and higher (replaced by BGAppRefreshTask), am I correct that there is no way for implementing WorkManager on iOS 13 and higher, because it uses the wrong/outdated API?

@kimmy-wang
Copy link

Why is there no SystemCapabilities attribute in this file project.pbxproj in my project?

@ened
Copy link
Collaborator

ened commented Apr 29, 2021

I have just verified this ticket can be closed - please see the Xcode screenshots:

Screen Shot 2021-04-29 at 20 38 23

And the resulting console logs after pressing that one:

Screen Shot 2021-04-29 at 20 38 28

Therefore closing this issue. Please open single, separate issues for specific questions or problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iOS iOS specific
Projects
None yet
Development

No branches or pull requests