Skip to content

Commit 1b8f773

Browse files
authored
test: shared sdk lib via xcodegen (#5181)
1 parent 369f7a1 commit 1b8f773

File tree

65 files changed

+417
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+417
-198
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,4 @@ Samples/macOS-SwiftUI/macOS-SwiftUI.xcodeproj
237237
Samples/tvOS-Swift/tvOS-Swift.xcodeproj
238238
Samples/visionOS-Swift/visionOS-Swift.xcodeproj
239239
Samples/watchOS-Swift/watchOS-Swift.xcodeproj
240+
Samples/SentrySampleShared/SentrySampleShared.xcodeproj

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ release-pod:
145145
pod trunk push SentrySwiftUI.podspec
146146

147147
xcode:
148+
xcodegen --spec Samples/SentrySampleShared/SentrySampleShared.yml
148149
xcodegen --spec Samples/SessionReplay-CameraTest/SessionReplay-CameraTest.yml
149150
xcodegen --spec Samples/iOS-ObjectiveC/iOS-ObjectiveC.yml
150151
xcodegen --spec Samples/iOS-Swift/iOS-Swift.yml
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "../Shared/Config/Architectures.xcconfig"
2+
#include "../Shared/Config/BuildOptions.xcconfig"
3+
#include "../Shared/Config/Deployment.xcconfig"
4+
#include "../Shared/Config/Linking.xcconfig"
5+
#include "../Shared/Config/Localization.xcconfig"
6+
#include "../Shared/Config/Packaging.xcconfig"
7+
#include "../Shared/Config/SearchPaths.xcconfig"
8+
#include "../Shared/Config/Signing.xcconfig"
9+
#include "../Shared/Config/Versioning.xcconfig"
10+
#include "../Shared/Config/CodeGeneration.xcconfig"
11+
#include "../Shared/Config/ClangLanguage.xcconfig"
12+
#include "../Shared/Config/ClangCppLanguage.xcconfig"
13+
#include "../Shared/Config/ClangModules.xcconfig"
14+
#include "../Shared/Config/ClangObjCLanguage.xcconfig"
15+
#include "../Shared/Config/ClangPreprocessing.xcconfig"
16+
#include "../Shared/Config/ClangWarnings.xcconfig"
17+
#include "../Shared/Config/ClangWarningsCpp.xcconfig"
18+
#include "../Shared/Config/ClangWarningsObjC.xcconfig"
19+
#include "../Shared/Config/AssetCatalog.xcconfig"
20+
#include "../Shared/Config/ClangAnalyzer.xcconfig"
21+
#include "../Shared/Config/Swift.xcconfig"
22+
#include "../Shared/Config/Metal.xcconfig"
23+
24+
PRODUCT_BUNDLE_IDENTIFIER = io.sentry.SentrySampleShared
25+
INFOPLIST_FILE = SentrySampleShared/Info.plist
26+
SUPPORTED_PLATFORMS = xrsimulator xros watchsimulator watchos macosx iphonesimulator iphoneos driverkit appletvsimulator appletvos
27+
28+
CODE_SIGN_STYLE = Manual
29+
CODE_SIGN_IDENTITY =
30+
CODE_SIGN_IDENTITY[sdk=macosx*] =
31+
PROVISIONING_PROFILE_SPECIFIER =
32+
DEVELOPMENT_TEAM =
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: SentrySampleShared
2+
createIntermediateGroups: true
3+
generateEmptyDirectories: true
4+
configs:
5+
Debug: debug
6+
Test: debug
7+
TestCI: debug
8+
Release: release
9+
projectReferences:
10+
Sentry:
11+
path: ../../Sentry.xcodeproj
12+
fileGroups:
13+
- ../Shared/Config
14+
- SentrySampleShared.yml
15+
options:
16+
bundleIdPrefix: io.sentry
17+
targets:
18+
SentrySampleShared:
19+
type: framework
20+
platform: auto
21+
sources:
22+
- SentrySampleShared
23+
dependencies:
24+
- target: Sentry/Sentry
25+
configFiles:
26+
Debug: SentrySampleShared.xcconfig
27+
Release: SentrySampleShared.xcconfig
28+
Test: SentrySampleShared.xcconfig
29+
TestCI: SentrySampleShared.xcconfig
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#if !os(macOS) && !os(watchOS)
2+
3+
import Foundation
4+
import Sentry
5+
import UIKit
6+
7+
public class AssertView: UIView {
8+
var span: Span?
9+
public var autoHide = true
10+
11+
private var assertLabel: UILabel!
12+
private var errorLabel: UILabel!
13+
14+
var message: String? {
15+
get {
16+
return assertLabel.text
17+
}
18+
set {
19+
assertLabel.text = newValue
20+
setNeedsLayout()
21+
}
22+
}
23+
24+
var errorMessage: String? {
25+
get {
26+
return errorLabel.text
27+
}
28+
set {
29+
errorLabel.text = newValue
30+
setNeedsLayout()
31+
}
32+
}
33+
34+
convenience init() {
35+
self.init(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
36+
}
37+
38+
override init(frame: CGRect) {
39+
super.init(frame: frame)
40+
initialize()
41+
}
42+
43+
required init?(coder: NSCoder) {
44+
super.init(coder: coder)
45+
initialize()
46+
}
47+
48+
private func initialize() {
49+
backgroundColor = UIColor(white: 0.3, alpha: 1)
50+
51+
assertLabel = UILabel().forAutoLayout()
52+
assertLabel.textColor = UIColor(white: 1, alpha: 1)
53+
assertLabel.accessibilityIdentifier = "ASSERT_MESSAGE"
54+
addSubview(assertLabel)
55+
56+
errorLabel = UILabel().forAutoLayout()
57+
errorLabel.textColor = UIColor(white: 1, alpha: 1)
58+
errorLabel.accessibilityIdentifier = "ASSERT_ERROR"
59+
errorLabel.numberOfLines = 0
60+
addSubview(errorLabel)
61+
62+
let guide = self.safeAreaLayoutGuide
63+
64+
let constraints = [
65+
assertLabel.topAnchor.constraint(equalTo: guide.topAnchor, constant: 16),
66+
assertLabel.leftAnchor.constraint(equalTo: guide.leftAnchor, constant: 16),
67+
assertLabel.rightAnchor.constraint(equalTo: guide.rightAnchor, constant: -16),
68+
69+
errorLabel.topAnchor.constraint(equalTo: assertLabel.bottomAnchor, constant: 16),
70+
errorLabel.leftAnchor.constraint(equalTo: guide.leftAnchor, constant: 16),
71+
errorLabel.rightAnchor.constraint(equalTo: guide.rightAnchor, constant: -16),
72+
errorLabel.bottomAnchor.constraint(equalTo: guide.bottomAnchor, constant: 0)
73+
]
74+
NSLayoutConstraint.activate(constraints)
75+
}
76+
77+
public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
78+
//If a tap occurs outside the view, it disappears
79+
let result = super.hitTest(point, with: event)
80+
if result == nil {
81+
close()
82+
}
83+
return result
84+
}
85+
86+
private func close() {
87+
UIAssert.shared.reset()
88+
if autoHide {
89+
removeFromSuperview()
90+
}
91+
}
92+
}
93+
94+
#endif // !os(macOS) && !os(watchOS)

Samples/Shared/DSNStorage.swift renamed to Samples/SentrySampleShared/SentrySampleShared/DSNStorage.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,33 @@ import Sentry
44
/**
55
* Stores the DSN to a file in the cache directory.
66
*/
7-
class DSNStorage {
8-
9-
static let shared = DSNStorage()
10-
7+
public class DSNStorage {
8+
public static let shared = DSNStorage()
119
private let dsnFile: URL
12-
10+
1311
private init() {
1412
// swiftlint:disable force_unwrapping
1513
let cachesDirectory = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
1614
// swiftlint:enable force_unwrapping
1715
dsnFile = cachesDirectory.appendingPathComponent("dsn")
1816
}
19-
20-
func saveDSN(dsn: String) throws {
17+
18+
public func saveDSN(dsn: String) throws {
2119
try deleteDSN()
2220
try dsn.write(to: dsnFile, atomically: true, encoding: .utf8)
2321
}
24-
25-
func getDSN() throws -> String? {
22+
23+
public func getDSN() throws -> String? {
2624
let fileManager = FileManager.default
27-
25+
2826
guard fileManager.fileExists(atPath: dsnFile.path) else {
2927
return nil
3028
}
31-
29+
3230
return try String(contentsOfFile: dsnFile.path)
3331
}
34-
35-
func deleteDSN() throws {
32+
33+
public func deleteDSN() throws {
3634
let fileManager = FileManager.default
3735
if fileManager.fileExists(atPath: dsnFile.path) {
3836
try fileManager.removeItem(at: dsnFile)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Foundation
2+
import Sentry
3+
4+
extension Bundle {
5+
var gitCommitHash: String? {
6+
infoDictionary?["GIT_COMMIT_HASH"] as? String
7+
}
8+
var gitBranchName: String? {
9+
infoDictionary?["GIT_BRANCH"] as? String
10+
}
11+
var gitStatusClean: Bool {
12+
(infoDictionary?["GIT_STATUS_CLEAN"] as? String) == "1"
13+
}
14+
}
15+
16+
public func injectGitInformation(scope: Scope) {
17+
if let commitHash = Bundle.main.gitCommitHash {
18+
scope.setTag(value: "\(commitHash)\(Bundle.main.gitStatusClean ? "" : "-dirty")", key: "git-commit-hash")
19+
}
20+
if let branchName = Bundle.main.gitBranchName {
21+
scope.setTag(value: branchName, key: "git-branch-name")
22+
}
23+
}
24+
25+
public class GitInjector: NSObject {
26+
@objc public static func objc_injectGitInformation(into scope: Scope) {
27+
injectGitInformation(scope: scope)
28+
}
29+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>$(MARKETING_VERSION)</string>
19+
<key>CFBundleVersion</key>
20+
<string>$(CURRENT_PROJECT_VERSION)</string>
21+
<key>NSHumanReadableCopyright</key>
22+
<string></string>
23+
</dict>
24+
</plist>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Foundation
2+
3+
public class BundleResourceProvider: NSObject {
4+
public static var loremIpsumTextFilePath: String? {
5+
Bundle(for: self).path(forResource: "LoremIpsum", ofType: "txt")
6+
}
7+
8+
@objc public static var screenshotURL: URL? {
9+
Bundle(for: self).url(forResource: "screenshot", withExtension: "png")
10+
}
11+
}

0 commit comments

Comments
 (0)