Write multi-platform applications using SwiftUI (tutorial with source code)

introduce

I asked myself a question: Can I write a normal app in SwiftUI for 6-7 screens with authentication and widgets, so that one codebase can run on both macOS and iOS? I tried it and wanted to share my experience.

I want to state it right away: If you have an app larger than a small pet project, it's best not to write a multi-platform app. I suggest considering splitting the application into

  • Shared modules with business logic and possibly base UI components
  • The UI part of iOS
  • UI section for Mac/iPad

project preparation

I think many of you are familiar with how to create a new project in Xcode, but I'll describe this just in case.

insert image description here

insert image description here
insert image description here
insert image description here
At this point the project setup is complete and you can start writing code. You don't need any other specific settings.

Next, we'll discuss the nuances of working with multiplatform code: errors and hints that can haunt you.

Problems I can identify

</

おすすめ

転載: blog.csdn.net/iCloudEnd/article/details/130187945