Skip to content

Commit 4d6ed82

Browse files
Modernize Swift UI (SpriteKit) repository (#3)
* Initial plan for issue * Update CI workflow and add DevContainer support Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com> * Add GitHub repository config files Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com> * Enhance repository documentation and add SwiftLint config Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com> * Fix xcodebuild command formatting in CI workflow Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com> * Fix Xcode project path detection and scheme names in CI workflow Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com> * Fix iOS simulator specification in CI workflow Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com> * Fix iOS simulator destination in CI workflow to use generic device identifier Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com> * Use My Mac destination for iOS builds in CI workflow Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com> * Simplify CI workflow destination specifications Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: KevinTCoughlin <706967+KevinTCoughlin@users.noreply.github.com>
1 parent 687af97 commit 4d6ed82

File tree

11 files changed

+370
-15
lines changed

11 files changed

+370
-15
lines changed

.devcontainer/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM swift:5.9-jammy
2+
3+
# Install necessary dependencies
4+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5+
&& apt-get -y install git curl libgd3 libpng16-16 libxkbcommon0 libxkbcommon-x11-0 \
6+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
7+
8+
# Create non-root user
9+
ARG USERNAME=vscode
10+
ARG USER_UID=1000
11+
ARG USER_GID=$USER_UID
12+
13+
RUN groupadd --gid $USER_GID $USERNAME \
14+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
15+
&& apt-get update \
16+
&& apt-get install -y sudo \
17+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
18+
&& chmod 0440 /etc/sudoers.d/$USERNAME
19+
20+
# Set up Swift environment
21+
RUN echo "export PATH=/usr/bin:$PATH" >> /home/$USERNAME/.bashrc \
22+
&& echo "export LANG=en_US.UTF-8" >> /home/$USERNAME/.bashrc
23+
24+
# Install SwiftLint (optional)
25+
RUN git clone https://github.com/realm/SwiftLint.git \
26+
&& cd SwiftLint \
27+
&& swift build -c release \
28+
&& mv .build/release/swiftlint /usr/local/bin/ \
29+
&& cd .. \
30+
&& rm -rf SwiftLint
31+
32+
# Switch to non-root user
33+
USER $USERNAME

.devcontainer/devcontainer.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "Swift Development",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {},
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"sswg.swift-lang",
11+
"vadimcn.vscode-lldb",
12+
"eamodio.gitlens",
13+
"ms-azuretools.vscode-docker"
14+
],
15+
"settings": {
16+
"lldb.library": "/usr/lib/liblldb.so",
17+
"swift.path.swift_driver_bin": "/usr/bin/swift",
18+
"editor.formatOnSave": true,
19+
"editor.rulers": [
20+
100
21+
]
22+
}
23+
}
24+
},
25+
"remoteUser": "vscode",
26+
"postCreateCommand": "swift --version"
27+
}

.github/CODEOWNERS

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This is a CODEOWNERS file to define individuals or teams responsible for code in this repository
2+
# Each line is a file pattern followed by one or more owners
3+
4+
# These owners will be the default owners for everything in the repo
5+
* @KevinTCoughlin
6+
7+
# Swift files in the shared directory
8+
/tictactoe\ Shared/ @KevinTCoughlin
9+
10+
# iOS specific files
11+
/tictactoe\ iOS/ @KevinTCoughlin
12+
13+
# macOS specific files
14+
/tictactoe\ macOS/ @KevinTCoughlin
15+
16+
# Tests
17+
/TicTacToeTests/ @KevinTCoughlin
18+
19+
# GitHub specific files
20+
/.github/ @KevinTCoughlin

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: '[BUG] '
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Tap on '....'
17+
3. See error
18+
19+
**Expected behavior**
20+
A clear and concise description of what you expected to happen.
21+
22+
**Screenshots**
23+
If applicable, add screenshots to help explain your problem.
24+
25+
**Environment (please complete the following information):**
26+
- Device: [e.g. iPhone 15, MacBook Pro]
27+
- OS: [e.g. iOS 17.5, macOS 14.4]
28+
- App Version: [e.g. 1.0.0]
29+
30+
**Additional context**
31+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: '[FEATURE] '
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Description
2+
<!--- Describe your changes in detail -->
3+
4+
## Motivation and Context
5+
<!--- Why is this change required? What problem does it solve? -->
6+
<!--- If it fixes an open issue, please link to the issue here. -->
7+
Fixes # (issue)
8+
9+
## How Has This Been Tested?
10+
<!--- Please describe in detail how you tested your changes. -->
11+
<!--- Include details of your testing environment, and the tests you ran to -->
12+
<!--- see how your change affects other areas of the code, etc. -->
13+
14+
## Screenshots (if appropriate):
15+
16+
## Types of changes
17+
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
18+
- [ ] Bug fix (non-breaking change which fixes an issue)
19+
- [ ] New feature (non-breaking change which adds functionality)
20+
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
21+
22+
## Checklist:
23+
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
24+
<!--- If you're unsure about any of these, don't hesitate to ask. -->
25+
- [ ] My code follows the code style of this project.
26+
- [ ] My change requires a change to the documentation.
27+
- [ ] I have updated the documentation accordingly.
28+
- [ ] I have added tests to cover my changes.
29+
- [ ] All new and existing tests passed.

