Skip to content

Commit

Permalink
Merge pull request #511 from nimblehq/release/4.7.0
Browse files Browse the repository at this point in the history
Release - 4.7.0
  • Loading branch information
blyscuit authored Aug 15, 2023
2 parents 8336744 + da4526d commit 5e7d284
Show file tree
Hide file tree
Showing 51 changed files with 472 additions and 51 deletions.
1 change: 0 additions & 1 deletion .github/wiki/Deliverable-Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ The file [DeliverableConstants.rb](https://github.com/nimblehq/ios-templates/blo
## Configure later

- Developer can modify the `DeliverableConstants` at any time.
- Use the command `sh deliverable_setup.sh` to open `DeliverableConstants` with Xcode.
- Open the file manually at `fastlane/Constants/DeliverableConstants.rb` with any IDE.
11 changes: 11 additions & 0 deletions .github/wiki/Selecting-User-Interface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Selecting User Interface

Current the template supports setup with two user interfaces:
- UIKit
- SwiftUI

To select a user interface when creating a project pass the argument `--interface [SwiftUI or UIKit]` with the `make` script.

```bash
sh make.sh --bundle-id [BUNDLE_ID_PRODUCTION] --bundle-id-staging [BUNDLE_ID_STAGING] --project-name [PROJECT_NAME] --interface SwiftUI
```
1 change: 1 addition & 0 deletions .github/wiki/_Sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [[Home]]
- [[Getting Started]]
- [[Deliverable Configurations]]
- [[Selecting User Interface]]

## Architecture

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/test_swiftui_install_script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test SwiftUI Install Script

on:
push:
branches: [ feature/**, bug/**, chore/** ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
Test:
name: Test
runs-on: macOS-12
steps:
- uses: actions/checkout@v3

- name: Bundle install
run: bundle install

- name: Start Install Script for SwiftUI Template App
run: sh make.sh --bundle-id co.nimblehq.template --bundle-id-staging co.nimblehq.template.staging --project-name TemplateApp --interface SwiftUI

- name: Build and Test
run: bundle exec fastlane buildAndTest
env:
CI: true
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Install Script
name: Test UIKit Install Script

on:
push:
Expand All @@ -14,14 +14,12 @@ jobs:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Bundle install
run: bundle install

- name: Start Install Script for Template App
run: sh make.sh --bundle-id co.nimblehq.template --bundle-id-staging co.nimblehq.template.staging --project-name TemplateApp
- name: Start Install Script for UIKit Template App
run: sh make.sh --bundle-id co.nimblehq.template --bundle-id-staging co.nimblehq.template.staging --project-name TemplateApp --interface UIKit

- name: Build and Test
run: bundle exec fastlane buildAndTest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_upload_build_to_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ jobs:
${{ runner.os }}-pods-
- name: Start Install Script for Template App
run: sh make.sh --bundle-id co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp
run: sh make.sh --bundle-id co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface UIKit

- name: Start Setup Script for Template App Firebase Upload
run: sh set_up_test_firebase.sh
run: cat Scripts/Swift/SetUpTestFirebase.swift Scripts/Swift/Extensions/FileManager+Utils.swift | swift -
env:
MATCH_REPO: ${{ secrets.MATCH_REPO }}
STAGING_FIREBASE_APP_ID: ${{ secrets.STAGING_FIREBASE_APP_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_upload_build_to_test_flight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
${{ runner.os }}-pods-
- name: Start Install Script for Template App
run: sh make.sh --bundle-id co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp
run: sh make.sh --bundle-id co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface UIKit

- name: Start Setup Script for Template App TestFlight Upload
run: sh set_up_test_testflight.sh
Expand Down
2 changes: 0 additions & 2 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require './fastlane/Constants/Constants'

# Warn when there is a big PR
warn("This pull request is quite big (#{git.lines_of_code} lines changed), please consider splitting it into multiple pull requests.") if git.lines_of_code > 500

Expand Down
76 changes: 76 additions & 0 deletions Scripts/Swift/Extensions/FileManager+Utils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import Foundation

extension FileManager {

func moveFiles(in directory: String, to destination: String) {
let currentDirectory = currentDirectoryPath
let files = try? contentsOfDirectory(
atPath: "\(currentDirectory)/\(directory)"
)
if let files = files {
for file in files {
guard file != ".DS_Store" else { continue }
do {
try moveItem(
atPath: "\(currentDirectory)/\(directory)/\(file)",
toPath:"\(currentDirectory)/\(destination)/\(file)"
)
} catch {
print("Error \(error)")
}
}
}
}

func rename(file: String, to destination: String) {
let currentDirectory = currentDirectoryPath
do {
try moveItem(
atPath: "\(currentDirectory)/\(file)",
toPath:"\(currentDirectory)/\(destination)"
)
} catch {
print("Error \(error)")
}
}

func removeItems(in directory: String) {
let currentDirectory = currentDirectoryPath
do {
try removeItem(atPath: "\(currentDirectory)/\(directory)")
} catch {
print("Error \(error)")
}
}

func replaceAllOccurrences(of original: String, to replacing: String) {
let files = try? allFiles(in: currentDirectoryPath)
guard let files else { return print("Cannot find any files in current directory") }
for file in files {
do {
let text = try String(contentsOf: file, encoding: .utf8)
let modifiedText = text.replacingOccurrences(of: original, with: replacing)
try modifiedText.write(to: file, atomically: true, encoding: .utf8)
} catch {
print(error.localizedDescription)
}
}
}

private func allFiles(in directory: String) throws -> [URL] {
let url = URL(fileURLWithPath: directory)
var files = [URL]()
if let enumerator = enumerator(
at: url,
includingPropertiesForKeys: [.isRegularFileKey],
options: [.skipsHiddenFiles, .skipsPackageDescendants]
) {
for case let fileURL as URL in enumerator {
let fileAttributes = try? fileURL.resourceValues(forKeys:[.isRegularFileKey])
guard fileAttributes?.isRegularFile ?? false else { continue }
files.append(fileURL)
}
}
return files
}
}
20 changes: 20 additions & 0 deletions Scripts/Swift/Helpers/SafeShell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation

@discardableResult
func safeShell(_ command: String) throws -> String? {
let task = Process()
let pipe = Pipe()

task.standardOutput = pipe
task.standardError = pipe
task.arguments = ["-c", command]
task.executableURL = URL(fileURLWithPath: "/bin/zsh")
task.standardInput = nil

try task.run()

let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output = String(data: data, encoding: .utf8)

return output
}
50 changes: 50 additions & 0 deletions Scripts/Swift/SetUpCICDService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/swift

import Foundation

let fileManager = FileManager.default

enum CICDService {
case github, bitrise, codemagic, later

init?(_ name: String) {
switch name.lowercased() {
case "g", "github":
self = .github
case "b", "bitrise":
self = .bitrise
case "c", "codemagic":
self = .codemagic
case "l", "later":
self = .later
default:
return nil
}
}
}

var service: CICDService? = nil

while service == nil {
print("Which CI/CD service do you use (Can be edited later) [(g)ithub/(b)itrise/(c)odemagic/(l)ater]: ")
service = CICDService(readLine() ?? "")
}

switch service {
case .github:
print("Setting template for Github Actions")
fileManager.removeItems(in: "bitrise.yml")
fileManager.removeItems(in: "codemagic.yaml")
case .bitrise:
print("Setting template for Bitrise")
fileManager.removeItems(in: "codemagic.yaml")
fileManager.removeItems(in: ".github/workflows")
case .codemagic:
print("Setting template for CodeMagic")
fileManager.removeItems(in: "bitrise.yml")
fileManager.removeItems(in: ".github/workflows")
case .later, .none:
print("You can manually setup the template later.")
}

print("✅ Completed")
18 changes: 18 additions & 0 deletions Scripts/Swift/SetUpDeliveryConstants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/swift

import Foundation

let fileManager = FileManager.default

print("Do you want to set up Constants values? (Can be edited later) [Y/n]: ")

var arg = readLine() ?? "y"

switch arg.lowercased() {
case "y", "yes", "":
let error = try safeShell("open -a Xcode fastlane/Constants/Constant.swift")
guard let error = error, !error.isEmpty else { break }
print("Could not open Xcode. Make sure Xcode is installed and try again.\nRaw error: \(error)")
default:
print("✅ Completed. You can edit this file at 'fastlane/Constants/Constant.swift'.")
}
25 changes: 25 additions & 0 deletions Scripts/Swift/SetUpInterface.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/swift

import Foundation

let fileManager = FileManager.default

var interface = "UIKit"

switch CommandLine.arguments[1] {
case "SwiftUI", "s", "S":
print("=> 🦅 Setting up SwiftUI")
interface = "SwiftUI"
let swiftUIAppDirectory = "tuist/Interfaces/SwiftUI/Sources/Application"
fileManager.rename(
file: "\(swiftUIAppDirectory)/App.swift",
to: "\(swiftUIAppDirectory)/\(CommandLine.arguments[2])App.swift"
)
default:
print("=> 🦉 Setting up UIKit")
interface = "UIKit"
}

fileManager.moveFiles(in: "tuist/Interfaces/\(interface)/Project", to: "")
fileManager.moveFiles(in: "tuist/Interfaces/\(interface)/Sources", to: "{PROJECT_NAME}/Sources")
fileManager.removeItems(in: "tuist/Interfaces")
16 changes: 16 additions & 0 deletions Scripts/Swift/SetUpTestFirebase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let teamIdPlaceholder = "<#teamId#>"
let stagingFirebaseAppIdPlaceholder = "<#stagingFirebaseAppId#>"
let firebaseTesterGroupsPlaceholder = "<#group1#>, <#group2#>"
let matchRepoPlaceholder = "[email protected]:{organization}/{repo}.git"

let envMatchRepo = ProcessInfo.processInfo.environment["MATCH_REPO"] ?? ""
let envStagingFirebaseAppId = ProcessInfo.processInfo.environment["STAGING_FIREBASE_APP_ID"] ?? ""
let envTeamId = ProcessInfo.processInfo.environment["TEAM_ID"] ?? ""
let firebaseTesterGroup = "nimble"

let fileManager = FileManager.default

fileManager.replaceAllOccurrences(of: teamIdPlaceholder, to: envTeamId)
fileManager.replaceAllOccurrences(of: stagingFirebaseAppIdPlaceholder, to: envStagingFirebaseAppId)
fileManager.replaceAllOccurrences(of: firebaseTesterGroupsPlaceholder, to: firebaseTesterGroup)
fileManager.replaceAllOccurrences(of: matchRepoPlaceholder, to: envMatchRepo)
9 changes: 9 additions & 0 deletions Tuist/Interfaces/SwiftUI/Project/.sourcery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sources:
- {PROJECT_NAME}/Sources
templates:
- tools/sourcery/templates
output:
{PROJECT_NAME}Tests/Sources/Mocks/Sourcery
args:
autoMockableTestableImports:
- {PROJECT_NAME}
60 changes: 60 additions & 0 deletions Tuist/Interfaces/SwiftUI/Project/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
platform :ios, '14.0'
use_frameworks!
inhibit_all_warnings!

def testing_pods
pod 'Quick', '~> 6.0'
pod 'Nimble', '~> 11.0'
pod 'Sourcery'
pod 'SwiftFormat/CLI'
end

target '{PROJECT_NAME}' do
# UI
pod 'Kingfisher'

# Backend
pod 'Alamofire'
pod 'JSONAPIMapper', :git => 'https://github.com/nimblehq/JSONMapper', :tag => '1.1.1'

# Storage
pod 'KeychainAccess'

# Tools
pod 'Firebase/Crashlytics'
pod 'NimbleExtension', :git => 'https://github.com/nimblehq/NimbleExtension', :branch => 'master'
pod 'R.swift'
pod 'Factory'

# Development
pod 'SwiftLint'
pod 'Wormholy', :configurations => ['Debug Staging', 'Debug Production']
pod 'xcbeautify'
pod "ArkanaKeys", path: "./ArkanaKeys/ArkanaKeys"
pod "ArkanaKeysInterfaces", path: "./ArkanaKeys/ArkanaKeysInterfaces"

target '{PROJECT_NAME}Tests' do
inherit! :search_paths
testing_pods
end

target '{PROJECT_NAME}KIFUITests' do
testing_pods
pod 'KIF', :configurations => ['Debug Staging', 'Debug Production']
pod 'KIF/IdentifierTests', :configurations => ['Debug Staging', 'Debug Production']
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
config.build_settings['ENABLE_BITCODE'] = 'NO'
if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
end
end
10 changes: 10 additions & 0 deletions Tuist/Interfaces/SwiftUI/Sources/Application/App.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SwiftUI

@main
struct {PROJECT_NAME}App: App {
var body: some Scene {
WindowGroup {
HomeView()
}
}
}
Loading

0 comments on commit 5e7d284

Please sign in to comment.