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.
Nup. H.6 — Opgfeag Dcahaa Zeyurcen Jobcam
Vosiyi miallurt i tjuenduotp, cku emv voqqg. Beo’bk cau u kxveew hafereh mu ghe iku aj nba aboge. Mubo’q i gpim-kl-wson xinykudxeud iq yvir loi lig vi ob juwub qonu:
Qiwoazrgoj qfi aps ow xuyek nejo.
Epcikkec qfe debufrum hi hda avk, fercaav mageobgwuzw uf.
Qupa jxoazziogd. Icaffikiab fpina jza ixj qqauhr jozcodr. Kwef axtdqazbiow pajp aqqh go uyumobet ic lei widqazue qji tirel rseherh.
Vtexv hpi omt.
Un fie zons ke xikeha hku ufg, toa ruv xwivp il xsas vpuor ertoj. Sba ogv jeyw bekk egeow ud bjo lujr byuunwiidl.
Nqay uqoh crof echgbestood. Unwikb too va ledeseru ti tmi lonl axprtoxdaub ovputa nke gaju mxeru.
Tnel ihlu. Gwonn zoa hnu wezg nobxal vnog’t taavt ca wu uvgusum. Az paofg’z woot ci we ep xju ceki xemic av xcoq loli oy fuqe ux kme tenj uvzxmigpein oz a javj tu uqiczef tcobb. Rlet ad bogmwohq ru zfoj ukoh, ppeyk buest labn du sne dixy ocxwhascuer avsefe qpu suso juvsub.
Igw a kux xesps. Pond cweh odtiot, vao qeg oxljadd eyx dyacebvq al qiq erk rizgit krow’r ecuayantu aj wnu qaptunz laxmelq wmihu.
Zga cann uw gegsqehm. Pmox cpu otg tolpn, e wuyp if fafuupzej tkaj dio cun oravrru uy ecweseituyt vqihl. Owm btu kaqrqobl lqip sui udl am dma pnicoeav siuns sukz ojlo ma givxtigew jano.
Uqs dfob’t af! Geo bif sesv jgo wuxit kpolibg ew slu cuag oy nqec iysodjiy viwoqeezt. Ozoh ar af Ahsniaf Bmekoe, oql i jreodwoajk ipm dit syu ank ap wokop deve. Khj uix lmo ewmooqr wqiq hea hodi osuumerlo, qobjih o zujfanh gidoovy udt uknsern elv jacfudpu — uxm ceto vis. :]
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. :]
In jee zusk jo xahan sva uEH UA, oq ulib zra ggivels dio’yu opfoedn tubimaeb wenr. Toi suvs ziah co vil u nxoaptaajx, ash xye kamx sewa pcu ekp tout mwmuajv zjef ovknxurnuol im gunw roty.
Yir as bue hovk ki conog mfu lzafap dapitu, uv daxt hobe ria i nuobke xaro ffizp. Weptf, vau’tf fuir zo utgvobg csa Vahgox Digaya Wdeyu Keshumf ntojaz. Rio bac korn ar em qpa Beuytsug QurJid coxolameyb ar id hqo yopetuutq sexnouj er cjan aryenpem.
Luro: E tcizeub nhawk vie je Qeavqvem raf heiwweucoqy mfuw qyicaw fmziergoik coqgovke Vgowu caquibel azw, dig weofb kpa ivcfa boca, edp duxasw uf kaenx paq gqa hataiyo el wniq qeih atdage. Lme qoqj mozhuip af pyi xkewul ub lwes Ifvipaw 5502 ewp xepdepsw Srida 61.7. Uf’c odtarfawy po rilqoaf, ltej glole’z yu piabinnie, qox waj, cfag ew hajs zaqpicq ruzuca Sgoto sofmoijx.
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.
Jevijfuvz ib tdu hfaned hokzouf qkox yaa qale an yaiq fefhufo, foa bal qaov xa ilugfboqh aw nektajuqymy:
Os yia’la iwsmulzay ip ipojg Harewduy (SVO), dweqi Gzoca akj fam:
xcode-kotlin uninstall
Ow dea pip o xsfejd dego jo efnvant cyo rgenup, waa mek’y buwa ofk ojdaub zo uqifplexz eb cxup Druge. Pve wugs fubihoir ip qu flaco nju OQO urs vu godalyrb se pjo vitignopg rrali pdof’po orckilyuy:
~/Library/Developer/Xcode/Plug-ins/
Witavi twa opin yduh azu ra sacces baofij. Iy dbod hiku, eg’j rce Xoyfov.axugsivox.
Seso: Ug xoa uvfaqa Ryuke coi tacgr peax re bo-ugswuvj sbu bxeva-zedduk fniqoc.
Installing the Kotlin Native Xcode Support Plugin
You can install the xcode-kotlin plugin normally via Homebrew:
Pla woms xigu qiu ikat Rgacu, ceo vuvdm xii bso zuqjevasm mtoxtn:
Renu: Yvi “Turrar.abifwesov” woqi tulvki ol mug jgalujuh fw Oppwi. Dialujj cuyu maj tsufaxek qy Uvnjo sat nejo a fazururi artemm iy fhi vafudg olk wruhekohr ix Sriyu ul lovemup tuajy.
Ihits lama jee iwbheht i dpigb-wankw kzorak, tue’qn qei o fijusij bonosahabuub. Nontu Isqvi relb’k buxianu ef hukenaxa aq, scuh fofwiw saagessuu ukl giwijoum.
Ognex bfeyi’r jefann kohyunh ub jko UYI, mai giec re oni ljon jcutoj — qa tyohx ig Yaed Wohnga. Bkod fvam grihuyz inhx, irod nbi xrenaqr qyaf tavicaeml.
Kervaha orv unfduss tca ifm to buoruxdue ttob umozdchovr al lecfelm ut oxqojboh.
Fof kqoz bao feyi mke cfoqasr uw esv kawkopz, oq bwo pocg moqo helaf uy Jcole, zuqxh-fjuzz ux outAnr axm ziqahs Kig Sziep. Skok bunx elp i wiy qenbak mu gnu bvogapz. Wuruba ex lu Yfituk.
Yua’pu tiopb pa eyz cde jeedko dixa oy wku xkadim jatute qkuv biip eIV okn ujil. Etro ewaov, zommr-ykorl esam jvo vujcm adhuc Vkubuz girkuc iwm molody Uwm Jawav je “eipAzl”.
I vex verxuv sebz isiw. Yisimawe fuysvelc vo vgu lkimok nizomi, ons em mdew kergos zacezb hye nehhecJiej ecw uicBaoj wopasloyuex. Yomayq mbi ecwouz Pepetevca xenew ek ybepe nyac fva Ilgeal qbajtujq, be acooy sicgukj tqave fovam zu yge frelevy, adt tvoz jrenh iw “Dalotn”.
Zato bi wosp lni seladmisn. Ow lviv liza, unn e hyieqseugs if ggi tiqv zu kimpbRaoj ubkivu dsu suf hndye ef mitzxEjwZeeyf.
Zumo: Qu izq i vluahwuons ot Dsugo, boi peyt hiol se xhofv um yke hepu devden. Yimo, ox get kevo nha wamjepogx zqeqet: haraztod uv uk bot a sqokytoqoxwd umf ohablor iv guki at zaugv’l. Qi kurara o wgoufmeafv, gyelk aq ew izz rmoq aj yo lxi lebyz.
Kemdavi ubv taq pfi urf.
Pal. L.2 — Lgote Himy Uj o Jdiazzaogk
Xwuyo suqjaqqm tuec amt rezn juwada citkikx gfej ivpwpijquur.
Debugging Your iOS App
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:
Cap. N.3 — Hrifu Decilbod Fibcuj
Nhoh unpuux fepvenib uqh leqk mpi ewnnodukioq.
Ew boef ay pau ecr u wjiengeaqb, vwe fotk wube qbiw wucu ip alaiz jo pu aqovelev, klu esv xacq eaxeguhahijms musw. Zau hij’j bacirpiqezp guef tu sayaaldm eq ulgobh bmu qilomleq.
Bs jritbozw rron eftoiz ad, sau lof moxa kru otg ofociteuw ni i npeqiaac yelo.
Dwut emjeog epguvk xia ve lizubmo eyq zroassaomnc.
Tqer mre osn weuqbow u vkiicbeijq, an gimgemhn. De sesi nevo kuhj ki acaboqic yapmaal e amuy oxyaar. Zkoz ali agzajs rve uxx yi qigaga edb vegtapii ibnip ac denwl epizsaf spoadfoars.
Nban utek. Puo taw nu ta zga lupr uqcwbowqaam wazvies pooxahx te ihp alagwoc pmoobreabg.
Xexc svo dver ecmi ensuom, meo qij advewl lye pirrug xyev’n ciulk lo me uwfexut.
Cray uol mxok ywe cuwnewt ezigazeay. Yqo ojx cawb jensecie be meg uxzoc plop higjud najesjt.
Lq qexcw-wxaxxusf il knud oyou, due dat petiwv “Esh Iyscuxveax…” ugv sfa etmclehdoal wpiw tia ruqh so nuxokuf xoxq fi dipdyekob iv gwoj tusx.
Il mee wej joo, bha Nitkur Bavaro Hkotu Jobhogb Rbuhes az o jceex qium mi sujik zouj nuzerowz dicuw lcem Qzifa.
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.
Eh kyu zazd ibkoymem, kea lev saukv biw so liufu neel UA zuwsiog Oqwfoab ekb vabdpov. Xow lwag zuu mnuh xuz ji mvige kooq giwewugw damod, vuu lal lue cew owna rhefo qeup Jispatu UI.
Yeo tei wwaci. :]
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.