Issue in Firebase Crashlytics setup iOS? - ios

I am trying to FirebaseCrashlytics in my app but stuck in 3rd step.
I am crashing app at
import UIKit
import FirebaseCrashlytics
class ViewController: UIViewController {
let testarry = [1, 3, 5]
override func viewDidLoad() {
super.viewDidLoad()
// crash app
print(testarry[5])
}
}
Run Script
Even after
Build and run your app
Stop the app from Xcode
Open the app manually from your device or simulator.
Third step is not passing
in xcode console getting output like
Is there anything i am missing?

Your upload runscript does not look correct, try following this format. Also, make sure your google services file is in your app.

Related

How to load WebAssembly in iOS app via WKWebVIew or JSC

I'm trying to load and execute a WebAssembly .wasm from within a Swift-based, iOS app. I first attempted to use the JavaScriptCore Framework but the WebAssembly.* module wasn't available in the Context when I tried to evaluate a trivial script. I was able to confirm the WebAssembly isn't defined via the Safari Debugger Console.
I then attempted to use WKWebView because I'm led to believe that the lack of WebAssembly is due to JSC not supporting JIT, which WKWebView should. I got the same result.
Here's a trivial app running on an iPhone X 12.4 emulator, Xcode 10.3 and the WebKit Framework manually added to the project. Make sure to open Safari and Select "Developer>Simulator" for WKWebView debugger.
import UIKit
import WebKit
class ViewController: UIViewController {
#IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
}
#IBAction func onClick(_ sender: UIButton) {
let testWasm = """
if(typeof WebAssembly !== 'undefined') {
console.log("Hello, Wasm.");
} else {
console.log("No Wasm for you!");
}
"""
webView.evaluateJavaScript(testWasm)
}
}
Does iOS actually have a way to load WebAssembly into a Swift-based app?
I wanted to run some benchmarks with JSC to compare it with Wasm3.
Basically I run into the same situation and wasn't able to fix so far.
Wasm3 runs perfectly fine on iOS, and may suite your needs at the moment.
Currently you can't run WebAssembly with JSC on the simulator according to this comment.
It appears that JavaScriptCore now has a WebAssembly interpreter, as of Feb 2020.

Breakpoint not getting hit, nor the Message extension is getting attached in iOS

I am writing a SMS filter extension for iOS. I created a MessageFilterExtension. The extension code is
import IdentityLookup
final class MessageFilterExtension: ILMessageFilterExtension {
var words: [String] = ["deal", "spam", "offer"]
override init() {
print("message filter init")
}
}
extension MessageFilterExtension: ILMessageFilterQueryHandling {
func handle(_ queryRequest: ILMessageFilterQueryRequest, context: ILMessageFilterExtensionContext, completion: #escaping (ILMessageFilterQueryResponse) -> Void) {
//...
}
I had set breakpoints in the container app did launch, in the appex handle and other methods. The appex does not call remote services. Then I choose the appex target, clicked run, in the attach list chose the container app as the likely target which was already mentioned. It then shows "Waiting to attach". Then I choose container app and hit run, it build and runs, and hits the breakpoint. However, the appex is not getting attached or launched. I then send some SMS texts, but it does not filter. No print statements in Xcode or Console.app. I have enabled message filter and set the Container app to filter SMS.
I am testing this on iPhone 7 Plus and iOS 12.1.4. Tested on previous release of iOS, but still did not work.
Methods I tried so far:
How To Debug iOS Appex
Messages App Extension won't hit breakpoints
I do not have the contact name saved. (With some combination, it worked once, but I now I am not able to debug). How do debug message filter extensions?
We can debug an extension by running the extension alone from the Xcode schema menu. In this case the breakpoint will be hit. When running with the main app, the extension breakpoints will not be hit. In general app extension programming seems to work that way.

Problem with adding Firebase Crashlytics to iOS Share Extension

I'm trying to add Firebase to collect analytics events and crashes to iOS Share Extension. Everything works perfect in main app but not in Share Extension. I managed to find this way of initialization:
override func viewDidLoad() {
super.viewDidLoad()
if FirebaseApp.app() == nil {
FirebaseApp.configure()
}
// other code
}
Analytics.logEvent works perfectly, I can see events in firebase console, but crashes are not collected.
In addition, xcode organizer periodically collects the following crashes:
Who can tell what could be the reason and what to do to make Crashlytics collect crashes?
I managed to do it by adding this:
if FirebaseApp.app() == nil {
FirebaseApp.configure()
Fabric.with([Crashlytics.self])
}

Why my iOS app fails / closes when I open it from iOS simulator?

I am developing a small Swift application. In Xcode, when I press run button or use cmd + R keyboard shortcut, simulator and my app runs as I expected. But in simulator, when I click my installed app's icon to run it my app appears for one second and crashes / fails with no error message or no log.
I'm new to iOS development and don't know is this a common issue or where I do wrong.
I've reset simulator content and settings by iOS Simulator Menu -> Reset Content and Settings... option.
I've restarted iOS simulator, Xcode and operating system (OS X) but the problem still existing.
I basically want to click my installed app's icon in simulator and run it. How can I fix this issue?
--
Edit due comments:
I don't touch AppDelegate.swift file. It is same as first generated. And I have only one ViewController class, ViewController.swift and methods are:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(animated: Bool) {
login()
}
/// Login method
func login() {
// login methos's body
}
Ok, I've got solution. Thanks to #Phillip Mills for his comment. That comment helps me to find solution.
In System Log Queries, I found the report crash, like as follow:
Dyld Error Message:
Library not loaded: #rpath/Alamofire.framework/Alamofire
Referenced from: /Users/USER/Library/Developer/CoreSimulator/Devices/79ECB6DD-8AF9-42F7-8543-AF9F689258C0/data/Containers/Bundle/Application/126E829F-A5D3-48CE-B65A-C06CE811A679/MyAwesoneApp.app/MyAwesoneApp
Reason: image not found
And googled it, than found this issue from github: dyld: Library not loaded: #rpath/Alamofire.framework/Alamofire on my iPhone(iOS8) while debuging #101
I tried that I saw from screen shot and it works!
I forgot to add Alamofire framework to Link Binary With Libraries part.

