Closed kbessemer closed 1 year ago
I resolved this bug by upgrading my Flutter Blue Plus plugin to 1.15.8
same issue, anything reason ?
same issue, anything reason ?
upgrade your plugin to 1.15.8
Thank you for your reply. I understand that checked the change log between versions 1.40 and 1.15.8, but couldn't find any mention of this issue. Could you please tell me some specific reason?
found reason, this commit fixed the issue: [Protobuf] remove protobuf from iOS and MacOS
I use flutter_blue in my code (not plus), so these are my options to fix the error:
found reason, this commit fixed the issue: [Protobuf] remove protobuf from iOS and MacOS
I use flutter_blue in my code (not plus), so these are my options to fix the error:
- migrate the flutter_blue_plus
- refactor to swift protobuf also worked.
- remove permission_handler dependency
@Yongle-Fu the issue is not that bad, found a hint here https://developer.apple.com/forums/thread/735610, the main cause is that the old flutter_blue code still catches and throws FlutterErrors, this was changed here as well. After we got rid of that in our fork everything worked again. (But would still recommend migrating to this plugin at some point)
Contents of: https://developer.apple.com/forums/thread/735610
I was migrating from Xcode 14 -> 15, and noticed that my code was failing with dyld[46534]: Symbol not found: _OBJC_CLASS_$_NSError
I was able to debug the problem to some old objective c code, as documented in this thread: https://github.com/RonRadtke/react-native-blob-util/issues/273
The error seems to stem from this particular try catch block
@try {
// Some code
}
@catch(NSError *er) {
// handle error
}
When I convert the code to catch an NSException instead, the runtime error goes away. Understandably, according to the apple docs, it should be throwing an NSException in the first place, but the documents do say
Important: Although you can throw and catch objects other than NSException objects, the Cocoa frameworks themselves might only catch NSException objects for some conditions. So if you throw other types of objects, the Cocoa handlers for that exception might not run, with undefined results. (Conversely, non-NSException objects that you throw could be caught by some Cocoa handlers.) For these reasons, it is recommended that you throw NSException objects only, while being prepared to catch exception objects of all types.
So it seems like this should not have produced a runtime error. I wanted to flag this in case the underlying code behind the @try @catch changed unintentionally.
Thank you for your help, i had update the objective c code to swift code and remove the try catch block indeed.
so to summarize, a simple fix is to fork the old FBP and remove any catching or throwing of FlutterError. this was invalid code. It should be NSException. see master branch for details. i.e.
@catch (NSException *e)
{
NSString *stackTrace = [[e callStackSymbols] componentsJoinedByString:@"\n"];
NSDictionary *details = @{@"stackTrace": stackTrace};
result([FlutterError errorWithCode:@"iosException" message:[e reason] details:details]);
}
FlutterBluePlus Version
1.4.0
Flutter Version
3.13.4
What OS?
iOS
OS Version
iOS 15.7.9 & iOS 17
Bluetooth Module
STM32
What happened?
The flutter app will not start on iOS, it crashes immediately.
Logs