.github/workflows/xcode.yml

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Xcode - Build and Analyze
1+
name: Xcode - Build and Test
22

33
on:
44
push:
@@ -8,29 +8,35 @@ on:
88

99
jobs:
1010
build:
11-
name: Build and analyze default scheme using xcodebuild
12-
runs-on: macos-15
11+
name: Build and test using xcodebuild
12+
runs-on: macos-latest
1313

1414
steps:
1515
- name: Checkout repository
1616
uses: actions/checkout@v4
1717

18+
- name: Set up Xcode
19+
uses: maxim-lobanov/setup-xcode@v1
20+
with:
21+
xcode-version: latest-stable
22+
1823
- name: Determine Default Scheme
1924
run: |
2025
# Get the default scheme from the target list
21-
scheme=$(xcodebuild -list -json | jq -r '.project.targets[0]')
22-
echo "Default scheme detected: $scheme"
23-
echo "scheme=$scheme" >> $GITHUB_ENV
26+
scheme_ios="tictactoe iOS"
27+
scheme_macos="tictactoe macOS"
28+
echo "scheme_ios=$scheme_ios" >> $GITHUB_ENV
29+
echo "scheme_macos=$scheme_macos" >> $GITHUB_ENV
2430
2531
- name: Identify Xcode Project or Workspace
2632
run: |
2733
# Check if workspace or project exists, and set the build target
28-
if [[ -n "$(ls *.xcworkspace 2>/dev/null)" ]]; then
34+
if [[ -n "$(find . -maxdepth 1 -name "*.xcworkspace" 2>/dev/null)" ]]; then
2935
filetype="workspace"
30-
file_to_build=$(ls *.xcworkspace | head -n 1)
31-
elif [[ -n "$(ls *.xcodeproj 2>/dev/null)" ]]; then
36+
file_to_build=$(find . -maxdepth 1 -name "*.xcworkspace" | head -n 1 | sed 's/^\.\///')
37+
elif [[ -n "$(find . -maxdepth 1 -name "*.xcodeproj" 2>/dev/null)" ]]; then
3238
filetype="project"
33-
file_to_build=$(ls *.xcodeproj | head -n 1)
39+
file_to_build=$(find . -maxdepth 1 -name "*.xcodeproj" | head -n 1 | sed 's/^\.\///')
3440
else
3541
echo "No .xcworkspace or .xcodeproj found." >&2
3642
exit 1
@@ -39,11 +45,39 @@ jobs:
3945
echo "filetype=$filetype" >> $GITHUB_ENV
4046
echo "file_to_build=$file_to_build" >> $GITHUB_ENV
4147
42-
- name: Build and Analyze
48+
- name: List available destinations
49+
env:
50+
scheme: ${{ env.scheme_ios }}
51+
filetype: ${{ env.filetype }}
52+
file_to_build: ${{ env.file_to_build }}
53+
run: |
54+
# List available destinations for debugging
55+
echo "Available destinations:"
56+
xcodebuild -scheme "$scheme" -$filetype "$file_to_build" -showdestinations
57+
58+
- name: Build for iOS
59+
env:
60+
scheme: ${{ env.scheme_ios }}
61+
filetype: ${{ env.filetype }}
62+
file_to_build: ${{ env.file_to_build }}
63+
run: |
64+
# Clean and build the iOS target
65+
xcodebuild clean build -scheme "$scheme" -$filetype "$file_to_build" -destination "platform=macOS" | xcpretty && exit ${PIPESTATUS[0]}
66+
67+
- name: Test
68+
env:
69+
scheme: ${{ env.scheme_ios }}
70+
filetype: ${{ env.filetype }}
71+
file_to_build: ${{ env.file_to_build }}
72+
run: |
73+
# Run tests
74+
xcodebuild test -scheme "$scheme" -$filetype "$file_to_build" -destination "platform=macOS" -testPlan "tictactoeTests" | xcpretty && exit ${PIPESTATUS[0]}
75+
76+
- name: Build for macOS
4377
env:
44-
scheme: ${{ env.scheme }}
78+
scheme: ${{ env.scheme_macos }}
4579
filetype: ${{ env.filetype }}
4680
file_to_build: ${{ env.file_to_build }}
4781
run: |
48-
# Clean, build, and analyze the project
49-
xcodebuild clean build analyze -scheme "$scheme" -"$filetype" "$file_to_build" | xcpretty && exit ${PIPESTATUS[0]}
82+
# Build the macOS target
83+
xcodebuild clean build -scheme "$scheme" -$filetype "$file_to_build" -destination "platform=macOS" | xcpretty && exit ${PIPESTATUS[0]}

