Skip to content

Commit

Permalink
Merge pull request #105 from squareup/bradfol/fix-example
Browse files Browse the repository at this point in the history
Rename module target to Knit and fix example project
  • Loading branch information
bradfol authored Jan 10, 2024
2 parents 62bfe7d + 8250ac5 commit 3be5b90
Show file tree
Hide file tree
Showing 31 changed files with 72 additions and 29 deletions.
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
KnitDIRegistrationTests.swift
KnitDITypeSafety.swift

# Example project

# Files generated by knit-cli
Example/KnitExample/KnitDITypeSafety.swift
Example/KnitExampleTests/KnitDIRegistrationTests.swift

# Example's bootstrap script creates a binary from local sources
Example/knit-cli
33 changes: 24 additions & 9 deletions Example/KnitExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objectVersion = 60;
objects = {

/* Begin PBXBuildFile section */
2C360AEA2B4E1A2C00C88B99 /* Knit in Frameworks */ = {isa = PBXBuildFile; productRef = 2C360AE92B4E1A2C00C88B99 /* Knit */; };
C40D0D1F2A838D140095AC59 /* KnitExampleUserAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40D0D1E2A838D140095AC59 /* KnitExampleUserAssembly.swift */; };
C43334F32A3FDD43003BA9E3 /* KnitExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43334F22A3FDD43003BA9E3 /* KnitExampleApp.swift */; };
C43334F52A3FDD43003BA9E3 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43334F42A3FDD43003BA9E3 /* ContentView.swift */; };
C43334F72A3FDD44003BA9E3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C43334F62A3FDD44003BA9E3 /* Assets.xcassets */; };
C43334FA2A3FDD44003BA9E3 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C43334F92A3FDD44003BA9E3 /* Preview Assets.xcassets */; };
C43335062A3FDDD3003BA9E3 /* KnitExampleAssembly.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43335052A3FDDD3003BA9E3 /* KnitExampleAssembly.swift */; };
C433350A2A3FDF68003BA9E3 /* Knit in Frameworks */ = {isa = PBXBuildFile; productRef = C43335092A3FDF68003BA9E3 /* Knit */; };
C44754F72A3FE7570072333A /* KnitDITypeSafety.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44754F62A3FE7570072333A /* KnitDITypeSafety.swift */; };
C44755172A3FEA5E0072333A /* KnitDIRegistrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44755162A3FEA5E0072333A /* KnitDIRegistrationTests.swift */; };
C44755192A3FEA740072333A /* TestModuleAssembler.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44755182A3FEA740072333A /* TestModuleAssembler.swift */; };
Expand All @@ -36,7 +36,6 @@
C43334F42A3FDD43003BA9E3 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
C43334F62A3FDD44003BA9E3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
C43334F92A3FDD44003BA9E3 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
C43335042A3FDD78003BA9E3 /* knit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = knit; path = ..; sourceTree = "<group>"; };
C43335052A3FDDD3003BA9E3 /* KnitExampleAssembly.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KnitExampleAssembly.swift; sourceTree = "<group>"; };
C44754F62A3FE7570072333A /* KnitDITypeSafety.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KnitDITypeSafety.swift; sourceTree = "<group>"; };
C447550D2A3FEA120072333A /* KnitExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KnitExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -49,7 +48,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C433350A2A3FDF68003BA9E3 /* Knit in Frameworks */,
2C360AEA2B4E1A2C00C88B99 /* Knit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -66,7 +65,6 @@
C43334E62A3FDD43003BA9E3 = {
isa = PBXGroup;
children = (
C43335042A3FDD78003BA9E3 /* knit */,
C43334F12A3FDD43003BA9E3 /* KnitExample */,
C447550E2A3FEA120072333A /* KnitExampleTests */,
C43334F02A3FDD43003BA9E3 /* Products */,
Expand Down Expand Up @@ -139,7 +137,7 @@
);
name = KnitExample;
packageProductDependencies = (
C43335092A3FDF68003BA9E3 /* Knit */,
2C360AE92B4E1A2C00C88B99 /* Knit */,
);
productName = KnitExample;
productReference = C43334EF2A3FDD43003BA9E3 /* KnitExample.app */;
Expand All @@ -159,6 +157,8 @@
C44755122A3FEA120072333A /* PBXTargetDependency */,
);
name = KnitExampleTests;
packageProductDependencies = (
);
productName = KnitExampleTests;
productReference = C447550D2A3FEA120072333A /* KnitExampleTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
Expand All @@ -171,7 +171,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1430;
LastUpgradeCheck = 1420;
LastUpgradeCheck = 1520;
TargetAttributes = {
C43334EE2A3FDD43003BA9E3 = {
CreatedOnToolsVersion = 14.2;
Expand All @@ -191,6 +191,9 @@
Base,
);
mainGroup = C43334E62A3FDD43003BA9E3;
packageReferences = (
2C360AE82B4E1A2B00C88B99 /* XCLocalSwiftPackageReference ".." */,
);
productRefGroup = C43334F02A3FDD43003BA9E3 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -230,6 +233,7 @@
);
inputPaths = (
"$(SRCROOT)/KnitExample/KnitExampleAssembly.swift",
"$(SRCROOT)/KnitExample/KnitExampleUserAssembly.swift",
);
outputFileListPaths = (
);
Expand All @@ -239,7 +243,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/usr/bin/xcrun --sdk macosx swift run knit-cli gen \\\n--assembly-input-path KnitExample/KnitExampleAssembly.swift \\\n--assembly-input-path KnitExample/KnitExampleUserAssembly.swift \\\n--type-safety-extensions-output-path KnitExample/KnitDITypeSafety.swift \\\n--unit-test-output-path KnitExampleTests/KnitDIRegistrationTests.swift\n";
shellScript = "./knit-cli gen \\\n--assembly-input-path KnitExample/KnitExampleAssembly.swift \\\n--assembly-input-path KnitExample/KnitExampleUserAssembly.swift \\\n--type-safety-extensions-output-path KnitExample/KnitDITypeSafety.swift \\\n--unit-test-output-path KnitExampleTests/KnitDIRegistrationTests.swift\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -280,6 +284,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -312,6 +317,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -340,6 +346,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -372,6 +379,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -516,8 +524,15 @@
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
2C360AE82B4E1A2B00C88B99 /* XCLocalSwiftPackageReference ".." */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ..;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
C43335092A3FDF68003BA9E3 /* Knit */ = {
2C360AE92B4E1A2C00C88B99 /* Knit */ = {
isa = XCSwiftPackageProductDependency;
productName = Knit;
};
Expand Down
2 changes: 1 addition & 1 deletion Example/KnitExample/KnitExampleUserAssembly.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright © Square, Inc. All rights reserved.

import Foundation
import KnitLib
import Knit

// @knit internal getter-named
/// An assembly expected to be registered at the user level rather than at the app level
Expand Down
17 changes: 17 additions & 0 deletions Example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Example Project

An example Xcode project that uses Knit.

## Setup

1. Run `./bootstrap` from the Example folder
1. Open the `KnitExample.xcodeproj` project

### Bootstrap Script

The bootstrap script compiles the Knit CLI tool from local source and moves the resulting executable to the Example directory.


For normal apps, the project should use the pre-complied executable binaries that are
included in the GitHub release zips (per release version).
(You are also free to download any of the released binary executables and place it in the Example directory to use it.)
4 changes: 4 additions & 0 deletions Example/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
cd ..
swift build --arch x86_64 --arch arm64 --product knit-cli
mv .build/apple/Products/Debug/knit-cli Example/
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let package = Package(
.macOS(.v12),
],
products: [
.library(name: "Knit", targets: ["KnitLib"]),
.library(name: "Knit", targets: ["Knit"]),
.executable(name: "knit-cli", targets: ["KnitCommand"])
],
dependencies: [
Expand All @@ -20,7 +20,7 @@ let package = Package(
],
targets: [
.target(
name: "KnitLib",
name: "Knit",
dependencies: [
.product(name: "Swinject", package: "Swinject"),
.product(name: "SwinjectAutoregistration", package: "SwinjectAutoregistration"),
Expand All @@ -43,9 +43,9 @@ let package = Package(
]
),
.testTarget(
name: "KnitLibTests",
name: "KnitTests",
dependencies: [
"KnitLib",
"Knit",
]
),
.testTarget(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright © Block, Inc. All rights reserved.
//

@testable import KnitLib
@testable import Knit
import XCTest

final class AbstractRegistrationTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright © Block, Inc. All rights reserved.
//

@testable import KnitLib
@testable import Knit
import XCTest

final class ComplexDependencyTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright © Square, Inc. All rights reserved.
//

@testable import KnitLib
@testable import Knit
import XCTest

final class DependencyBuilderTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

import Foundation
@testable import KnitLib
@testable import Knit
import XCTest

final class GeneratedModuleAssemblyTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright © Square, Inc. All rights reserved.
//

@testable import KnitLib
@testable import Knit
import XCTest

final class ModuleAssemblerTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright © Square, Inc. All rights reserved.
//

@testable import KnitLib
@testable import Knit
import XCTest

final class ModuleAssemblyOverrideTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright © Block, Inc. All rights reserved.
//

@testable import KnitLib
@testable import Knit
import XCTest

final class ModuleAssemblyScopingTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright © Block, Inc. All rights reserved.
//

@testable import KnitLib
@testable import Knit
import XCTest

final class ModuleCycleTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

import Foundation
@testable import KnitLib
@testable import Knit
import XCTest

final class ScopedModuleAssemblerTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import KnitLib
import Knit
import XCTest

protocol ServiceProtocol {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

import Foundation
@testable import KnitLib
@testable import Knit
import XCTest

final class SynchronizationTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright © Square, Inc. All rights reserved.
//

@testable import KnitLib
@testable import Knit
import Swinject

protocol TestResolver: Resolver { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright © Square, Inc. All rights reserved.
//

import KnitLib
import Knit
import XCTest

final class WeakResolverTests: XCTestCase {
Expand Down

0 comments on commit 3be5b90

Please sign in to comment.