

{"id":115405,"date":"2023-06-27T09:00:56","date_gmt":"2023-06-27T03:30:56","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=115405"},"modified":"2026-06-01T14:32:09","modified_gmt":"2026-06-01T09:02:09","slug":"swift-tic-tac-toe-app","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/","title":{"rendered":"Swift Tic Tac Toe App \u2013 Play Anytime, Anywhere!"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:2612,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1eC5C7Y1rd92v0WIGEfTj-uilcvzAWoBn\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601085201\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1eC5C7Y1rd92v0WIGEfTj-uilcvzAWoBn\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-02 08:34:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-07 03:42:14&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-07 03:42:14&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>Welcome to this project, where we will build a Tic-Tac-Toe app using SwiftUI. Tic-Tac-Toe is a classic game that involves two players taking turns to mark X or O on a 3&#215;3 grid. The objective of the game is to get three of your marks in a row, either horizontally, vertically, or diagonally. By following this project, you will learn how to create a fully functional Tic-Tac-Toe game using the Swift programming language and SwiftUI framework.<\/p>\n<h3>About Swift Tic-Tac-Toe App<\/h3>\n<p>The objective of this project is to build a Tic-Tac-Toe app that allows users to play a tic-tac-toe game. We will implement the game logic and user interface and handle win\/draw conditions.<\/p>\n<h3>Prerequisites for Tic-Tac-Toe project using Swift<\/h3>\n<p>To follow this project, you should have basic knowledge of SwiftUI and the Swift programming language. It is also required to have Xcode installed on your Mac.<\/p>\n<h3>Download Swift Tic-Tac-Toe Project<\/h3>\n<p>Please download the source code of Swift Tic-Tac-Toe Project from the following link: <a href=\"https:\/\/drive.google.com\/file\/d\/1eC5C7Y1rd92v0WIGEfTj-uilcvzAWoBn\/view?usp=drive_link\"><strong>Swift Tic-Tac-Toe Project Code<\/strong><\/a>.<\/p>\n<h3>Steps to Create a Tic-Tac-Toe Game Using Swift<\/h3>\n<p>Following are the steps for developing the Swift Tic-Tac-Toe app Project:<\/p>\n<p><strong>Step 1:<\/strong> Create a new SwiftUI project in Xcode.<br \/>\n<strong>Step 2:<\/strong> Creating the Tic-Tac-Toe View<br \/>\n<strong>Step 3:<\/strong> Creating the Tic-Tac-Toe View Model<br \/>\n<strong>Step 4:<\/strong> Creating the AlertItem<\/p>\n<h4>Step 1: Create a new SwiftUI project in Xcode.<\/h4>\n<p><strong>a.<\/strong> Open Xcode and click on the \u201cCreate a new Xcode Project\u201d option.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/create-a-xcode.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115745 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/create-a-xcode.webp\" alt=\"create a xcode\" width=\"1602\" height=\"913\" \/><\/a><\/p>\n<p><strong>b.<\/strong> Now select the platform as \u201ciOS\u201d and the application type as \u201cApp\u201d.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/select-platform-as-ios-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115746 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/select-platform-as-ios-scaled.webp\" alt=\"select platform as ios\" width=\"2560\" height=\"1602\" \/><\/a><\/p>\n<p><strong>c.<\/strong> Now, Enter the name of the app and organization identifier, and select SwiftUI interface for building the UI of the app. Also, select Swift as a language for creating the app.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/enter-the-name-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115747 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/enter-the-name-scaled.webp\" alt=\"enter the name\" width=\"2560\" height=\"1599\" \/><\/a><\/p>\n<p><strong>d.<\/strong> Select the folder where you want to save the app and click on Create.<\/p>\n<p><strong>e.<\/strong> Now your project is ready for development, and you will see something like below.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/project-is-ready-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115748 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/project-is-ready-scaled.webp\" alt=\"project is ready\" width=\"2560\" height=\"1550\" \/><\/a><\/p>\n<p><strong>f.<\/strong> Drag and drop the \u201cX\u201d and \u201cO\u201d images in the assets<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/drag-and-drop-x-o-images-scaled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115749 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/drag-and-drop-x-o-images-scaled.webp\" alt=\"drag and drop x o images\" width=\"2560\" height=\"1557\" \/><\/a><\/p>\n<h4>Step 2: Creating the Tic-Tac-Toe View<\/h4>\n<p><strong>a.<\/strong>Create a new Swift file named <strong>&#8220;TicTacToeView.swift&#8221;<\/strong>.<br \/>\n<strong>b.<\/strong> In the <strong>TicTacToeView struct,<\/strong> define the layout of the game board using a <strong>LazyVGrid<\/strong> with three flexible columns.<br \/>\n<strong>c.<\/strong> Create an array of optional values representing the moves made by both players.<br \/>\n<strong>d.<\/strong> Create a <strong>ZStack<\/strong> for each square on the game board, overlaying a blue background rectangle and a white foreground rectangle.<br \/>\n<strong>e.<\/strong> Display an <strong>X<\/strong> or <strong>O<\/strong> image if the square has been filled.<br \/>\n<strong>f.<\/strong> Add an onTapGesture to each square to handle the player&#8217;s move.<br \/>\n<strong>g.<\/strong> Add space at the top and bottom of the game board using Spacer.<br \/>\n<strong>h.<\/strong> Disable the game board and display an alert if a win or draw has been detected.<br \/>\n<strong>i.<\/strong> Add padding to the game board.<br \/>\n<strong>j.<\/strong> Implement the <strong>TicTacToeView_Previews<\/strong> struct for previewing the view.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import SwiftUI\r\nstruct TicTacToeView: View {\r\n    \/\/ Create an instance of the GameViewModel as a state object\r\n    @StateObject private var viewModel = TicTacToeViewModel()\r\n    \/\/ Create image views for the X and O symbols\r\n    let xImage = Image(\"XImage\")\r\n    let oImage = Image(\"OImage\")\r\n    \r\n    var body: some View {\r\n        GeometryReader { geometry in\r\n            VStack {\r\n                \/\/ Add space at the top\r\n                Spacer()\r\n                \/\/ Create a grid of squares for the game board\r\n                LazyVGrid(columns: viewModel.columns, spacing: 5) {\r\n                    ForEach(0..&lt;9) { i in\r\n                        \/\/ Create a ZStack to overlay rectangles and images\r\n                        ZStack {\r\n                            \/\/ Create a blue rectangle as the background for the square\r\n                            Rectangle()\r\n                                .foregroundColor(.blue).opacity(0.9)\r\n                                .frame(width: geometry.size.width\/3 - 15,\r\n                                       height: geometry.size.width\/3 - 15)\r\n                                .cornerRadius(15)\r\n                            \/\/ Create a white rectangle as the foreground for the square\r\n                            Rectangle()\r\n                                .foregroundColor(.white)\r\n                                .frame(width: geometry.size.width\/3-30,\r\n                                       height: geometry.size.width\/3-30)\r\n                                .cornerRadius(10)\r\n                            \r\n                            \/\/ Display an X or O image if the square has been filled\r\n                            if let move = viewModel.moves[i] {\r\n                                if move.player == .human {\r\n                                    xImage\r\n                                        .resizable()\r\n                                        .frame(width: 50, height: 50)\r\n                                        .foregroundColor(.black)\r\n                                } else {\r\n                                    oImage\r\n                                        .resizable()\r\n                                        .frame(width: 50, height: 50)\r\n                                        .foregroundColor(.black)\r\n                                }\r\n                            }\r\n                        }\r\n                        \/\/ When the square is tapped, call the function to process the move\r\n                        .onTapGesture {\r\n                            viewModel.processPlayerMove(for: i)\r\n                        }\r\n                    }\r\n                    \/\/ Add space at the bottom\r\n                    Spacer()\r\n                }\r\n                \/\/ Disable the game board if a win or draw has been detected\r\n                .disabled(viewModel.isGameBoardDisabled)\r\n                \/\/ Add padding to the game board\r\n                .padding()\r\n                \/\/ Show an alert if a win or draw has been detected\r\n                .alert(item: $viewModel.alertItem) { alertItem in\r\n                    Alert(title: alertItem.title,\r\n                          message: alertItem.message,\r\n                          dismissButton: .default(alertItem.buttonTitle, action: { viewModel.resetGame() }))\r\n                }\r\n                \/\/ Add space at the bottom\r\n                Spacer()\r\n            }\r\n        }\r\n    }\r\n    \/\/ Define an enumeration for the players (human or computer)\r\n    enum Player {\r\n        case human, computer\r\n    }\r\n    \r\n    \/\/ Define a struct for a move, including the player and board index\r\n    struct Move {\r\n        let player: Player\r\n        let boarderIndex: Int\r\n        \r\n        \/\/ Provide an indicator for the move (X or O)\r\n        var indicator: String {\r\n            return player == .human ? \"xmark\" : \"circle\"\r\n        }\r\n    }\r\n    \r\n    \/\/ Define a preview for the view\r\n    struct TicTacToeView_Previews: PreviewProvider {\r\n        static var previews: some View {\r\n            TicTacToeView()\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<h4>Step 3: Creating the Tic-Tac-Toe View Model<\/h4>\n<p><strong>a.<\/strong> Create a new Swift file named <strong>&#8220;TicTacToeViewModel.swift&#8221;<\/strong>.<br \/>\n<strong>b.<\/strong> Define the layout of the game board as a grid with three flexible columns.<br \/>\n<strong>c.<\/strong> Define properties for moves, <strong>isGameBoardDisabled<\/strong>, and <strong>alertItem<\/strong>.<br \/>\n<strong>d.<\/strong> Implement the <strong>processPlayerMove<\/strong> method to handle processing the user&#8217;s move.<br \/>\n<strong>e.<\/strong> Implement the <strong>isSquareOccupied<\/strong> method to check if a square is already occupied.<br \/>\n<strong>f.<\/strong> Implement the <strong>determineComputerMovePosition<\/strong> method to determine a random unoccupied index for the computer&#8217;s move.<br \/>\n<strong>g.<\/strong> Implement the <strong>checkWinCondition<\/strong> method to check if a player has a winning move.<br \/>\n<strong>h.<\/strong> Implement the <strong>checkForDraw<\/strong> method to check if the game has ended in a draw.<br \/>\n<strong>i.<\/strong> Implement the <strong>resetGame<\/strong> method to reset the game board.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import SwiftUI\r\nfinal class TicTacToeViewModel: ObservableObject {\r\n    \r\n    \/\/ Defines the layout of the game board as a grid with 3 columns.\r\n    let columns : [GridItem] = [GridItem(.flexible()),\r\n                                GridItem(.flexible()),\r\n                                GridItem(.flexible()),]\r\n    \r\n    \/\/ An array of optional values representing the moves made by both players. Nil indicates that the square is not yet occupied.\r\n    @Published var moves:[TicTacToeView.Move?] = Array(repeating: nil, count: 9)\r\n    \r\n    \/\/ A flag indicating if the game board should be disabled to prevent further user interaction.\r\n    @Published var isGameBoardDisabled:Bool = false\r\n    \r\n    \/\/ An optional alert to be displayed to the user in case of a win or draw.\r\n    @Published var alertItem: AlertItem?\r\n    \r\n    \/\/ A method to handle processing the user's move.\r\n    func processPlayerMove(for position:Int) {\r\n        \r\n        \/\/ For human player:\r\n        \/\/ If the square is already occupied, do nothing and return.\r\n        if isSquareOccupied(in: moves, forIndex: position) {\r\n            return\r\n        }\r\n        \r\n        \/\/ Update the moves array to reflect the human player's move.\r\n        moves[position] = TicTacToeView.Move(player: .human, boarderIndex: position)\r\n        \r\n        \/\/ Check if the human player has won the game.\r\n        if checkWinCondition(for: .human, in: moves) {\r\n            alertItem = AlertContent.humanWins\r\n            return\r\n        }\r\n        \r\n        \/\/ Check if the game has ended in a draw.\r\n        if checkForDraw(in: moves) {\r\n            alertItem = AlertContent.draw\r\n            return\r\n        }\r\n        \r\n        \/\/ Disable the game board to prevent further user interaction.\r\n        isGameBoardDisabled = true\r\n        \r\n        \/\/ After a delay of 0.5 seconds, allow the computer to make a move.\r\n        DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [self] in\r\n            let computerPosition = determineComputerMovePosition(in: moves)\r\n            moves[computerPosition] = TicTacToeView.Move(player:.computer, boarderIndex: computerPosition)\r\n            isGameBoardDisabled = false\r\n            \r\n            \/\/ Check if the computer has won the game.\r\n            if checkWinCondition(for: .computer, in: moves) {\r\n                alertItem = AlertContent.computerWins\r\n                return\r\n            }\r\n            \r\n            \/\/ Check if the game has ended in a draw.\r\n            if checkForDraw(in: moves) {\r\n                alertItem = AlertContent.draw\r\n                return\r\n            }\r\n        }\r\n    }\r\n    \r\n    \/\/ A method to check if a square on the board is already occupied.\r\n    func isSquareOccupied(in moves: [TicTacToeView.Move?], forIndex index: Int) -&gt; Bool {\r\n        \/\/ Returns true if the move in the specified index is already occupied, otherwise false\r\n        return moves.contains(where: {$0?.boarderIndex == index})\r\n    }\r\n    \r\n    func determineComputerMovePosition(in moves:[TicTacToeView.Move?]) -&gt; Int {\r\n        \/\/ Determines a random unoccupied index for the computer's move\r\n        let occupiedIndices = Set(moves.compactMap { $0?.boarderIndex })\r\n        let allIndices = Set(0..&lt;9)\r\n        let unoccupiedIndices = allIndices.subtracting(occupiedIndices)\r\n        let randomIndex = unoccupiedIndices.randomElement()!\r\n        \r\n        return randomIndex\r\n    }\r\n    \r\n    func checkWinCondition(for player:TicTacToeView.Player, in moves:[TicTacToeView.Move?])-&gt;Bool{\r\n        \/\/ Checks whether the specified player has a winning move on the game board\r\n        let winPatterns:Set&lt;Set&lt;Int&gt;&gt; = [[0,1,2],\r\n                                         [3,4,5],\r\n                                         [6,7,8],\r\n                                         [0,3,6],\r\n                                         [1,4,7],\r\n                                         [2,5,8],\r\n                                         [0,4,8],\r\n                                         [2,4,6]]\r\n        let playerMoves = moves.compactMap{$0}.filter {$0.player == player}\r\n        let playerPositions = Set(playerMoves.map{$0.boarderIndex})\r\n        \r\n        for pattern in winPatterns where pattern.isSubset(of: playerPositions){return true}\r\n        \r\n        return false\r\n    }\r\n    \r\n    func checkForDraw(in moves:[TicTacToeView.Move?])-&gt;Bool{\r\n        \/\/ Checks if the game board is full and there is no winner\r\n        return moves.compactMap{$0}.count == 9\r\n    }\r\n    \r\n    func resetGame() {\r\n        \/\/ Resets the game board to its initial state\r\n        moves = Array(repeating: nil, count: 9)\r\n    }\r\n    \r\n}\r\n<\/pre>\n<h4>Step 4: Creating the AlertItem<\/h4>\n<p><strong>a.<\/strong> Create a new Swift file called <strong>&#8220;Alerts.swift&#8221;<\/strong>.<br \/>\n<strong>b.<\/strong> Create the <strong>AlertItem<\/strong> struct that conforms to the <strong>Identifiable<\/strong> protocol.<br \/>\n<strong>c.<\/strong> Create static properties for commonly-used alerts, such as <strong>humanWins<\/strong>, <strong>computerWins<\/strong>, and <strong>draw<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import SwiftUI\r\n\/\/ AlertItem is a struct that conforms to the Identifiable protocol\r\nstruct AlertItem:Identifiable {\r\n    \/\/ Each AlertItem has a unique ID\r\n    let id = UUID()\r\n    \r\n    \/\/ The title of the alert, displayed in bold\r\n    var title : Text\r\n    \r\n    \/\/ The message displayed in the alert\r\n    var message : Text\r\n    \r\n    \/\/ The text displayed on the button in the alert\r\n    var buttonTitle : Text\r\n}\r\n\/\/ AlertContent is a struct that holds static properties for commonly-used alerts\r\nstruct AlertContent {\r\n    \r\n    \r\n    static let humanWins = AlertItem(title: Text(\"YOU WIN!\"),\r\n                                     message: Text(\"You have beaten your phone\"),\r\n                                     buttonTitle: Text(\"Rematch\"))\r\n    \r\n    static let computerWins  = AlertItem(title: Text(\"YOU LOST!\"),\r\n                                         message: Text(\"Your phone has beaten you\"),\r\n                                         buttonTitle: Text(\"Rematch\"))\r\n    \r\n    static let draw = AlertItem(title: Text(\"DRAW!\"),\r\n                                message: Text(\"You have drawn against your phone\"),\r\n                                buttonTitle: Text(\"Rematch\"))\r\n    \r\n}\r\n<\/pre>\n<p>Now the app is ready to play.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe-project-output-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115754 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe-project-output-1.webp\" alt=\"swift tic tac toe project output\" width=\"800\" height=\"564\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe-app-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-115750 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe-app-output.webp\" alt=\"swift tic tac toe app output\" width=\"400\" height=\"867\" \/><\/a><\/p>\n<h3>Summary:<\/h3>\n<p>Congratulations! You have successfully created a Tic-Tac-Toe app using SwiftUI. You have learned how to implement the game logic and user interface and handle win\/draw conditions. You can now run the app and enjoy playing Tic-Tac-Toe. However, this is not the end. You can further enhance the app by adding features such as a scoreboard and different game modes. The possibilities are endless, and you can customize the app according to your needs and creativity.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to this project, where we will build a Tic-Tac-Toe app using SwiftUI. Tic-Tac-Toe is a classic game that involves two players taking turns to mark X or O on a 3&#215;3 grid. The&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":115744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27789],"tags":[27801,27791,27790,27798,27796,27797,27799,27800],"class_list":["post-115405","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-swift-tutorials","tag-swift-project-for-practice","tag-swift-project-ideas","tag-swift-projects","tag-swift-tic-tac-toe-app","tag-swift-tic-tac-toe-game-app","tag-swift-tic-tac-toe-game-app-project","tag-tic-tac-toe-game-app","tag-tic-tac-toe-game-app-project"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Swift Tic Tac Toe App \u2013 Play Anytime, Anywhere! - DataFlair<\/title>\n<meta name=\"description\" content=\"Experience endless fun with Swift Tic Tac Toe! Play against friends or challenge our smart AI. Download now for a thrilling gaming adventure!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Swift Tic Tac Toe App \u2013 Play Anytime, Anywhere! - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Experience endless fun with Swift Tic Tac Toe! Play against friends or challenge our smart AI. Download now for a thrilling gaming adventure!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-27T03:30:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T09:02:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Swift Tic Tac Toe App \u2013 Play Anytime, Anywhere! - DataFlair","description":"Experience endless fun with Swift Tic Tac Toe! Play against friends or challenge our smart AI. Download now for a thrilling gaming adventure!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/","og_locale":"en_US","og_type":"article","og_title":"Swift Tic Tac Toe App \u2013 Play Anytime, Anywhere! - DataFlair","og_description":"Experience endless fun with Swift Tic Tac Toe! Play against friends or challenge our smart AI. Download now for a thrilling gaming adventure!","og_url":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2023-06-27T03:30:56+00:00","article_modified_time":"2026-06-01T09:02:09+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"Swift Tic Tac Toe App \u2013 Play Anytime, Anywhere!","datePublished":"2023-06-27T03:30:56+00:00","dateModified":"2026-06-01T09:02:09+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/"},"wordCount":707,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe.webp","keywords":["swift project for practice","swift project ideas","swift projects","swift tic tac toe app","swift tic tac toe game app","swift tic tac toe game app project","tic tac toe game app","tic tac toe game app project"],"articleSection":["Swift Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/","url":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/","name":"Swift Tic Tac Toe App \u2013 Play Anytime, Anywhere! - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe.webp","datePublished":"2023-06-27T03:30:56+00:00","dateModified":"2026-06-01T09:02:09+00:00","description":"Experience endless fun with Swift Tic Tac Toe! Play against friends or challenge our smart AI. Download now for a thrilling gaming adventure!","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/06\/swift-tic-tac-toe.webp","width":1200,"height":628,"caption":"swift tic tac toe"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/swift-tic-tac-toe-app\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Swift Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/swift-tutorials\/"},{"@type":"ListItem","position":3,"name":"Swift Tic Tac Toe App \u2013 Play Anytime, Anywhere!"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam6\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/115405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=115405"}],"version-history":[{"count":11,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/115405\/revisions"}],"predecessor-version":[{"id":148722,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/115405\/revisions\/148722"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/115744"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=115405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=115405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=115405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}