Skip to content

JPrendy/module-ios-application

Repository files navigation

Module iOS Application

Description

A Swift Application that contains a Swift module/library that can be reused in many other projects.

Contents

Setup Steps

Important: we cannot import another app in another app aka Single View App calling a Single View App.

To create an application with many module, first we need to create a new folder, then start Xcode and create a workspace by going File > new > workspace and call it module-application and add it in the new folder you just created.

Next, we want to create a project in the workspace we just created by going File > new > project and select Single View App and call it module-ios-application. Make sure it is added to module-application. See the image below.

Once that has been created, create a class in the module-ios-application, for example this class is Pokemon.

import Foundation

public class Pokemon {
    
    public init() {}
    
    public let region = "Johto"

}

Add the following to AppDelegate.swift, this is important as we will know it will work when we add this class as part of framework

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    let test = Pokemon().region
    print("hello \(test)")
    return true
}

To create a module/framework, we want to create a project in the workspace we just created by going File > new > project and select framework and call it module-test-application. Make sure it is added to module-application. See the image below.

Now, carry over the data in Pokemon class to the framework project. After that has been added.

We go back to the Single View App, add drag the framework file into the module-ios-application. See the image below

Go back to AppDelegate.swift and remember to import the project in the file with import module_test_application. You should have something like the following below.

import UIKit
import module_test_application

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {



    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        let test = Pokemon().region
        print("hello \(test)")
        return true
    }

To set up fastlane, type the following in the terminal and follow the steps

fastlane init

How to run the project locally

To run the tests locally, run the following.

bundle exec fastlane tests

Tools

Linter: we use the following linter link.

Uploading Artifacts: we use the following way to upload Artifacts, they allow you to persist data like test results after a job has completed, see the following documentation link.

Creating images/icons: we use Figma to create images and icon. Figma makes it very easy to create designs in many different formats.

Creating a Mock Server: we use a mock server with Postman to quickly test apis, to see how to create a mock server, see the following video link.

Mobile Specific Tools:

Fastlane: Fastlane allows us to automate our development and release process link.

App Center: App Center is used to distribute an app, making it very easy to test on a physical device by using a fastlane plugin link.

Update Dependencies

Npm: How to update a npm package.

Gemfile: How to update a Gemfile package.

Releases

How to manage releases in a repository link.

Helpful resources

The following link provides helpful information video on how to setup a modules in Xcode

The following link provides helpful information article on how to setup a modules in Xcode

The following link provides helpful information on how to setup structures and classes in iOS

The following link provides helpful information on how to fix initializer is inaccessible due to 'internal' protection level

The following link provides helpful information on the differences between Framework, library, Package and Module

About

A Swift Application that contains a Swift module/library that can be reused in many other projects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published