Skip to content

Commit

Permalink
feat: add a sample scenario that run on iOS 11 and iOS > 13
Browse files Browse the repository at this point in the history
  • Loading branch information
antranapp committed Nov 14, 2021
1 parent 96d5212 commit ad2855a
Show file tree
Hide file tree
Showing 16 changed files with 453 additions and 78 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Build and Test

# See available software: https://github.com/actions/virtual-environments/blob/master/images/macos/macos-10.15-Readme.md
runs-on: macos-10.15
runs-on: macos-11

steps:
- name: Cancel Previous Runs
Expand All @@ -24,16 +24,22 @@ jobs:
- uses: actions/checkout@v2
- name: Prepare Xcode
run: |
sudo xcode-select --switch /Applications/Xcode_12.4.app
sudo xcode-select --switch /Applications/Xcode_12.5.1.app
xcodebuild -version
swift --version
xcrun simctl list devices 14.4
xcrun simctl list devices 14.5
- name: Boot simulator
run: xcrun simctl boot "iPhone 12 Pro"

- name: Run Internal tests
run: xcodebuild clean build test -project Sample.xcodeproj -scheme "Sample-Internal" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=14.4"
run: xcodebuild clean build test -project Sample.xcodeproj -scheme "Sample-Internal" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=14.5"

- name: Run Production tests
run: xcodebuild clean build test -project Sample.xcodeproj -scheme "Sample-Production" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=14.4"
run: xcodebuild clean build test -project Sample.xcodeproj -scheme "Sample-Production" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=14.5"

- name: Build Internal tests iOS 12
run: xcodebuild clean build -project Sample.xcodeproj -scheme "Sample-Internal" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=12.4"

- name: Run Production tests iOS 12
run: xcodebuild clean build -project Sample.xcodeproj -scheme "Sample-Production" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=12.4"
155 changes: 149 additions & 6 deletions Sample/Sample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D76DC204271D136200396CE9"
BuildableName = "Sample-Internal-iOS11.app"
BlueprintName = "Sample-Internal-iOS11"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D76DC204271D136200396CE9"
BuildableName = "Sample-Internal-iOS11.app"
BlueprintName = "Sample-Internal-iOS11"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D76DC204271D136200396CE9"
BuildableName = "Sample-Internal-iOS11.app"
BlueprintName = "Sample-Internal-iOS11"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
45 changes: 45 additions & 0 deletions Sample/Sample/Resources/Info-Internal-iOS11.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
3 changes: 2 additions & 1 deletion Sample/Sample/Sources/Common/AppServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import Foundation

class AppServices: ObservableObject {
@available(iOS 13.0, *)
final class AppServices: ObservableObject {
let docURL: URL
let githubService: GithubService

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Combine
import Foundation
import SwiftUI

@available(iOS 13.0, *)
final class RepositoryListViewModel: ObservableObject {

private let githubService: GithubService
Expand Down
32 changes: 32 additions & 0 deletions Sample/Sample/Sources/Internal/Extensions/UIView+Autolayout.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright © 2021 An Tran. All rights reserved.
//

import Foundation
import UIKit

extension UIView {
func addAutolayoutSubview(_ subview: UIView) {
subview.translatesAutoresizingMaskIntoConstraints = false
addSubview(subview)
}

func addFillingSubview(_ subview: UIView, inset: CGFloat = 0) {
addAutolayoutSubview(subview)
NSLayoutConstraint.activate([
subview.leadingAnchor.constraint(equalTo: leadingAnchor, constant: inset),
subview.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -inset),
subview.topAnchor.constraint(equalTo: topAnchor, constant: inset),
subview.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -inset),
])
}

func addCenterSubview(_ subview: UIView) {
addAutolayoutSubview(subview)

NSLayoutConstraint.activate([
subview.centerXAnchor.constraint(equalTo: centerXAnchor),
subview.centerYAnchor.constraint(equalTo: centerYAnchor),
])
}
}
40 changes: 40 additions & 0 deletions Sample/Sample/Sources/Internal/InternalAppDelegateiOS11.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Copyright © 2021 An Tran. All rights reserved.
//

import Scenarios
import UIKit

@UIApplicationMain
final class InternalAppDelegate: BaseAppDelegate {

// MARK: Properties

private lazy var manager = BaseScenariosManager()

// MARK: APIs

override func makeRootViewController() -> UIViewController {
manager.makeAppController().rootViewController
}

override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
defer {
manager.prepare(window!)
}

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

@objc func application(
_ application: UIApplication,
performActionFor shortcutItem: UIApplicationShortcutItem,
completionHandler: @escaping (Bool) -> Void
) {
let result = manager.performAction(for: shortcutItem)
completionHandler(result)
}
}
30 changes: 30 additions & 0 deletions Sample/Sample/Sources/Internal/Scenarios/PrototypeScenario.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright © 2021 An Tran. All rights reserved.
//

import Foundation
import Scenarios
import UIKit

final class PrototypeScenario: Scenario {
static var name: String = "Prototype"
static var kind: ScenarioKind = .prototype

static var rootViewProvider: RootViewProviding {
NavigationAppController(withResetButton: true) { _ in
ViewController()
}
}
}

private final class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white

let label = UILabel()
label.text = "Prototype"

view.addCenterSubview(label)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ extension ScenarioKind {
@objc static let component = ScenarioKind(rawValue: "Component", nameForSorting: "3")
@objc static let designSystem = ScenarioKind(rawValue: "Design System", nameForSorting: "3")
@objc static let networking = ScenarioKind(rawValue: "Networking", nameForSorting: "4")
@objc static let prototype = ScenarioKind(rawValue: "Prototype", nameForSorting: "5")
}
Loading

0 comments on commit ad2855a

Please sign in to comment.