Skip to content

Instantly share code, notes, and snippets.

class AppContext {
let container: DIContainer
init() {
self.container = DIContainer.init()
ServiceAssembly.assembled(in: container)
}
}
import Foundation
import FeatureService
public class Feature2 {
public struct Dependencies {
let feature1: Feature1Service
let feature3: Feature3Service
public init(feature1: Feature1Service, feature3: Feature3Service) {
self.feature1 = feature1
import FeatureService
extension Feature1: Feature1Service {
public func doSomething() {
print("Feature1 do something")
}
}
func testFeature2() {
let dependencies: Feature2.Dependencies = AnyInitializer(Feature2.Dependencies.init).resolve(by: container)
let f2 = Feature2(dependencies: dependencies)
f2.doSomething()
}
output:
Test Case '-[DITests.DITests testFeature2]' started.
/usr/bin/swift
-frontend -c /Feature3.swift
-primary-file PrivateModel.swift
-emit-module-path /PrivateModel\~partial.swiftmodule
-emit-module-doc-path /PrivateModel\~partial.swiftdoc
### Swift dependencies file v0 ###
provides-top-level:
- "Feature2"
provides-nominal:
- "8Feature2AAC"
provides-member:
- ["8Feature2AAC", ""]
provides-dynamic-lookup:
- "doSomething"
- "feature1"

Enable indexing

  • defaults delete com.apple.dt.Xcode IDEIndexEnable
  • defaults write com.apple.dt.Xcode IDEIndexEnable -bool YES

Disable indexing

  • defaults delete com.apple.dt.Xcode IDEIndexDisable
  • defaults write com.apple.dt.Xcode IDEIndexDisable -bool YES

Show Indexing numeric progress

  • defaults write com.apple.dt.Xcode IDEIndexerActivityShowNumericProgress -bool YES
2020-08-11 16:04:56.202 Xcode[33874:47419755] SourceKit-client: [2:request:775:690.9009] [398] {
key.request: source.request.indexer.notify-indexable-did-add-file,
key.filepath: "/Users/vedon/Documents/Private/ModularDesign/IndexingDemo/IndexingDemo/Modal.swift",
key.indexer.arg.indexer-token: 1,
key.indexer.arg.indexable.id: "/Users/vedon/Documents/Private/ModularDesign/IndexingDemo/IndexingDemo.xcodeproj/IndexingDemo-4ED35A0324E2816600806386"
}
2020-08-11 15:58:33.804 Xcode[33874:47408816] SourceKit-client: [2:request:156931:308.5030] [336] {
key.request: source.request.indexer.srv.jump-to-expression-definition,
key.indexer.arg.indexer-token: 1,
key.indexer.arg.query.name: "hello",
key.indexer.arg.query.doc-location: {
key.indexer.arg.doc-loc.url: "file:///Users/vedon/Documents/Private/ModularDesign/IndexingDemo/IndexingDemo/ViewController.swift",
key.indexer.arg.doc-loc.start-line: 17,
key.indexer.arg.doc-loc.start-col: 9,
key.indexer.arg.doc-loc.end-line: 17,
key.indexer.arg.doc-loc.end-col: 9,
2020-08-11 16:09:10.248 Xcode[33874:47431447] SourceKit-client: [2:response:775:944.9466] [227] {
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
key.syntaxmap: [
],
key.substructure: [
{
key.kind: source.lang.swift.decl.class,
key.name: "Modal",
key.offset: 147,
key.length: 55,