flutter_downloader: Failed to set registerPlugins on iOS
Hi! I’m having a problem running an app with this plugin installed. I’ve done everything I found on the internet and nothing works… If I comment await FlutterDownloader.initialize(); I can start the application.
Exception:
[ +2 ms] [DEVICE LOG] 2020-01-09 10:10:13.600816+0100 localhost Runner[14546]: methodCallHandler: initialize
[ ] [DEVICE LOG] 2020-01-09 10:10:13.601151+0100 localhost Runner[14546]: startBackgroundIsolate
[ ] [DEVICE LOG] 2020-01-09 10:10:13.639051+0100 localhost Runner[14546]: (Foundation) *** Assertion failure in -[FlutterDownloaderPlugin startBackgroundIsolate:], /Users/breakpoint/Flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.3.4/ios/Classes/FlutterDownloaderPlugin.m:117
[ ] [DEVICE LOG] 2020-01-09 10:10:13.686382+0100 localhost Runner[14546]: (CoreFoundation) *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'failed to set registerPlugins'
[ ] [DEVICE LOG] *** First throw call stack:
[ +4 ms] [DEVICE LOG] (
[ ] [DEVICE LOG] 0 CoreFoundation 0x000000010a5828db __exceptionPreprocess + 331
[ ] [DEVICE LOG] 1 libobjc.A.dylib 0x0000000109437ac5 objc_exception_throw + 48
[ ] [DEVICE LOG] 2 CoreFoundation 0x000000010a582662 +[NSException raise:format:arguments:] + 98
[ ] [DEVICE LOG] 3 Foundation 0x0000000108b0d76b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
[ ] [DEVICE LOG] 4 Runner 0x0000000105e50cfe -[FlutterDownloaderPlugin startBackgroundIsolate:] + 782
[ ] [DEVICE LOG] 5 Runner 0x0000000105e569eb -[FlutterDownloaderPlugin initializeMethodCall:result:] + 187
[ ] [DEVICE LOG] 6 Runner 0x0000000105e5a7d0 -[FlutterDownloaderPlugin handleMethodCall:result:] + 256
[ ] [DEVICE LOG] 7 Flutter 0x0000000106a98f95 __45-[FlutterMethodCha<…>
[ +16 ms] methodCallHandler: initialize
[ ] startBackgroundIsolate
[ ] *** First throw call stack:
[ ] (
[ ] 0 CoreFoundation 0x000000010a5828db __exceptionPreprocess + 331
[ ] 1 libobjc.A.dylib 0x0000000109437ac5 objc_exception_throw + 48
[ ] 2 CoreFoundation 0x000000010a582662 +[NSException raise:format:arguments:] + 98
[ ] 3 Foundation 0x0000000108b0d76b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
[ ] 4 Runner 0x0000000105e50cfe -[FlutterDownloaderPlugin startBackgroundIsolate:] + 782
[ ] 5 Runner 0x0000000105e569eb -[FlutterDownloaderPlugin initializeMethodCall:result:] + 187
[ ] 6 Runner 0x0000000105e5a7d0 -[FlutterDownloaderPlugin handleMethodCall:result:] + 256
[ ] 7 Flutter 0x0000000106a98f95 __45-[FlutterMethodCha<…>
[ +3 ms] Service protocol connection closed.
[ ] Lost connection to device.
main.dart:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterDownloader.initialize();
...
}
AppDelegate.m:
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#include "FlutterDownloaderPlugin.h"
@implementation AppDelegate
void registerPlugins(NSObject<FlutterPluginRegistry>* registry) {
[FlutterDownloaderPlugin registerWithRegistrar:[registry registrarForPlugin:@"vn.hunghd.flutter_downloader"]];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (@available(iOS 10.0, *)) {
[UNUserNotificationCenter currentNotificationCenter].delegate = (id<UNUserNotificationCenterDelegate>)self;
}
[GeneratedPluginRegistrant registerWithRegistry:self];
[FlutterDownloaderPlugin setPluginRegistrantCallback:registerPlugins];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end
flutter doctor:
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.13.6 17G10021,
locale en-BA)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Android Studio (version 3.3)
[✓] IntelliJ IDEA Community Edition (version 2019.3.1)
[✓] Connected device (1 available)
• No issues found!
flutter_downloader version:
1.3.4
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (1 by maintainers)
@anisalibegic check your “/ios/Runner/AppDelegate.swift” file. I had the same problem. I solved it by adding the code below.
“AppDelegate.swift”
good luck!!
A C function pointer can only be formed from a reference to a ‘func’ or a literal closure
A C function pointer can only be formed from a reference to a ‘func’ or a literal closure