Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developing the ios(native) module. #4

Open
khairilushan opened this issue Apr 27, 2018 · 5 comments
Open

Developing the ios(native) module. #4

khairilushan opened this issue Apr 27, 2018 · 5 comments

Comments

@khairilushan
Copy link

Hi, First of all thank you for this example that you provided in this repo. Really help me to get started with Kotlin/ Native and MPP.
I just want to ask you, what is the best workflow for now, for develop the iOS (Native) module. For example if I want to use the iOS framework API (NSUserDefaults, NSURLSession, etc), what is the best practice to work on it? Which IDE should I choose to work on this part, since seems like we can't work on this via IntelliJ (for now). If you have some tips regarding setup for these stuff, I would love to know that more.

Thank You so much.

@Albert-Gao
Copy link
Owner

Albert-Gao commented Apr 29, 2018

Hi. Thanks for using the repo.

Can't say best practice because things continue getting better here in term of KN.

About IDE

  • If you want to call iOS API, you should use AppCode, one of the latest experimental version got the support for KN. Will give you the auto-completion support.

  • If you don't need to call iOS API, then any IDE which supports kotlin could do.

About sharing code

  • I suggest not move too much logic to the KN world. Only the business logic, otherwise you need to declare some really low-level API and implement them twice in order to reuse the upper level business logic.

  • I found some issues like, nowadays, even you write some code twice, still less than the KN part code. Because the platform official approach makes things much more easier to deal with(Like google's new architecture component). Things like persistent, I got a multi-platform approach to use JSON file to store some small data, thus, I could expend the business logic cover to features like persistent. But then you need to deal with all the CRUD and sync with UI which makes it harder.

I might be wrong because I am really not that kind of deep deep native expert who can re-invent the wheel in a concise way. xD

Brief

But KN really shines when you only embed all the very core business logic (without platform API). Like your model class and all the related logic.

So, the answer is yes, it works. I mean, write code and running on 2 platforms, but you should control it in a way that you can handle :)

Only my 2 cents, hope it helps.

@khairilushan
Copy link
Author

Hi, Thank you so much for your response and that explanation.
Currently Im trying to use it like this: So I have an expect class called NetworkService in my common module that I need to implement in both platform.
So I want to use Retrofit for android and NSURLSession for iOS implementation.

But when I open this platforms/ios module in AppCode I can't get the auto-completion to worked. But If I create a K/N project via AppCode (Using the latest version) I can get the auto-completion worked.
Do you know any workaround that I can use to develop this platform/ios module with the IDE support?

Once again, Thank you so much. :)

@khairilushan
Copy link
Author

I got it worked now. So I need to include the platform:ios module into the iOS project by following instructions described here > https://github.com/JetBrains/kotlin-native/blob/master/MULTIPLATFORM.md#4-ios-application .
So now I can open the iOS project in AppCode and develop the platform:ios along side with the iOS project with the IDE support.
Thank You.

@Albert-Gao
Copy link
Owner

Really thanks for sharing the information !

@skydsai
Copy link

skydsai commented Oct 25, 2018

Thank you for this example that you provided in this repo.Really help me to get started with Kotlin/ Native.Can you tell me, how to build the ios app or create ios app in AppCode in KN?because I according to (http://developine.com/kotlin-native-ios-development-multiplatform-project/ and https://blog.csdn.net/xiangzhihong8/article/details/80630159) ,step by step but build failed or build empty view or nothing, please help me, would you provided AppCode Demo in KN,Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants