Fruta: Building a Feature-Rich App with SwiftUI

Overview

Fruta: Building a Feature-Rich App with SwiftUI

Create a shared codebase to build a multiplatform app that offers widgets and an App Clip.

Overview

The Fruta sample app builds an app for macOS, iOS, and iPadOS that implements SwiftUI platform features like widgets, App Clips, and localization. Users can order smoothies, save favorite drinks, collect rewards, and browse recipes in English and Russian.

The sample app’s Xcode project includes widget extensions that enable users to add a widget to their iOS Home screen or the macOS Notification Center, and view their rewards or a favorite smoothie. The Xcode project also includes an App Clip target. With the App Clip, users can discover and instantly launch some of the app's functionality on their iPhone or iPad without installing the full app.

The Fruta sample app leverages Sign in with Apple and Apple Pay to provide a streamlined user experience.

Configure the Sample Code Project

To build this project for iOS 15, use Xcode 13. The runtime requirement is iOS 15. To build this project for macOS 12 Monterey beta 7, use Xcode 13 beta 5. To configure this project, follow these steps:

  1. To run on your devices, including on macOS, set your team in the targets’ Signing & Capabilities panes. Xcode manages the provisioning profiles for you.
  2. To run on an iOS or iPadOS device, open the iOSClip.entitlements file and update the value of the Parent Application Identifiers Entitlement to match the iOS app's bundle identifier.
  3. Make a note of the App Group name on the iOS target’s Signing & Capabilities tab in Project Settings. Substitute this value for group.example.fruta in the Model.swift file.
  4. To enable the in-app-purchase flow, edit the Fruta iOS "Run" scheme, and select Configuration.storekit for StoreKit Configuration.

Create a Shared Codebase in SwiftUI

To create a single app definition that works for multiple platforms, the project defines a structure that conforms to the App protocol. Because the @main attribute precedes the structure definition, the system recognizes the structure as the entry point into the app. Its computed body property returns a WindowGroup scene that contains the view hierarchy displayed by the app to the user. SwiftUI manages the presentation of the scene and its contents in a platform-appropriate manner.

@main
struct FrutaApp: App {
    @StateObject private var model = Model()
    
    var body: some Scene {
        WindowGroup {
            ContentView()
                .environmentObject(model)
        }
        .commands {
            SidebarCommands()
            SmoothieCommands(model: model)
        }
    }
}

View in Source

For more information, see App Structure and Behavior.

Offer an App Clip

On iOS and iPadOS, the Fruta app offers some of its functionality to users who don't have the full app installed as an App Clip. The app's Xcode project contains an App Clip target, and, instead of duplicating code, reuses code that’s shared across all platforms to build the App Clip. In shared code, the project makes use of the Active Compilation Condition build setting to exclude code for targets that don't define the APPCLIP value. For example, only the App Clip target presents an App Store overlay to prompt the user to get the full app.

VStack(spacing: 0) {
    Spacer()
    
    orderStatusCard
    
    Spacer()
    
    if presentingBottomBanner {
        bottomBanner
    }
    
    #if APPCLIP
    Text(verbatim: "App Store Overlay")
        .hidden()
        .appStoreOverlay(isPresented: $presentingAppStoreOverlay) {
            SKOverlay.AppClipConfiguration(position: .bottom)
        }
    #endif
}
.onChange(of: model.hasAccount) { _ in
    #if APPCLIP
    if model.hasAccount {
        presentingAppStoreOverlay = true
    }
    #endif
}

View in Source

For more information, see Creating an App Clip with Xcode and Choosing the Right Functionality for Your App Clip.

Create a Widget

To allow users to see some of the app's content as a widget on their iOS Home screen or in the macOS Notification Center, the Xcode project contains targets for widget extensions. Both use code that’s shared across all targets.

For more information, see WidgetKit.

You might also like...
A standalone, flexible API that provides a full-featured rich text editor for iOS applications.
A standalone, flexible API that provides a full-featured rich text editor for iOS applications.

Twitter Text Editor A standalone, flexible API that provides a full featured rich text editor for iOS applications. This provides a robust text attrib

IGStoryButtonKit provides an easy-to-use button with rich animation and multiple way inspired by instagram story/stories.
IGStoryButtonKit provides an easy-to-use button with rich animation and multiple way inspired by instagram story/stories.

Introduction Have you ever seen UI like instagram story, haven't you? Actually, features like instagram story have been implemented in many applicatio

The ultimate spinning wheel view that supports dynamic content and rich customization.
The ultimate spinning wheel view that supports dynamic content and rich customization.

The ultimate spinning wheel control that supports dynamic content and rich customization. Main Features 🏵 Dynamic content, supports texts, images, an

A rich-text editor for iOS

DTRichTextEditor This project aims to provide a replacement for Apple's severely limited UITextView and to allow for editing attributed strings. It co

Powerful text framework for iOS to display and edit rich text.
Powerful text framework for iOS to display and edit rich text.

