First of all, thank you for considering contributing to InsForge Swift SDK! It's people like you that make InsForge a great tool.
By participating in this project, you agree to abide by our code of conduct. Please be kind and respectful to others.
If you find a bug, please report it by following these steps:
- Check if it already exists: Search GitHub Issues to ensure the issue hasn't been reported yet
- Create a detailed Issue: Use the Bug Report template, including:
- Clear title and description
- Steps to reproduce
- Expected behavior vs actual behavior
- Environment information (iOS/macOS version, Swift version, SDK version)
- Code sample (if possible)
- Screenshots or logs (if applicable)
We welcome new feature suggestions!
- Check the roadmap: See if it's already planned
- Create a Feature Request: Use the template to explain:
- Use case for the feature
- Why this feature would be useful
- Possible implementation approach
- Whether you're willing to implement it
# 1. Fork the repository
# Click the "Fork" button on GitHub
# 2. Clone your fork
git clone https://github.com/YOUR_USERNAME/insforge-swift.git
cd insforge-swift
# 3. Add upstream repository
git remote add upstream https://github.com/InsForge/insforge-swift.git
# 4. Create development branch
git checkout -b feature/my-awesome-feature
# 5. Install dependencies
swift package resolve
# 6. Build project
swift build
# 7. Run tests
swift test-
Create a Branch
Use descriptive branch names:
feature/add-batch-operations- New featuresfix/auth-token-refresh- Bug fixesdocs/improve-readme- Documentation updatesrefactor/database-client- Code refactoring
-
Write Code
Follow project conventions:
- Use Swift API Design Guidelines
- Maintain consistent code style
- Add appropriate comments
- Use meaningful variable and function names
-
Add Tests
import XCTest @testable import InsForge final class MyFeatureTests: XCTestCase { func testMyFeature() async throws { // Arrange let client = InsForgeClient(/* ... */) // Act let result = try await client.myFeature() // Assert XCTAssertEqual(result, expectedValue) } }
-
Run Tests
# Run all tests swift test # Run specific tests swift test --filter MyFeatureTests # With verbose output swift test -v
-
Commit Code
Use clear commit messages:
type: short description (no more than 50 characters) Detailed explanation of why this change was made, not how. Include relevant issue numbers. Closes #123Commit types:
feat:New featurefix:Bug fixdocs:Documentation updatestyle:Formatting (doesn't affect code meaning)refactor:Refactoring (neither fixes bugs nor adds features)test:Adding testschore:Build process or auxiliary tool changesperf:Performance optimization
Example:
feat: add batch insert operation to database client Implements batch insert functionality to reduce network overhead when inserting multiple records at once. Closes #45 -
Push Code
git push origin feature/my-awesome-feature
-
Create Pull Request
Create a PR on GitHub:
- Clear title
- Detailed description of changes
- Link related issues
- Ensure CI passes
- Request review
Before submitting a PR, ensure:
- Code follows project style guide
- All tests pass
- Added tests for new features
- Updated relevant documentation
- Updated CHANGELOG.md
- Commit messages are clear
- No compilation warnings
- Passed SwiftLint checks
Documentation is equally important! You can:
- Fix spelling or grammar errors
- Improve existing documentation
- Add code examples
- Translate documentation
- Create tutorials or guides
Documentation locations:
README.md- Project homepagedocs/GETTING_STARTED.md- Getting started guidedocs/PUBLISHING.md- Publishing guide- Code comments - DocC documentation
// ✅ Good
public actor MyClient {
private let url: URL
public init(url: URL) {
self.url = url
}
public func doSomething() async throws -> Result {
// Implementation
}
}
// ❌ Bad
public actor myClient {
var Url: URL
func DoSomething() throws -> Result {
// Implementation
}
}- Type names: PascalCase (
InsForgeClient,AuthClient) - Variables/Functions: camelCase (
signIn,getCurrentUser) - Constants: camelCase (
maxRetryCount,defaultTimeout) - Protocols: Nouns or adjectives (
AuthStorage,Sendable)
// ✅ Use typed errors
public enum MyError: Error {
case invalidInput
case networkFailure(Error)
}
throw MyError.invalidInput
// ❌ Avoid generic errors
throw NSError(domain: "MyDomain", code: -1)// ✅ Use async/await
public func fetchData() async throws -> Data {
try await httpClient.execute(.get, url: url)
}
// ✅ Use actor to protect state
public actor StateManager {
private var state: State
public func update(_ newState: State) {
state = newState
}
}
// ❌ Avoid callbacks
public func fetchData(completion: @escaping (Result<Data, Error>) -> Void) {
// Don't do this
}// ✅ Use descriptive test names
func testSignInWithValidCredentialsSucceeds() async throws {
// Test implementation
}
// ✅ Use Arrange-Act-Assert pattern
func testExample() async throws {
// Arrange
let client = makeTestClient()
// Act
let result = try await client.doSomething()
// Assert
XCTAssertEqual(result, expectedValue)
}
// ✅ Test error cases
func testSignInWithInvalidCredentialsThrowsError() async throws {
let client = makeTestClient()
await XCTAssertThrowsError(
try await client.signIn(email: "bad", password: "bad")
) { error in
XCTAssertTrue(error is InsForgeError)
}
}The project uses SwiftLint to maintain code quality.
Installation:
brew install swiftlintRun checks:
swiftlintAuto-fix:
swiftlint --fixOnly maintainers can release new versions:
- Update
CHANGELOG.md - Update version number in
Sources/InsForge/InsForgeClient.swift - Create PR and merge
- Create tag:
git tag -a 1.0.1 -m "Release 1.0.1" - Push tag:
git push origin 1.0.1 - Create Release on GitHub
If you have questions:
- Check the documentation
- Search existing Issues
- Ask in Discussions
- Join the Discord community
Thanks to all contributors! Your efforts make InsForge better.
By contributing, you agree that your contributions will be licensed under the MIT License.