.swiftlint.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
excluded:
2+
- .build
3+
- Carthage
4+
- Pods
5+
- fastlane
6+
- vendor
7+
8+
disabled_rules:
9+
- trailing_whitespace
10+
- line_length
11+
- identifier_name
12+
13+
opt_in_rules:
14+
- empty_count
15+
- empty_string
16+
- fatal_error_message
17+
- force_unwrapping
18+
- implicitly_unwrapped_optional
19+
- legacy_random
20+
- multiline_arguments
21+
- multiline_parameters
22+
- sorted_first_last
23+
- vertical_parameter_alignment_on_call
24+
25+
cyclomatic_complexity:
26+
warning: 15
27+
28+
function_body_length:
29+
warning: 50
30+
error: 100
31+
32+
type_body_length:
33+
warning: 300
34+
error: 500

CONTRIBUTING.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Contributing to SK-Tic-Tac-Toe
2+
3+
Thank you for considering contributing to this project! Here are some guidelines to help you get started.
4+
5+
## Development Environment
6+
7+
This project uses Swift and SpriteKit for iOS and macOS.
8+
9+
### Prerequisites
10+
- Xcode 15.0 or higher
11+
- Swift 5.9 or higher
12+
- macOS 13.0 or higher
13+
14+
### Development Environment Setup
15+
1. Clone the repository
16+
2. Open `tictactoe.xcodeproj` in Xcode
17+
3. Build and run the project
18+
19+
Alternatively, you can use VS Code with our provided DevContainer configuration:
20+
1. Install VS Code and the DevContainer extension
21+
2. Open the repository in VS Code
22+
3. When prompted, choose "Reopen in Container"
23+
24+
## Pull Request Process
25+
26+
1. Fork the repository
27+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
28+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
29+
4. Push to the branch (`git push origin feature/amazing-feature`)
30+
5. Open a Pull Request
31+
32+
### Code Style Guidelines
33+
34+
- Follow Swift's API Design Guidelines
35+
- Use Swift's standard library types where applicable
36+
- Write meaningful commit messages
37+
- Include tests for new features
38+
39+
## Testing
40+
41+
Make sure to run tests before submitting your PR:
42+
- Use the test plan to run all tests
43+
- Fix any issues that arise
44+
45+
## License
46+
47+
By contributing to this project, you agree that your contributions will be licensed under the project's license.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Kevin T. Coughlin and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)