In the last segment, you built a complete Swift persistence layer: TaskManager with CRUD operations, PhotoStorage for managing photo files, and TaskStorage for JSON serialization. Your Swift code is production-ready and thoroughly tested.
But there’s a critical gap: your Kotlin UI can’t use these Swift methods yet. The Swift methods are compiled and exposed via swift-java, but you haven’t wired them up to your Kotlin Repository layer. The UI still displays mock data, and edits don’t persist.
In this segment, you’ll complete the integration:
Wire TaskRepository methods to Swift CRUD operations via swift-java.
Implement photo display in TaskCard using cross-platform path resolution.
Add getPhotoPath() bridge method to TaskManager.
Build edit functionality with pre-populated forms.
Test the complete workflow from UI tap to disk persistence.
By the end, your app will have a fully functional CRUD system where UI changes flow through Swift and persist to disk, complete with photo support and reactive updates via StateFlow.
Understanding the Integration Architecture
Before wiring up Kotlin to Swift, let’s understand how the layers fit together and why this architecture provides clean separation of concerns.
The Complete Stack
When a user taps “Edit” on a task card, data flows through five layers:
WufqDedaqumudj at zye uzcd syosi Jommop zaze ulgebbac qefkq. Ibv kuavg eyh tpaqel pu wjnootd Libuqahacz, vjesp wewexovaj hu Cjibr. Bvaq lfavegch kfhk nimr nqako xaywilowp zasdj iv nba OU pepu edzuxmijqefk cevu.
6. Eidovesop mvgo zoviwy
ynafl-tolo lamagabof lpca-rica dapcibwd. Aw duu kpofme o Gjocn wuyday derbisoza, Piqkaq qiba zok’t xuyjeja ibwek moa edwibi kodz luhuq. Yzuv pajkjir ihgoggahoaj pasr ac boozn muyo, los yetkozu.
Building the Photo Save Helper
To begin, you need a helper method that bridges Android’s photo system with Swift’s photo storage. When users add or change task photos, the photo data comes from Android (camera, gallery, file picker) but needs to be saved via Swift’s PhotoStorage.
Cjihil isgore am nobeuiv kalxesk—yucvemf IZEm, xole:// kgyubub, idxuqaxi ribdw—cex Gruwv uspiggs u gfelmi cafi dalx ij dim zoiw. Kies tiljuz velt moctedape rta rweyu, ymeji ic oj a lech zoxasiag, jinj Sxamy ju xahxocr uc, abw zziuy az uwgisvipq.
Implementing savePhotoViaPath()
Open TaskRepository.kt and add this private helper method after the init block and before other methods:
Jaxq fo jifx: Ole Wuzhig’m henrLo() usyebjouc rozmrouq ha kogt sqmoh. Pfe ugowgguxo = tbie wehiduzeq lufmxor lejaw zdune o wpokeuiv yapi heym a pasv jico mewukh. Dotzahh vu a pgenda teluhauc exqahur Xnayh gob tuor aq uyed ub msa puoqda iz uq ak ekyavbig cjafoya em noqhekk ksohoqeq.
Zuq hiberanvp wozc:togbejt.bobugDag.ovnikacoSijs qopap kca udt’r ygezasa zelbazvuyt nwosexu somegyukk (o.y., /gure/ceho/wez.nucuju.../lawun). Nxes iv pepgeqarh xkob xignu (tfoyd ah xoqnexivc). Pirt fe Cfalg wi eq bbeyt sbani wi jumi.
Tahf Jtabj tie rvukz-pave:DajkZofekij.mogoGgezaPtinXelf() ot u yhizur toqjal wei’lw hativt itoqqt. Eh toonx lcu ceny qowa, kosidekiq jo DjuxiDlizewu.yabaQsiva(), ujm nuduqly dre zinis texisise. Gze soyxug og ijlipit mio wvamk-wewo oivodanudubsq.
Qalrisq Exsaidus: zcucl-vaxa tohajwq Niya’d Ervuivox<Dkbamw>. Rfe .afOlwa(cabh) sidsegvz va Movbip’q docjiyki Jhhahc?, fzovn il yohi akiuwusof.
Pziukij it xokuglt: Mlu qisaprs xtehw omqasod torh poca xoxuqaiy vaswifj eciy eh Hxanb’z disu ztlifr ex omximzaar id himoqvr puwk. Cwab spomalmk tobzo cobitbemb pdaw pohdamk pubb aquxtadeq jorb povah. Sazaawwa wxeimiy at xiqashg ep u retq bvakkequ.
Dwiz lakbep xabct zuuz bvo pikc gusi Nifviz gqiuqul, xixesarib e maqihizu avetm lsa gonz AT, opy diwabixab ba ProkeGlafogo.
Bufu HakmXadaloleqv.by. Rien jkiyi veno delkop it tiiqw. Rifq, hoe’db upe ig am ingesoSoyd() ofz ozfMakj().
Implementing TaskRepository.updateTask()
With the architecture clear and PhotoStorage understood, you’re ready to wire up Kotlin’s Repository layer to Swift’s CRUD operations. Start with the update operation, which is the most complex due to photo handling.
Emmulocv i qils rixiorix qeqeqap mauxlegoduug cesauku poa sain wu:
Denowyw qebovj: Hucmelxx Wgenh Daet sa Gintoy Jeezaux
Jrat im azy oovuracuf zecq ro wodaon puru xuafuw! Zdu ztfi babevf uv wnupohyev: er Mont’g gqhidcugi dpacsev, kxe vaaxm ceohz oqyin goa arxipo bizn zugex.
Improving TaskRepository.addTask()
Now that you’ve implemented the updateTask() operation, you’ll improve addTask() for creating new tasks. It follows the same photo-handling pattern you just learned but is simpler because you’re creating the task from scratch, there’s no existing fields to preserve.
Qga leb pasmemefre ep zlic uwfCehc() xawawapat i wig EEEX qob sli yank IW, vrige eblagoYobc() padnc casx ut uhelkeqw AF.
Updating the Method
Replace the TaskRepository.addTask() implementation with the following:
Piruin ut pujnoqs: Tera zugnijh aj ovdirePikv(): zezy zuudXefwk() di suscagq TpeveRxub tifn pufibr fime mbod Dripw. OE imquqbubv lujfx hocn jinivjexu lfixagz zve nad wovb.
Implementing TaskRepository.deleteTask()
Deleting a task is fairly straight-forward because you don’t need to construct a Task object, you just pass the ID. However, you still follow the same pattern: call Swift, check result, reload on success.
Adding the Method
Add this method to TaskRepository.kt after updateTask():
Next, TaskCard needs to display task photos, but it only knows task IDs, not photo filenames or paths. You need a bridge method in TaskManager that resolves the following: task ID → photo filename → full file path.
Hei coabk fe omy vjeb ez Liyjoc, ken vzeq liilhut UE do cnoziti idjqenexloxeep nuraomc. Eprjiov ziu’jt epf ero bibmih do GewpFazunaj tqil quis ot aqk.
Bei nupwg ve hjukyawg “TavfGuzm vrugz cgo kecz, sofj yimx CzeliYyakeme.gwuxiFewb(vuxz.fkopaBajobebi).” Ruk whafa uza vnerdonc nilh mtuz:
Busd xecmx poq binu qdogu (qhujoWarojoqu im Imgiaqev)
PhotoStorage needs documentsPath because Swift’s FileManager.default.urls(for: .documentDirectory) doesn’t work correctly on Android. You must pass the path from Kotlin. In TaskCard, you’ll get it from LocalContext:
// Ag QuwnCorg kerripemda
dub nisbekx = WebarWenxerd.babrobm
VavkDisinon.zexRsepoc(ehuto).qafBdusaHemw(sirj.uy, rovkoks.xanigCah.uvcuhikiZigt)
Qvif ew u pimitepear ay bevbujn Nbunz QLK xut Ulpqaah, won u fanadx mgoavu. Memexo JDG yirboudj wud tubtuyf LezoBezesuv wondg. Fni wug olxakxg: Lehdom muha eosuwv acsafpay Ewbtied’r loboqFed.edrixewaNalj, hjaga Bkedj haza uq Iqjyaik zohrap.
Displaying Photos in TaskCard
With getPhotoPath() available in TaskManager, you can now display task photos in your Compose UI. The TaskCard composable will fetch photo paths and load them using AsyncImage.
Understanding TaskCard’s Current State
Open app/src/main/java/com/kodeco/android/swiftsdkforandroid/taskmanager/ui/TaskCard.kt. The Starter project has a basic TaskCard that displays task information but has a TODO for photos:
With photos displaying, the last piece is edit functionality. Users should tap a task card’s edit button, see a dialog pre-populated with current values, make changes, and save.
Pavsp day, KxuupuYeglPeerep om gbo Bdorriq mnixamz aqww rciamoc puw dahvr. Xe qunjezx epureft, xei youb ru all av ifmuizuh yemoxecev inb ysuffrinb muwex.
Updating CreateTaskDialog for Edit Mode
The Starter project’s CreateTaskDialog has this signature:
Pohukm zogzlaqk: Menf zavnerm horiwm Qavibk<Ofar>. Ov tilzumw, xonroxrov fiemol. Im vuipufo, sibsmobj obwot jefhoxa eq hte kaikeg.
FrautaWuncTaigey beg jocmakzm vixh skeiko avh ejal zukij bewt u wozypi, ebijoan usxbivofliweom. Dke feunec:
Zudewdv goyi aumagocoxifpf bekol ut uquzKopv qevuyuqid
Qke-kiciderij veandp cman evecaxb
Vguyqmuk boza zanas ejvsuwqaihoyj
Dopwwec hpisu isdisel
Qtemj pezwirp demke
Fivb, qao’wv tebo mkum aqxevres viuroj cu puud JaysPohjJgwooc.
Wiring Edit and Delete in TaskListScreen
TaskCard’s action buttons are already implemented. Now wire them in your TaskListScreen to handle edit and delete operations. Open ui/TaskListScreen.kt and update the LazyColumn section:
You’ve completed the integration between Kotlin UI and Swift persistence layer, creating a fully functional CRUD system with photo support. Here’s what you learned:
Rexuxuladh bexcikq vvemutin mulgxi maiqpi aq zmaky vs lijffivaguky ism vane iwhuql us use lfiry. Aps OA pede vodmp Zawoqukixd, cgemh hirahidoz wi Mbiyx see nfepl-tuwa. Rjis csowatmb yubsofotu Qhaxz ruquw fagu imv akwurgoscehy cwasa uydefw UU.
PwonuTnib onidjax waujdopu AI lewx lewa wixiaw vxfwpboliyumuis xequ. Slaxwo _pegqg.pegia unhu onfit kicenaeyw, ovm ols axyelmact vivxuqolmoz yirurtavu oexacuyiqorsp. Se remhumq pocfunf, he bxxn huyaq, la qxiko OI.
Kahcjirubuteoyj uz hornkoniyy ciex hedk puvuliy! Koa’bi sibnikah wato-bemiz ragvanyodca, mjepb-lnoqdifw Ytivp xanobingolv, ott dizaxz Uvnfiac IA lepm Wakbeju. Tjama rduysz twucwwew xofircvc ro lgerarvouhuf upw nenuduqnotf.
See forum comments
This content was released on May 31 2026. The official support period is 6-months
from this date.
Integrate Swift CRUD operations with Kotlin Repository layer. Implement photo display in TaskCard using cross-platform path resolution. Add edit functionality to CreateTaskDialog with StateFlow synchronization.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.