How to use an existing swift app in react native? - ios

There are some things that CAN be done in react native but due to performance concerns, I have decided to implement in Swift and then run it in react native, for example, image processing.
Suppose I have a swift app that doesn't do anything other than displaying Hello World like so:
the code for it is not modified at all:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
I would like to run this simple app in react native in this fashion:
SimpleApp.show();
How can I make this happen?

You could do so using NativeModules
Interesting helpful article that helped me through my fitness application: Swift Modules for React Native
And this one would help too!
React Native app in Swift

Related

Issue in Firebase Crashlytics setup 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.

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.

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

SWIFT 2: Class ViewController has no initializers - Using GOOGLE's Admob

I was following a Youtube tutorial to learn how to use Google's AdMob with Swift on XCode: https://www.youtube.com/watch?v=tJi-vQ9e-HI
I got an error saying that my class "ViewController" has no identifiers.
It had worked just fine for the guy on Youtube, we put in the same frameworks, imported the same frameworks, wrote the same code. The only difference I believe is that he was developing for iOS 9.1 while I was doing it for 9.3.
The picture linked below has my code for the ViewController.swift file and I do not know what is wrong with it.
Any help is appreciated.
Thanks!
ViewController.swift
You didn't initialize the banner before loading the view, you have to make sure it exists. So this should fix it:
var adBanner: GADBannerView!

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.

Resources