Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug iOS native code in a flutter plugin?

I'm wonder how to debug flutter iOS code in a plugin? I can open the example app that's generated whenever you create a plugin but I see the plugin code as binary framework, therefore I can't debug it.

For android it's fairly easy, I just open the android folder in A.S. and the plugin + the example are there, I just add run configs and I start debugging right away.

But I really hope to find a similar way for iOS.

like image 789
Shehabic Avatar asked Oct 11 '18 23:10

Shehabic


2 Answers

Plugins are added to the ios app as pod projects so it is similar to debugging any code in pod project.

  1. Open Runner project workspace
  2. Browse the file in the Pods project
  3. Put Breakpoint

NB: Need to run app from flutter first to work this properly

enter image description here

like image 113
Eldhose Avatar answered Oct 19 '22 02:10

Eldhose


To set a breakpoint and debug Flutter plugin code from Xcode, try the following:

  1. Open ios/Runner.xcworkspace for the Flutter application you want to debug.
  2. From the Debug menu, select Breakpoints > Create symbolic breakpoint...
  3. In the Symbol field, enter the method you want to break on. For example, to break on the default entrypoint for the plugin defined in the HelloPlugin class, set the symbol to -[HelloPlugin handleMethodCall:result:].
  4. Run your app from Xcode via Product > Run.

From that point, trigger the plugin code through whichever UI actions will hit the code in question.

like image 4
cbracken Avatar answered Oct 19 '22 02:10

cbracken