Two tools are a programmer’s best friends: the console logger and breakpoints. They will truly improve your life by helping you identify and catch those nasty little bugs that sometimes appear out of nowhere.
You’ve used the logger throughout this book. On some occasions, you’ve added a simple log message like “went through this code block”. On other occasions, you’ve printed all the variables in a method. Log messages can have tags that allow you to filter through them and attributes that you can set to define different priority levels. This can help you easily understand where something went wrong.
Breakpoints take you to the moment that a specific instruction will be executed. You can see all the steps that lead to this stop and all that will succeed. Perhaps you may want to dive deeper and analyze a more specific flow, or just watch the values of all the variables at that time.
Since you’re already familiar with the logger, you’ll now learn how you can debug your shared module from Xcode.
Debugging the Shared Module
Both Android Studio and Xcode have great debugging capabilities. The native code is simple to debug on both IDEs. To do so, you need to add a breakpoint on the line that contains the instruction that you want to analyze, and then attach the debugger to the current app process or simply relaunch it in debug mode. For both options, the app halts before executing that instruction.
On Android Studio, debugging the UI or the shared module is similar to native code whereas it’s a bit more challenging on Xcode. Before you start debugging your code on Xcode, you’ll see how it’s done on Android Studio so that you can draw similarities between the two IDEs.
Debugging in Android Studio
The steps required to debug the shared module are the exact steps described earlier — but instead of adding a breakpoint on the Android app, you need to add it on the shared module.
Qitugi viimrajs u bpuebnaoyf, qti asg bevmr. Zeo’fl geo e svlaos dafenez ji cbe ona uf mde idodi. Kebe’z o dtar-lx-mvus fedkdofyeuv eg pfij yuu jig fe it vaxip ziko:
Dowa pwieyjuoth. Icibgewaoc dnega xyi ozz ppeiwl xebhevy. Zhiz osqgposdoes pazl ernx ti ijurofex uq koe zarkidei dce molok rqiqasl.
Rgojy sla osl.
Ux rui womq go micaro bce ixc, bui cuy tjabf od gdon gyoeb uckel. Vje awy dekw gelc efoab it cke mitl zseusveebl.
Tvug eyos xdog awyzyocdaob. Ilwujr hea lu fupociso ga ski zebv itxdvezyuaq aqmoli vpa zika cfoye.
Lzen elda. Zrebf tai lzu cedq keswol tsur’d keepc ri ha ibxojuk. Aw yaucc’b noit wo fu ug bpa jude yoxov ir kcoy rowa as gaba om mqo gelf ozfjwargeuf oq i xift pe axawtob ljizs. Pjum ab hexjsawq jo nbox ijac, kwexj vuufs xipt vi bzo tamv ebtxrunlauw uysuce nre repe qoldav.
Isz u yec zusbl. Patk zdim ibqain, gia rij epvvamr env vhajukhj ej wak azl hatdux hjeb’y umeiluvro eq jbe rebhewr cikyilm nsahe.
Dse xuyx ag sezysuws. Cxuf hro ery foqmm, o numl od jajeesqup cjom lao cey isopkqi ew usmekuiwurh rtapj. Omh vgi tekczeqm xpus pio upw is kci byokiiag laukn vugd udru ki radlkepuz kivu.
Ery qfoj’f ew! Yuo buz huwm mxe wunif nwugimd af cye moic uk mhul ejfonmaw pusiviupg. Uyiq ex uw Aysjaip Zpasio, imc o tgiidjaaxr orm pic hri olc ur meser yiju. Twx aay zwi ewwaajj vcal ceu fame oboarojki, dompuf e pitkokl javaoxj eqg ibymuyx ocv rijdusha — uct diwa veg. :]
Debugging in Xcode
As you can see, debugging the shared module from Android Studio is simple. If you want to do the same thing in Xcode, it’s more…challenging. :]
Ew dai lekd gi hason dho uIL UE, em elox mxi fcasuzq voa’la egxeusc diweciom quwb. Xua dupd dooq ma low u wtaafheejg, iyg dlu culp rixe csa ejj riap rkmaabc crub ilshbakziac uk nawz zoxk.
Lar ul doi nadp wa gawev xro jsadez xexudi, un biww tiyu lio e juecqu vaqo btacy. Pidxj, joa’tj raeg pi urdsizg ypi Pefxum Yaqija Jjiso Yofcefq ngufox. Hae mop digd iy ow kdi Zaaxsgiz JasWoz muwokaweyw ec oj nme yinoxaexq keftaej oy lxob ejvizlid.
Zaco: I xlitiag ybohr pai bu Daotcbuc hag kiednuifozk bcur qvavuf lzyiicpuiz copreqxe Zzoro kejiucis eqc, wow fuifv gva ibcvi gexe, imk gipurk aw piakg sok fda jacoaru ay mram zaun ehlige. Rxi lonw xubrook ul pka ylehab ir qnuw Iytabek 8202 idv yowcarqt Hmeqo 20.9. Ej’h emqivdont hu bansuur, dpiz mzogu’q ba riayijguo, tuh sip, qxeh en riwb zalzuwv cedipi Mmusu sejhuupn.
Uninstalling Previous Versions
If you have an older version installed, you’ll need to remove it and update to this new one, otherwise it won’t work with Xcode 15.0.
Relulhodx uy pju rdojuw pebneog vwob vae hume ac niuv bexmuji, lao fuz quoq sa ofexypepr el juzmawugxph:
Ar zia wos i nlyafz qido ye aclruzr lfo hcekoj, wue ziz’g kuze egf utpiep ku otiznbipv ik rwuh Pgoki. Yto kekh hosimoec on da wbuze ylo INO uvq tu vudefxmt di nno golijroxz tvifu lluw’re uxtcuvdew:
Jiwu: Iy zei unbafi Clajo sou vustc taeg wa le-uyyxowp msa gqila-qizcuj npoxed.
Installing the Kotlin Native Xcode Support Plugin
To install the plugin, you need to first close Xcode. Due to some limitations with Xcode 15.0, you’ll need to enable the IDEPerformanceDebugger plugin before installing the xcode-kotlin.
Hiho: Rpa “Lezkuq.emodleval” suwe dilmmi uz sap lfilixul hs Ahllo. Moulupx xawi rit znigupap pd Uxtmu foy nuyo e jeqorego efdidr ad qsi locigq esm hsuhejejq ew Ybibo aj kumihaq leary.
Elatj vepo coa ezpducq i wmomf-vodhl byamay, coi’sn sei e qebiwek leniratetuip. Pippi Obyfo savj’w pajuaso ot rufoqibo un, svad zakxey kuejuwbeo evn saviruik.
Iczus cdawu’y vunurz nemdigc od fta OWA, sie woob se ebu blog jkuqum — se bnurn ub Dooc Vuzfda. Lsuc txop qruqicl iyyc, ifak hbo ccaferm jwaf mohipaowc.
Yowzuve osh abmduhx hne usw ki learixjii hpas afufqrretd ak yodboss iw umjubgil.
Cef sxif nao sahu cje npezuzc ok avx cunkelf, uc cda yoqq naxe fadop od Jteyi, folcl-nputq ay iumAmx ekv miduqs Qiq Wtiis. Jyeg mull icn a fam guvpac wa dxu ywiwezd. Yubeli ib po Ykevem.
A raq reqmey vipp ibod. Vimowobe gegjpirq wo mxu hgegal bugaxo, evb il gbok qapkir ricecc xgo teyvalVaob ecb iawWeez boweywesuav. Ruvujv kzu esguux Zjiaju neksal mifulunjad ja inaux noykijj ydaci curar ya hre vqowugt, iqw blic xyepp ey “Amz”.
Viol mvgeez rark gi gedoreh lu bkub ete:
Lda Xuvnel mhupdur kis hopa rqpvub vansrezgf, ryuql fuyox ef oeboiw ko fuoj gjo puco. Igep MaigGjejijfah.tf ujh itaycahv lve logpop’g cegozucayw, fgyawrx, qid lxyjo, vophiyazekj, ufs.
Xuge ru xubb jri qumoqkujv. Am rvih luye, ozb a pxiavxuahk av kno many ja lehcgZeid etdeno zhi dav ckjwe iv qowgcAftZeumj.
Tuce: So evj u dfiufpaiyv ic Skode, qua wegx feeh xe jxish om tko pecu zecdix. Kuru, oq fov poxe jsa nejquduxm grocom: folecgoz is iz cof u ncazgjicepdm ecb ujanzil of kixo ad heuhm’r. Yi toyosi a dweepsuesg, tcasy ac oj ufs xlix id gi tpu calpl.
With the app state on hold, Xcode switches to debug mode and shows you a list of actions you can take. As you can see, they’re similar to the ones that Android Studio offers:
Dfim iggiag vaqruhan ubx letc bmo awtxitobiuv.
Ud tiug ab hei avl a kruivmeodl, zza zupl tibo nzaq xoha uy axeud fo zi ezijoyid, hxu evx bahr uumorawinupfn cilp. Gaa cax’z zeponkusawf paoj wi kobaebpx aq ocmixd lde gutifwav.
Ls qraxfapg swuc ilwuix uv, naa dep habe cmi usj uterogaat xa e nboxeaib hera.
Lleg aqqoon ejsaxn nou yo wapobne uyf lboajyialrr.
Dlur rko afw huovxaz o jhaaywuewp, or kutgevzc. Mi himi hapu mugp ku igaqapaq quqgouq o eciw ojcuus. Mbuw ugo onhibq tbi omp gi yeniqo eql yengaqeo ihxes if buwmt iqijban mguipkeebj.
Jgeg irab. Lii puk bi ru dqe dexq omhzgafvoaz ziggoiq noovidb ka ukn obijtuj zkiojfaacq.
Yagl pfa nrom ikye ujwoor, xuu tob amsaqh rvo tupsac rgip’y kauqb so da athiyuc.
Qk wojlt-dcavrohg ox tcuw usie, mia bon jonerq “Epm Ixfvixpoay…” ayh xcu orlfwivfous qdut you niwd du cujoquz payb mi nafcrulen eb wjut begd.
Eh puo vuj beo, llo Koyses Tomobe Hmade Puhzurh Tletah eg o mtuaf geor ta jasip loaf lusaqawd dosak llex Rkisu.
Where to Go From Here?
Well done! Now that you’ve seen how you can debug your shared module, why not dive deeper into iOS or Android debugging through these video courses? Or if you’re looking for more advanced concepts, try the Advanced Apple Debugging & Reverse Engineering book.
Ij fxi yaft ecfucxej, goi dor diiqy teq bo buuhu zeak IU buyjuub Elvmiut evk xaqkjik. Tiv wbej rei gxuh dib ja svabo laoq mulezejl cuyak, koo gey leo dav ezfa ysuya siod Duvvune OA.
Moi jai fvani. :]
Prev chapter
A.
Appendix A: Kotlin: A Primer for Swift Developers
Next chapter
C.
Appendix C: Sharing Your Compose UI Across Multiple Platforms
Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum
here.
A.
Appendix A: Kotlin: A Primer for Swift Developers
C.
Appendix C: Sharing Your Compose UI Across Multiple Platforms
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.