YYText Powerful text framework for iOS to display and edit rich text. (It's a component of YYKit) Features UILabel and UITextView API compatible High

A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view
A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view

ZSSRichTextEditor The Editor ZSSRichTextEditor is a beautiful Rich Text WYSIWYG Editor for iOS. It includes all of the standard editor tools one would

Rich Markdown editing control for iOS
Rich Markdown editing control for iOS

MarkdownTextView Rich Markdown Editing for iOS MarkdownTextView is an iOS framework for adding rich Markdown editing capabilities. Support for Markdow

RichTexture is a rich text editor for iOS.

RichTexture About RichTexture is a rich text editor for iOS. Running Open RichTexture.xcworkspace, change the bundle identifier to an identifier linke

Smooch is the best way to have personal, rich conversations with people on your website or customers on any device

Smooch is the best way to have personal, rich conversations with people on your website or customers on any device. Our features, integrations and developer-friendly APIs empower companies to connect with their customers in a whole new way.

GroceryMartApp-iOS-practice - To Practice fundamental SwiftUI feature like navigation, state mamagement, customazing etc
GroceryMartApp-iOS-practice - To Practice fundamental SwiftUI feature like navigation, state mamagement, customazing etc

🥬 GroceryMartApp-iOS-practice 아래의 내용은 스윗한 SwiftUI 책의 실전 앱 구현하기 을 바탕으로 정리한 내용입니다

DGPreview - Make UIKit project enable preview feature of SwiftUI
DGPreview - Make UIKit project enable preview feature of SwiftUI

DGPreview Make UIKit project enable preview feature of SwiftUI Requirements iOS

A UICollectionViewLayout subclass displays its items as rows of items similar to the App Store Feature tab without a nested UITableView/UICollectionView hack.
A UICollectionViewLayout subclass displays its items as rows of items similar to the App Store Feature tab without a nested UITableView/UICollectionView hack.

CollectionViewShelfLayout A UICollectionViewLayout subclass displays its items as rows of items similar to the App Store Feature tab without a nested

Returns true for all possible feature flags within the Twitter Mac app!

twitterinject Returns true for all possible feature flags within the Twitter Mac app! On Apple platforms, the default feature flags are present within

Essential Feed App – Image Feed Feature

Essential Feed App – Image Feed Feature

A Flutter powered messaging app including Firebase registration, authentication and group messaging feature.

we_chat A Flutter powered messaging app including Firebase registration, authentication and group messaging feature. Getting Started This project is a

Bill splitting app with tip feature
Bill splitting app with tip feature

Tipsy Tipsy is a bill splitting app with tip feature. You can split the total bi

Ios-exercise - In this exercise applicant should implement a new feature into an existing sample app

Cooking app In this exercise applicant should implement a new feature into an ex

AudioPlayer is syntax and feature sugar over AVPlayer. It plays your audio files (local & remote).

AudioPlayer AudioPlayer is a wrapper around AVPlayer. It also offers cool features such as: Quality control based on number of interruption (buffering

Instagram-like photo browser and a camera feature with a few line of code in Swift.
Instagram-like photo browser and a camera feature with a few line of code in Swift.

Fusuma is a Swift library that provides an Instagram-like photo browser with a camera feature using only a few lines of code.

Owner
Alexander Cyon
Crypto & DLT dev 💸 OSS author 📖 Donations: BTC: 3GarsdAzLpEYbhkryYz1WiZxhtTLLaNJwo ETH: 0xAB8F0137295BFE37f50b581F76418518a91ab8DB
Alexander Cyon
A curated list of awesome SwiftUI tutorials, libraries, videos and articles.

Awesome SwiftUI ??️ A curated list of awesome SwiftUI tutorials, libraries, sessions and articles. Contributing Found a SwiftUI library or snippet tha

Chinsyo 607 Jan 3, 2023
🤖 WWDC19 player using SwiftUI

WWDCPlayer Watch WWDC19 sessions with WWDCPlayer ?? Requirements Xcode 11 Beta Swift 5.1 License WWDCPlayer is under MIT license. See the LICENSE file

Minseob Yoon 49 Nov 4, 2022
FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

null 10 Dec 11, 2022
A thread safe, performant, feature rich image fetcher

PINRemoteImage Fast, non-deadlocking parallel image downloader and cache for iOS PINRemoteImageManager is an image downloading, processing and caching

Pinterest 4k Jan 9, 2023
A feature-rich circular slider control written in Swift.

MTCircularSlider Screenshot Usage To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 1

Eran Boudjnah 132 Jan 1, 2023
his is my second app, made right after the I am Rich app

I-am-Poop ?? Hello everyone! This is my second app, made right after the I am Rich app, to better fixate the concepts I learned during this lesson, wh

Victor Colen 1 Oct 11, 2021
RichTextKit is a Swift-based library for working with rich text in UIKit, AppKit and SwiftUI.

About RichTextKit RichTextKit is a Swift-based library that lets you work with rich text in UIKit, AppKit and SwiftUI. RichTextKit is under developmen

Daniel Saidi 282 Dec 28, 2022
Gemini is rich scroll based animation framework for iOS, written in Swift.

Overview What is the Gemini? Gemini is rich scroll based animation framework for iOS, written in Swift. You can easily use GeminiCollectionView, which

Shohei Yokoyama 3k Dec 27, 2022
RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing.

RichEditorView RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. Written in Swift 4 Supports iOS 8+ through Cocoapod

Caesar Wirth 1.8k Dec 24, 2022