diff --git a/Connect4.xcworkspace/contents.xcworkspacedata b/Connect4.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..b2758ea --- /dev/null +++ b/Connect4.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Connect4.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Connect4.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Connect4.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Connect4_CLI/Connect4_CLI.xcodeproj/project.pbxproj b/Connect4_CLI/Connect4_CLI.xcodeproj/project.pbxproj new file mode 100644 index 0000000..88d4ca9 --- /dev/null +++ b/Connect4_CLI/Connect4_CLI.xcodeproj/project.pbxproj @@ -0,0 +1,305 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 90BAEE022D34FAF100C6B480 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90BAEE012D34FAF100C6B480 /* main.swift */; }; + 90BAEE0A2D34FFA900C6B480 /* Model in Frameworks */ = {isa = PBXBuildFile; productRef = 90BAEE092D34FFA900C6B480 /* Model */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 90BAEDFC2D34FAF100C6B480 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 90BAEDFE2D34FAF100C6B480 /* Connect4_CLI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Connect4_CLI; sourceTree = BUILT_PRODUCTS_DIR; }; + 90BAEE012D34FAF100C6B480 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 90BAEDFB2D34FAF100C6B480 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 90BAEE0A2D34FFA900C6B480 /* Model in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 90BAEDF52D34FAF100C6B480 = { + isa = PBXGroup; + children = ( + 90BAEE002D34FAF100C6B480 /* Connect4_CLI */, + 90BAEDFF2D34FAF100C6B480 /* Products */, + 90BAEE082D34FFA400C6B480 /* Frameworks */, + ); + sourceTree = ""; + }; + 90BAEDFF2D34FAF100C6B480 /* Products */ = { + isa = PBXGroup; + children = ( + 90BAEDFE2D34FAF100C6B480 /* Connect4_CLI */, + ); + name = Products; + sourceTree = ""; + }; + 90BAEE002D34FAF100C6B480 /* Connect4_CLI */ = { + isa = PBXGroup; + children = ( + 90BAEE012D34FAF100C6B480 /* main.swift */, + ); + path = Connect4_CLI; + sourceTree = ""; + }; + 90BAEE082D34FFA400C6B480 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 90BAEDFD2D34FAF100C6B480 /* Connect4_CLI */ = { + isa = PBXNativeTarget; + buildConfigurationList = 90BAEE052D34FAF100C6B480 /* Build configuration list for PBXNativeTarget "Connect4_CLI" */; + buildPhases = ( + 90BAEDFA2D34FAF100C6B480 /* Sources */, + 90BAEDFB2D34FAF100C6B480 /* Frameworks */, + 90BAEDFC2D34FAF100C6B480 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Connect4_CLI; + packageProductDependencies = ( + 90BAEE092D34FFA900C6B480 /* Model */, + ); + productName = Connect4_CLI; + productReference = 90BAEDFE2D34FAF100C6B480 /* Connect4_CLI */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 90BAEDF62D34FAF100C6B480 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1420; + LastUpgradeCheck = 1420; + TargetAttributes = { + 90BAEDFD2D34FAF100C6B480 = { + CreatedOnToolsVersion = 14.2; + }; + }; + }; + buildConfigurationList = 90BAEDF92D34FAF100C6B480 /* Build configuration list for PBXProject "Connect4_CLI" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 90BAEDF52D34FAF100C6B480; + productRefGroup = 90BAEDFF2D34FAF100C6B480 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 90BAEDFD2D34FAF100C6B480 /* Connect4_CLI */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 90BAEDFA2D34FAF100C6B480 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 90BAEE022D34FAF100C6B480 /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 90BAEE032D34FAF100C6B480 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 90BAEE042D34FAF100C6B480 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 90BAEE062D34FAF100C6B480 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 90BAEE072D34FAF100C6B480 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 90BAEDF92D34FAF100C6B480 /* Build configuration list for PBXProject "Connect4_CLI" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 90BAEE032D34FAF100C6B480 /* Debug */, + 90BAEE042D34FAF100C6B480 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 90BAEE052D34FAF100C6B480 /* Build configuration list for PBXNativeTarget "Connect4_CLI" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 90BAEE062D34FAF100C6B480 /* Debug */, + 90BAEE072D34FAF100C6B480 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + 90BAEE092D34FFA900C6B480 /* Model */ = { + isa = XCSwiftPackageProductDependency; + productName = Model; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 90BAEDF62D34FAF100C6B480 /* Project object */; +} diff --git a/Connect4_CLI/Connect4_CLI/main.swift b/Connect4_CLI/Connect4_CLI/main.swift new file mode 100644 index 0000000..80cdedc --- /dev/null +++ b/Connect4_CLI/Connect4_CLI/main.swift @@ -0,0 +1,11 @@ +// +// main.swift +// Connect4_CLI +// +// Created by Adam BONAFOS on 13/01/2025. +// + +import Foundation + +print("Hello, World!") + diff --git a/Model/.gitignore b/Model/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/Model/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Model/Package.swift b/Model/Package.swift new file mode 100644 index 0000000..cda3b64 --- /dev/null +++ b/Model/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "Model", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "Model", + targets: ["Model"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "Model", + dependencies: []), + .testTarget( + name: "ModelTests", + dependencies: ["Model"]), + ] +) diff --git a/Model/README.md b/Model/README.md new file mode 100644 index 0000000..3d677e7 --- /dev/null +++ b/Model/README.md @@ -0,0 +1,3 @@ +# Model + +A description of this package. diff --git a/Model/Sources/Model/Board.swift b/Model/Sources/Model/Board.swift new file mode 100644 index 0000000..16ea9fc --- /dev/null +++ b/Model/Sources/Model/Board.swift @@ -0,0 +1,35 @@ +// +// Board.swift +// +// +// Created by Adam BONAFOS on 13/01/2025. +// + +import Foundation + +public struct Board { + let rowNb: Int + let columnNb: Int + var grid: [[Int]] + + init(rowsNb: Int = 6, columnsNb: Int = 7) { + rowNb = rowsNb + columnNb = columnsNb + grid = Array(repeating: Array(repeating: 0, count: columnsNb), count: rowsNb) + } + + subscript(row: Int, column: Int) -> Int { + get { + guard row >= 0 && row < rowNb && column >= 0 && column < columnNb else { + fatalError("Out of board") + } + return grid[row][column] + } + set { + guard row >= 0 && row < rowNb && column >= 0 && column < columnNb else { + fatalError("Out of board") + } + grid[row][column] = newValue + } + } +} diff --git a/Model/Sources/Model/Model.swift b/Model/Sources/Model/Model.swift new file mode 100644 index 0000000..c88e2a8 --- /dev/null +++ b/Model/Sources/Model/Model.swift @@ -0,0 +1,6 @@ +public struct Model { + public private(set) var text = "Hello, World!" + + public init() { + } +} diff --git a/Model/Tests/ModelTests/ModelTests.swift b/Model/Tests/ModelTests/ModelTests.swift new file mode 100644 index 0000000..38c36bb --- /dev/null +++ b/Model/Tests/ModelTests/ModelTests.swift @@ -0,0 +1,11 @@ +import XCTest +@testable import Model + +final class ModelTests: XCTestCase { + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(Model().text, "Hello, World!") + } +}