Skip to content
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

Merged
merged 4 commits into from
May 23, 2024
Merged

Updates README.md #52

merged 4 commits into from
May 23, 2024

Conversation

nikz
Copy link
Collaborator

@nikz 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
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
install-preview.png Outdated Show resolved Hide resolved
Copy link
Collaborator

@sumitramanga sumitramanga left a 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 💯

nikz and others added 3 commits May 17, 2024 16:05
Co-authored-by: Sumitra Manga <36393794+sumitramanga@users.noreply.github.com>
Co-authored-by: Sumitra Manga <36393794+sumitramanga@users.noreply.github.com>

```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)
Copy link
Collaborator

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

Copy link
Collaborator Author

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?

Copy link
Collaborator

@sumitramanga sumitramanga May 20, 2024

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>) {
    }

}```

Copy link
Collaborator

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

Copy link
Collaborator

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")
    }
}

Copy link
Collaborator Author

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.

Copy link
Collaborator

@sumitramanga sumitramanga left a 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 😄

@nikz nikz merged commit b8f7c5b into MindscapeHQ:master May 23, 2024
@nikz nikz deleted the readme-update branch May 23, 2024 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants