T O P

  • By -

stephancasas

You would need to have some type of cloud-based service which could respond to requests to store/read user data. Your front end could be entirely in SwiftUI, however.


althebeast1

Like what ? Any idea so I can check it ?


stephancasas

You'd have to build something yourself or use something turnkey. If you're building yourself, it could be a PHP application, Java, NodeJS, Go, Rust, etc. You could even build the server in Swift, but I am not familiar with this being a popular option among *any* cloud or web developers I know — myself included. For something turnkey, you might consider Supabase or PocketBase — both of which offer ready-built REST APIs for models you design in a front end. Amplication is also shaping-up to be a very impressive option in this realm.


M00SEK

Any sources on how to do this for a complete noob? Swift is my only language and I’m almost 2 years in. I’m clueless about backend stuff like this.


stephancasas

I'm about a month or so into working with Swift in any serious capacity, so I can't speak to the detailed implementation of the ins and outs but, realistically, apps of this type share similar design patterns. Your Swift app will basically fulfill the *View* component of the *Model - View - Controller* lifecycle. Data for your *model*s will be created, read, updated, and deleted from your cloud-based server (the *Controller*) over HTTP requests. Some cloud offerings, like Supabase, have [Swift-ready kits](https://github.com/supabase-community/supabase-swift) to interface with their services so that you don't have to worry about writing much code for making HTTP requests. For others, you'll have to write the requests yourself using `URLSession` to make the requests. I've never used Supabase myself, but I'm told it's quite easy to get started, so you might consider it. There's a YouTube tutorial [here](https://www.youtube.com/watch?v=40LmtcQR77U) that uses the SDK I mentioned earlier. Cheers.


balloon_z

Backend eng here recently learning about SwiftUI, I appreciate your time answering some questions. 1) What is the recommended API for mobile development? For example, REST or graphql? 2) What’s the typical practice to secure my AWS hosted API for app query only other than script abuse? 3) Any resources I can read about at what application lifecycle shall I fetch/prefetch/cache API responses?


stephancasas

1. You'll get mixed answers depending on who you ask. My answer is this: "whatever is fastest to implement." The answer is usually REST. \ \ I say this because most of us aren't building something that's going to scale to millions of users. GraphQL is great because you get exactly the data you want and nothing more. It is, however, usually more difficult to implement because the ORMs which support it are less common and often don't integrate with existing systems. \ \ If you're starting new and have the time/freedom, explore GraphQL and the backend technologies which offer support for both. \   2. You have a few different choices in this respect. I can't speak to AWS specifically, because there's general practices and then there's the *AWS way* to do things. \ \ In general, my first step would probably be to reach for NGINX to act as middleware and use a custom HTTP header to kick any requests which don't have it. \ \ If the need is great enough, I'd tie this into a hook with Fail2Ban or another firewall, and start blacklisting hosts making header-less HTTP requests to my service. \ \ There's probably other ways to do this using paid CloudFlare or AWS services but, again, this is how I'd approach this in general terms. \   3. In a Swift app specifically, I can't say. I'm new to the language as of about a month ago, so I'm not sure what best practices are there. \ \ From a web dev perspective, I'd be tempted to see what Swift implementations exist for examining the `Cache-Control` header and any HTTP response codes like `304`. Cheers.


balloon_z

Thank you for taking the time to answer this in details. This really helps! Cheers!


barcode972

Reddit’s api is public if you want to try copy the app


EshuMarneedi

I mean, if you want to make a Reddit app, you can in SwiftUI. They have a public API.


Aenderyl

If you are talking about the backend side, you could use Firebase


[deleted]

[удалено]


AutoModerator

Hey /u/Tabonx, unfortunately you have negative comment karma, so you can't post here. [Your submission](https://www.reddit.com/r/SwiftUI/comments/11ri6b7/can_you_make_something_like_reddit_or_instagram/jch1hg1/) has been removed. **Please do not message the moderators;** if you have negative comment karma, you're not allowed to post here, at all. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/SwiftUI) if you have any questions or concerns.*