I have a requirement where I need to create a library that consumes backend service and stores locally, My question is can I have local database within static libary and what is the best possible way to achive the same.
Asked
Active
Viewed 54 times
0
-
A local database is just a local file. Use `NSFileManager` to retrieve the data folder path, and create a database there from the library code (unless it's there already). You can use SQLite, Core Data, or a homegrown format of your choosing, depends on the structure of the data you want to store. – Seva Alekseyev May 06 '20 at 14:00
-
Hi @SevaAlekseyev I need to create a library for serving db sync offline support by consuming webservices and saving to local db, As per your suggestion I need to store SQLite file in document folder, but I didnt find what is homegrown format...and also let me know is it good idea to create static library file for my requirement or I need to create framework template. Please do suggest me..thanks for you time and help. Also I would appriciate if you are able to share any useful links. – Naresh May 06 '20 at 14:22
-
"Homegrown format" means data format that you come up with. I don't know the entirety of your requirements, but from what I've heard, a static library will suffice. All that said, you sound like you don't know where to start. Is this a work project, or a school one, or a hobby one? – Seva Alekseyev May 06 '20 at 14:46
-
@SevaAlekseyev its a work project, but data security is very important and we need lib because we have existing apps in ionic and cordova which can consume native code and that is the reason we came up with library. and we need data persistance which I am not aware of how to do it in library..so I posted my query. – Naresh May 06 '20 at 14:57
-
So, are you new to native development on iOS? Also, while reverse engineering a native code library is harder, it's not impossible. If you're thinking of protecting your Web API by wrapping it native code, it will not stop a determined enough attacker. – Seva Alekseyev May 06 '20 at 15:30
-
See this discussion: https://stackoverflow.com/questions/2016250/sensitive-data-in-memory/2016288#2016288 – Seva Alekseyev May 06 '20 at 15:39
-
No, I am native iOS developer but I have not come accross such scenario of using persistant storage in lib package but I know its not possible to reverse engineer the library file or any iOS binary, but is it good practice to create sqlite file from my static lib into target app sandbox space and have necessary business logic or how the other existing libraries do their design architecture for such usecases. – Naresh May 06 '20 at 17:34
-
Why not? Working with a SQLite database from a library is the same as working with it from an app. The library will inherit the sandbox space from the app that links to it. NSFileManager will work all the same. What is you problem you're stuck on right now? – Seva Alekseyev May 06 '20 at 18:13