Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 3 additions & 57 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,62 +1,8 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## MacOS
.DS_Store

## User settings
xcuserdata/

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

## SPM
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
8 changes: 8 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tools]
swiftlint = "0.54.0"
swiftformat = "0.53.3"

[settings]
jobs = 6
http_timeout = 30
experimental = true
6 changes: 6 additions & 0 deletions .mise/helpers/common
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -euo pipefail

# Predefined variables
readonly EXT_BUILD_DIR="$MISE_PROJECT_ROOT/.build"
7 changes: 7 additions & 0 deletions .mise/tasks/autocorrect
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# mise description="Clean build directory"
set -euo pipefail

source "$MISE_PROJECT_ROOT/.mise/helpers/common"

swiftlint autocorrect --quiet
7 changes: 7 additions & 0 deletions .mise/tasks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# mise description="Build the project"
set -euo pipefail

source "$MISE_PROJECT_ROOT/.mise/helpers/common"

xcrun swift build
7 changes: 7 additions & 0 deletions .mise/tasks/clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# mise description="Clean build directory"
set -euo pipefail

source "$MISE_PROJECT_ROOT/.mise/helpers/common"

rm -rf "$EXT_BUILD_DIR"
9 changes: 9 additions & 0 deletions .mise/tasks/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# mise description="Show environment"
set -euo pipefail

source "$MISE_PROJECT_ROOT/.mise/helpers/common"

xcrun sw_vers
xcrun xcode-select -p
xcrun xcodebuild -version
5 changes: 5 additions & 0 deletions .mise/tasks/format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# mise description="Format the project"
set -euo pipefail

swiftformat $MISE_PROJECT_ROOT
8 changes: 8 additions & 0 deletions .mise/tasks/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# mise description="Lint the project"
set -euo pipefail

source "$MISE_PROJECT_ROOT/.mise/helpers/common"

swiftlint --strict --quiet
swiftformat . --lint
7 changes: 7 additions & 0 deletions .mise/tasks/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# mise description="Test the project"
set -euo pipefail

source "$MISE_PROJECT_ROOT/.mise/helpers/common"

xcrun swift test
10 changes: 10 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--swiftversion 5.10
--exclude .build
--maxwidth 120
--allman false
--disable wrapMultilineStatementBraces
--funcattributes prev-line
--typeattributes prev-line
--varattributes prev-line
--wraparguments before-first
--wrapparameters before-first
16 changes: 16 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
disabled_rules:
- trailing_comma
- opening_brace
- force_try

included:
- Sources/
- Tests/

identifier_name:
excluded:
- r

type_name:
excluded:
- T
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
mise := ~/.local/bin/mise

define HELP_BODY
USAGE: make <subcommand>

SUBCOMMANDS:
help Show help.
setup Set up development environment.
clean Clean build folder.
env Show build environment.
build Build.
test Run tests.
format Format source code.
autocorrect Autocorrect lint issues if possible.
lint Lint source code.

endef
export HELP_BODY

help:
@echo "$$HELP_BODY"

setup:
curl "https://mise.run" | sh

clean:
@$(mise) run clean

env:
@$(mise) run env

build: env
@$(mise) run build

test:
@$(mise) run test

format:
@$(mise) install
@$(mise) run format

autocorrect:
@$(mise) install
@$(mise) run autocorrect

lint:
@$(mise) install
@$(mise) run lint
27 changes: 27 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// swift-tools-version: 5.10

import PackageDescription

let package = Package(
name: "SwiftCommons",
platforms: [
.macOS(.v10_13),
.iOS(.v15),
],
products: [
.library(
name: "SCInject",
targets: ["SCInject"]
),
],
targets: [
.target(
name: "SCInject",
dependencies: []
),
.testTarget(
name: "SCInjectTests",
dependencies: ["SCInject"]
),
]
)
37 changes: 37 additions & 0 deletions Sources/SCInject/Assembler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2024 Marcin Iwanicki and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import Foundation

public final class Assembler {
private let container: Container

public init(container: Container) {
self.container = container
}

@discardableResult
public func assemble(_ assemblies: [Assembly]) -> Assembler {
for assembly in assemblies {
assembly.assemble(container)
}
return self
}

public func resolver() -> Resolver {
container
}
}
21 changes: 21 additions & 0 deletions Sources/SCInject/Assembly.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2024 Marcin Iwanicki and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import Foundation

public protocol Assembly {
func assemble(_ registry: Registry)
}
Loading