-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates README.md #52
Conversation
nikz
commented
May 15, 2024
- Adds more detail around SwiftUI and App Delegates
- Clarifies SPM instructions
- Adds example for user information in Swift
* Adds more detail around SwiftUI and App Delegates * Clarifies SPM instructions * Adds example for user information in Swift
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes LGTM! Just want to test before approving. Nice work 💯
|
||
```bash | ||
pod 'raygun4apple' | ||
You likely want to start Raygun in your `AppDelegate`. By default newer Swift UI apps do not come with an `AppDelegate`, so you can [follow these instructions](https://www.hackingwithswift.com/quick-start/swiftui/how-to-add-an-appdelegate-to-a-swiftui-app) to add one to your project (for macOS you need to [use NSApplication](https://stackoverflow.com/questions/71291654/swiftui-appdelegate-on-macos) instead) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I create a new Swift project, instead of the NSObject
type I have the UIResponder
type in that same position. Should I replace that with NSObject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sumitramanga I think it depends on what kind of project you're creating - for macOS or for iOS. Can you paste the App
struct you have in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@main
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
let raygunClient = RaygunClient.sharedInstance(apiKey: "{redacted}")
raygunClient.enableCrashReporting()
return true
}
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
}
}```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a iOS app with Swift This is the AppDelegate that I've been working in. I also have been working in the ViewController which I'll show you. These are the only files I've touched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let crashButton = UIButton(type: .system)
crashButton.setTitle("Trigger crash", for: .normal)
crashButton.addTarget(self, action: #selector(triggerCrash), for: .touchUpInside)
crashButton.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(crashButton)
NSLayoutConstraint.activate([
crashButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
crashButton.centerYAnchor.constraint(equalTo: view.centerYAnchor),
])
}
@objc func triggerCrash() {
fatalError("Test for Raygun")
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sumitramanga yeah so NSObject
is just a generic object whereas UIResponder
is an interface for events so I would put UIResponder
in there. Different people might do different things though.
Your second example looks like a UIKit app rather than a SwiftUI app, which is why there's a difference. I think they start with an AppDelegate by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :) Running through the README was easy but I will let you know once I have a working app 😄