-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add iOS and macOS samples with Tuist * Add headers * Close macOS app on last window closed * Add tvOS, watchOS and visionOS * Workaround crash on sendAllReports * Make more clean default UI * Fix SPM syntax * Simplify the setup * Use a single target for sample * Add build rule * Fix build action * Fix step name * Add Package.swift as builds trigger
- Loading branch information
Showing
11 changed files
with
444 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Build Sample | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'Sources/**/include/**' | ||
- 'Package.swift' | ||
- 'Samples/**' | ||
- '.github/workflows/build-sample.yml' | ||
|
||
push: | ||
branches: | ||
- master | ||
|
||
schedule: | ||
- cron: '0 0 1 * *' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
sample: | ||
runs-on: macos-latest | ||
timeout-minutes: 15 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- platform: iOS | ||
- platform: macOS | ||
- platform: tvOS | ||
- platform: watchOS | ||
- platform: visionOS | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use Latest Stable Xcode | ||
uses: maxim-lobanov/setup-xcode@v1 | ||
with: | ||
xcode-version: latest-stable | ||
|
||
- name: Install visionOS Platform | ||
if: matrix.platform == 'visionOS' | ||
shell: bash | ||
run: | | ||
# See https://github.com/actions/runner-images/issues/8144#issuecomment-1902072070 | ||
defaults write com.apple.dt.Xcode AllowUnsupportedVisionOSHost -bool YES | ||
defaults write com.apple.CoreSimulator AllowUnsupportedVisionOSHost -bool YES | ||
xcodebuild -downloadPlatform visionOS | ||
- name: Install Tuist | ||
run: | | ||
brew tap tuist/tuist | ||
brew install tuist@4.18.0 | ||
- name: Generate Project | ||
working-directory: ./Samples | ||
run: tuist generate --verbose --no-open | ||
|
||
- name: Run Build | ||
uses: bamx23/xcodebuild@os-version | ||
timeout-minutes: 10 | ||
with: | ||
action: build | ||
workspace: "Samples/KSCrashSamples.xcworkspace" | ||
scheme: "Sample" | ||
platform: ${{ matrix.platform }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// swift-tools-version:5.3 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "KSCrashSamplesCommon", | ||
platforms: [ | ||
.iOS(.v14), | ||
.tvOS(.v14), | ||
.watchOS(.v7), | ||
.macOS(.v11), | ||
], | ||
products: [ | ||
.library( | ||
name: "LibraryBridge", | ||
targets: ["LibraryBridge"] | ||
), | ||
.library( | ||
name: "CrashTriggers", | ||
targets: ["CrashTriggers"] | ||
), | ||
.library( | ||
name: "SampleUI", | ||
targets: ["SampleUI"] | ||
), | ||
], | ||
dependencies: [ | ||
.package(path: "../.."), | ||
], | ||
targets: [ | ||
.target( | ||
name: "LibraryBridge", | ||
dependencies: [ | ||
.product(name: "Recording", package: "KSCrash"), | ||
.product(name: "Reporting", package: "KSCrash"), | ||
] | ||
), | ||
.target( | ||
name: "CrashTriggers" | ||
), | ||
.target( | ||
name: "SampleUI", | ||
dependencies: [ | ||
.target(name: "LibraryBridge"), | ||
.target(name: "CrashTriggers"), | ||
] | ||
) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// CrashTriggers.mm | ||
// | ||
// Created by Nikolay Volosatov on 2024-06-23. | ||
// | ||
// Copyright (c) 2012 Karl Stenerud. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall remain in place | ||
// in this source code. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
#import "CrashTriggers.h" | ||
|
||
@implementation CrashTriggers | ||
|
||
+ (void)nsexception | ||
{ | ||
NSException *exc = [NSException exceptionWithName:NSGenericException | ||
reason:@"Test" | ||
userInfo:@{ @"a": @"b"}]; | ||
[exc raise]; | ||
} | ||
|
||
@end |
33 changes: 33 additions & 0 deletions
33
Samples/Common/Sources/CrashTriggers/include/CrashTriggers.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// CrashTriggers.h | ||
// | ||
// Created by Nikolay Volosatov on 2024-06-23. | ||
// | ||
// Copyright (c) 2012 Karl Stenerud. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall remain in place | ||
// in this source code. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface CrashTriggers : NSObject | ||
|
||
+ (void)nsexception; | ||
|
||
@end |
35 changes: 35 additions & 0 deletions
35
Samples/Common/Sources/LibraryBridge/RecordingSample.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// RecordingSample.swift | ||
// | ||
// Created by Nikolay Volosatov on 2024-06-23. | ||
// | ||
// Copyright (c) 2012 Karl Stenerud. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall remain in place | ||
// in this source code. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
import Foundation | ||
import KSCrashRecording | ||
|
||
public class RecordingSample { | ||
public static func simpleInstall() { | ||
let config = KSCrashConfiguration() | ||
KSCrash.shared().install(with: config) | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Samples/Common/Sources/LibraryBridge/ReportingSample.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// ReportingSample.swift | ||
// | ||
// Created by Nikolay Volosatov on 2024-06-23. | ||
// | ||
// Copyright (c) 2012 Karl Stenerud. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall remain in place | ||
// in this source code. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
import Foundation | ||
import KSCrashRecording | ||
import KSCrashFilters | ||
import KSCrashSinks | ||
|
||
public class ReportingSample { | ||
public static func logToConsole() { | ||
KSCrash.shared().sink = CrashReportSinkConsole.filter().defaultCrashReportFilterSet() | ||
KSCrash.shared().sendAllReports() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// SampleView.swift | ||
// | ||
// Created by Nikolay Volosatov on 2024-06-23. | ||
// | ||
// Copyright (c) 2012 Karl Stenerud. All rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall remain in place | ||
// in this source code. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
|
||
import SwiftUI | ||
import LibraryBridge | ||
import CrashTriggers | ||
|
||
public struct SampleView: View { | ||
public init() { } | ||
|
||
public var body: some View { | ||
NavigationView { | ||
List { | ||
Section(header: Text("Crashes")) { | ||
Button("NSException") { | ||
CrashTriggers.nsexception() | ||
} | ||
} | ||
Section(header: Text("Reporting")) { | ||
Button("Log To Console") { | ||
ReportingSample.logToConsole() | ||
} | ||
} | ||
} | ||
.navigationTitle("KSCrash Sample") | ||
} | ||
.onAppear { | ||
RecordingSample.simpleInstall() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import ProjectDescription | ||
|
||
let project = Project( | ||
name: "KSCrashSamples", | ||
packages: [ | ||
.local(path: "Common"), | ||
], | ||
targets: [ | ||
.target( | ||
name: "Sample", | ||
destinations: .allForSample, | ||
product: .app, | ||
bundleId: "com.github.kstenerud.KSCrash.Sample", | ||
infoPlist: InfoPlist.extendingDefault(with: [ | ||
"UILaunchScreen": [ | ||
"UIImageName": "LaunchImage", | ||
"UIBackgroundColor": "LaunchScreenColor", | ||
], | ||
"UISupportedInterfaceOrientations": ["UIInterfaceOrientationPortrait"], | ||
"CFBundleDisplayName": "KSCrashSample", | ||
"WKApplication": true, | ||
"WKWatchOnly": true, | ||
]), | ||
sources: ["Sources/**"], | ||
dependencies: [ | ||
.package(product: "SampleUI", type: .runtime), | ||
] | ||
), | ||
] | ||
) | ||
|
||
extension Set where Element == ProjectDescription.Destination { | ||
static var allForSample: Self { | ||
let sets: [Set<Destination>] = [ | ||
.iOS, | ||
.macOS, | ||
.tvOS, | ||
.watchOS, | ||
.visionOS, | ||
] | ||
return sets.reduce(.init()) { $0.union($1) } | ||
} | ||
} |
Oops, something went wrong.