Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This repository contains Smart Mobile Factory's common project setup files for iOS development. It provides reusable components, scripts, and configurations that are shared across multiple iOS projects and frameworks through git submodules.

## Architecture

The repository is organized into several functional directories:

### SDK Helper Wrappers
- **LifetimeTracker/**: Memory leak detection helpers with base view controllers (wraps https://github.com/krzysztofzablocki/LifetimeTracker)

### Development Tools
- **SwiftLint/**: SwiftLint v0.59.1 configurations and execution scripts with portable binary
- **Xcode/**: Xcode version checking utilities

### Utilities
- **Plist2swift/**: Swift Package Manager tool that generates Swift code from plist files
- **Git/**: Git merge drivers and upmerge scripts for framework development
- **Strato/**: License management utilities

## Common Development Commands

### Main Setup Script
```bash
# For apps
"${SRCROOT}/Submodules/SMF-iOS-CommonProjectSetupFiles/setup-common-project-files.sh" --targettype "${PRODUCT_TYPE}"

# For SwiftUI apps
"${SRCROOT}/Submodules/SMF-iOS-CommonProjectSetupFiles/setup-common-project-files.sh" --targettype "${PRODUCT_TYPE}" --SwiftUI

# For framework unit tests
"${SRCROOT}/Submodules/SMF-iOS-CommonProjectSetupFiles/setup-common-project-files.sh" --targettype "com.apple.product-type.framework"
```

### Individual Tool Commands
```bash
# SwiftLint only
./SwiftLint/copy-and-run-swiftlint-config.sh

# Xcode version check
./Xcode/check-xcode-version.swift

# Plist2Swift code generation
./Plist2swift/Plist2swift -e EnumName -o output.swift input1.plist input2.plist
```

### Testing Plist2swift
```bash
cd Plist2swift
swift test
```

## Setup Integration

The main setup script handles:
- Copying and merging SwiftLint configurations (`.swiftlint.yml` and `.project-swiftlint.yml`)
- Running SwiftLint with portable binary or system installation
- Copying GitHub PR templates based on project type
- Optional Xcode version validation

## Key Configuration Files

- **swiftlint.yml**: Base SwiftLint v0.59.1 configuration
- **swiftlint+frameworks.yml**: Additional rules for frameworks
- **swiftlint+swiftUI.yml**: SwiftUI-specific rules
- **project-swiftlint.yml**: Template for project-specific excluded paths

## SDK Integration Pattern

The LifetimeTracker SDK helper follows this pattern:
1. Provides base view controllers that integrate with LifetimeTracker when available
2. Uses conditional compilation (`#if canImport(LifetimeTracker)`) to support projects with or without the dependency
3. Offers simple setup methods with sensible defaults
4. Handles debug vs release build configurations

## File Generation

- `.swiftlint.yml` is automatically copied to project root
- Add this file to `.gitignore` as it is generated
- Project-specific configurations use `.project-swiftlint.yml` template

## Framework Development

For framework projects:
- Unit test targets get separate SwiftLint configuration
- Special PR templates are used for breaking changes
- Git merge drivers help with version management during upmerges
49 changes: 0 additions & 49 deletions DrString/copy-and-run-DrString-config.sh

This file was deleted.

Binary file removed DrString/drstring
Binary file not shown.
7 changes: 0 additions & 7 deletions DrString/drstring.toml

This file was deleted.

112 changes: 3 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
# SMF-iOS-CommonProjectSetupFiles

[![Language: Swift 5.3](https://img.shields.io/badge/Swift-5.2-orange.svg)](https://swift.org)
[![Xcode: Xcode 11.7](https://img.shields.io/badge/Xcode-11.7-orange.svg)](https://developer.apple.com/xcode)
[![Language: Swift 5.3](https://img.shields.io/badge/Swift-5.9-orange.svg)](https://swift.org)
[![Xcode: Xcode 15](https://img.shields.io/badge/Xcode-15-orange.svg)](https://developer.apple.com/xcode)

This Repo contains our common project setup files.

Helpers which can be added manually to the Xcode project which should be used:

- [HockeySDK.swift](#hockeyapp-sdk)
- [SentrySDK.swift](#sentry-sdk)
- [BuglifeSDK.swift](#buglife-sdk)
- [LifetimeTrackerSDK](#lifetimetracker-sdk)

Scripts which should be called during the build phase:

- [SwiftLint](#swiftlint)
- [DrSwift](#drswift)
- [Xcode version check](#xcode-version-check)

### Setup
Expand Down Expand Up @@ -52,100 +48,7 @@ If you want to add more parameters, eg. to disable SwiftLint, you have to add th

## Helper classes

### HockeyApp-SDK

This repo contains the `HockeySDK` helper struct which takes care of the default HockeyApp SDK setup. The SDK will be initialized with the App ID and the Crash Manager started.

### Sentry-SDK

This repo contains the `SentrySKD` (plus the SMFLogger variant) helper struct which takes care of the default Sentry SDK setup. The SDK will be initialized with the Sentry DSN (in the info.plist).

#### Integrate the HockeyApp SDK
To use the HockeySDK.swift helper struct you have to manually add the HockeyApp SDK to your project first. Use the preferred way to do this - at this time it's [CocoaPods](https://cocoapods.org).

#### Add the HockeyApp App ID to the info plists
The helper struct will automatically read the App IDs from the info plists. It's mandatory to add these with the key `HockeyAppId` to all info plists in the project:

```
<key>HockeyAppId</key>
<string>ABCDE...</string>
```

#### Add the HockeySDK.swift file to the project

Once the SDK is properly integrated and the App IDs set you have to add the `HockeySDK.swift` file to the Xcode project:

```
Project navigator > Submodules > Add files to "SMF-iOS-CommonProjectSetupFiles" > Choose the folder "HockeyApp"
```

#### Use the HockeySDK.swift helper struct

If all former steps are completed you can call the `HockeySDK.setup()` method during the `applicationDidFinishLaunching(_:)` in the app delegate:

```
func applicationDidFinishLaunching(_ application: UIApplication) {
HockeySDK.setup()
}
```

#### Customiztion

If you want to use a diferent `BITCrashManagerStatus` (the default is `.autoSend`) or want to enable crash reports also for debug builds you can send these as optional parameters:

```
HockeySDK.setup(withStatus: .alwaysAsk, configureHockeyAppAlsoForDebugBuildTypes: true)
```

#### Perform a test crash

If you want to test if crash reports are working you can perform a test crash. This will trigger a `fatalError()`. Note: If you didn't set `configureHockeyAppAlsoForDebugBuildTypes` to `true` you have to build the app as release app in order to capture crashes!

```
HockeySDK.performTestCrash()
```


### Buglife-SDK

This repo contains the `BuglifeSDK` helper struct which takes care of the default Buglife SDK setup with `Shake` as default invocation option to trigger the Buglife view controller.

#### Integrate the Buglife SDK
To use the BuglifeSDK.swift helper struct you have to manually add the Buglife SDK to your project first. Use the preferred way to do this - at this time it's [CocoaPods](https://cocoapods.org).

#### Add the Buglife ID to the info plists
The helper struct will automatically read the IDs from the info plists. It's mandatory to add these with the key `BuglifeId` to all info plists in the project:

```
<key>BuglifeId</key>
<string>ABCDE...</string>
```

#### Add the BuglifeSDK.swift file to the project

Once the SDK is properly integrated and the Buglife ID set you have to add the `BuglifeSDK .swift` file to the Xcode project:

```
Project navigator > Submodules > Add files to "SMF-iOS-CommonProjectSetupFiles" > Choose the folder "Buglife"
```

#### Use the BuglifeSDK.swift helper struct

If all former steps are completed you can call the `BuglifeSDK.setup()` method during the `applicationDidFinishLaunching (_:)` in the app delegate:

```
func applicationDidFinishLaunching(_ application: UIApplication) {
BuglifeSDK.setup()
}
```

#### Customiztion

If you want to use a diferent `LIFEInvocationOptions` (the default is `.shake`) you can send it as optional parameter:

```
BuglifeSDK.setup(withOption: .screenshot)
```

### LifetimeTracker-SDK

Expand All @@ -165,7 +68,7 @@ Multiple `#if canImport(LifetimeTracker)` checks make sure that targets with Lif

### SwiftLint

Swiftlint is integrated in SMF-iOS-CommonProjectSetupFiles itself. The current version is 0.28.1.
SwiftLint is integrated in SMF-iOS-CommonProjectSetupFiles itself. The current version is 0.59.1.

#### Integrate it into the project

Expand All @@ -187,15 +90,6 @@ excluded:
##### Optional: Call the SwiftLint script without using the setup script
If you want to copy the SwiftLint configuration and lint the code without integrating the setup script you can call `Submodules/SMF-iOS-CommonProjectSetupFiles/SwiftLint/copy-and-run-swiftlint-config.sh` directly.

### DrSwift

[DrSwift](https://github.com/dduan/DrString) is integrated in SMF-iOS-CommonProjectSetupFiles itself. The current version is 0.4.2.

#### Integrate it into the project

DrString is configured to run when you execute `Submodules/SMF-iOS-CommonProjectSetupFiles/setup-common-project-files.sh` with [framework target configuration](#setup) parameters.

**Make sure that `/.drstring.toml` is added to the gitignore file as the DrSwift configuration file be automatically copied from the repo into the projects base folder.**

### Xcode version check

Expand Down
Binary file modified SwiftLint/portable_swiftlint/swiftlint
Binary file not shown.
3 changes: 0 additions & 3 deletions setup-common-project-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ if [ $callSwiftlint = true ]; then
./SwiftLint/copy-and-run-swiftlint-config.sh "$projectDir" $isFramework $isSwiftUIProject || exit 1;
fi

if [ $isFramework = true ]; then
./DrString/copy-and-run-DrString-config.sh "$projectDir" || exit 1;
fi

if [ $copyPRTemplate = true ]; then

Expand Down