How do I force a crash in Swift iOS app with Fabric SDK?

All I can find is Is there a quick way to force a crash? which says to:
[[Crashlytics sharedInstance] crash];
which I think in Swift would be
Crashlytics.sharedInstance.crash()
but this does not seem to exist. (perhaps the docs are out of date and no longer apply since Fabric gobbled up Crashlytics?)
I see that there is a Crashlytics.crash(self:Crashlytics) ...nevermind, friggin XCode's completion is always broken for me. See answer below.
If you are using the new Firebase Crashlytics SDK note that import Crashlytics has been replaced by import FirebaseCrashlytics. The crash() method is no longer available in the new SDK. As recommended by Firebase, simply use:
Swift:
fatalError()
Obj C:
assert(NO);
(if it's in a file other than your AppDelegate, you will need to import Crashlytics, then just do Crashlytics.sharedInstance().crash()
Create a Project and App in firebase
Add a new iOS app in the firebase console if you have existing firebase project or create firebase project and create new app in the firebase console.
Add Firebase to iOS App
Firstly in step 1, register your app by adding the bundle identifier while creating iOS app to firebase. In step 2, Download config file GoogleService-Info.plist add it to your workspace like in the image shown below.
Add Crashlytics SDK via CocoaPods
To get started, add the Crashlytics SDK framework files to your project. For most projects, the easiest way to do that is by adding the Crashlytics CocoaPods.
pod 'Firebase/Core'
pod 'Fabric', '~> 1.7.2'
pod 'Crashlytics', '~> 3.9.3'
Test your implementation
Enable Crashlytics debug mode: In order to enable crashlytics in debug mode we need to set Fabric.sharedSDK().debug mode to true in AppDelegate.swift.
import UIKit
import Firebase
import Crashlytics
import Fabric
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Fabric.sharedSDK().debug = true
return true
}
Force crash to test implementation: While writing this article, I have one view controller with one button named (Click to crash app) in the middle of the viewController. For the testing purpose, when user click the button app crashed.
And View controller this below code and run once in simulator or device and check in Firebase dashboard .You find all crashes report.
import UIKit
import Crashlytics
class ViewController: UIViewController {
var name:String!
var number:Int!
override func viewDidLoad() {
super.viewDidLoad()
name = "12"
}
#IBAction func crashBtnAction(_ sender: Any) {
//creshreportMethod()
print("name of the value",name)
var myDict = [String:Any]()
myDict = ["name":number!]
print("my dict value",myDict)
}
}
Crashlytics can’t capture crashes if your build attaches a debugger at launch. Adjust your build settings to change the project’s debug information format:
With your project still selected in the Xcode Navigator, open the Build Settings tab.
Click All at the top of the tab to display all build settings.
Search for “debug information format”.
Set the Debug Information Format setting to DWARF with dSYM File.

Resources