Cannot remove Main Interface from Xcode project - ios

I am working on an iPad app that does not use a .storyboard interface. My AppDelegate has the following code (in Xcode 8.2.1):
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = MyViewController()
return true
}
I've cleared the Main Interface field from the target as shown below:
However, upon running the app, I receive the following crash message:
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Could not find a storyboard
named 'Main' in bundle NSBundle
It seems that upon Building/Running the app, the Main Interface field is automatically repopulated with "Main". I've been able to remove this on universal apps, but this is my first, and unsuccessful attempt with an iPad only project. I've tried both pressing Return on the keyboard and clicking outside the field in hopes of saving my Main Interface text field changes, but still have the same result.
My question is: How can I remove the Main Interface from the target and thus avoid this error message?

Check your Info.plist. There should be an entry for the Main storyboard file base name. Delete it there and you should be good to go!

Related

iOS Firestore App runs on Simulator but not on phone

I am developing an App that uses Firestore. The app runs fine on the Xcode simulator, but crashes when I try to run it on my phone. I get the following error message:
*** Terminating app due to uncaught exception 'FIRIllegalStateException', reason: 'Failed to get FirebaseApp
instance. Please call FirebaseApp.configure() before using Firestore'
I do call FirebaseApp.configure() in the didFinishLaunchingWithOptions:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
I don't understand why it would run in the simulator and not on my phone. Any help would be appreciated.
Check your podfile for how you add the firebase cocoapods, It should be like this,
pod 'FirebaseCore'
pod 'Firebase/Messaging'
If your podfile different ,please remove old firebase related pods,insert this and install.
I discovered, on a Japanese code forum, what to do. I added the following code to the AppDelegate.swift file:
var window: UIWindow?
override init() { //初期化メソッドを追記
FirebaseApp.configure()
}
The app now runs both in the simulator and on my iPhone.

IOS - second launch of my app going auto in background

when I start my application from Xcode, the application works properly, but if I close and then open the app again, it goes into the background automatically without control. How can I fix this bug ?
There are some crash types those will not be happening when running the app via Xcode.
For example:
If the app launch takes too long, that app will be crashed. Basically it’s not a crash, but app needs to be launched quickly without delay which is expected by operating system.
So You need to make sure that you are not doing any heavy operations on Main Thread during app launch especially on below methods in AppDelegate
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Avoid heavy loads on main thread here
return true
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Avoid heavy loads on main thread here
return true
}
Also I received a crash a few years back when I tried to add an objective c struct to my NSObject class without allocating memory of struct variable. But this crash was unable to reproduce when I was running my app via Xcode and only happened when I launch the app without Xcode. So I made that struct variable as a pointer and did memory allocation as like (BoothStructure*)malloc(sizeof(BoothStructure) * count), after that there was no crash.
So please analyze your crash using crash logs as well and check if it meets any one of above scenario.
To check crash log of development build:
Open Xcode -> Connect your iOS device which has/had the crashed app -> Window -> Devices and Simulators -> View Device Logs
To check crash log of production build(you should add your developer account in Xcode that is used to publish your app):
Open Xcode -> Window -> Organizer -> Select your app from the list of apps -> Select crashes tab in segmented controller at top -> Select your build version.

Use of unresolved identifier 'TestFairy' error in Xcode 9 when using TestFairy.begin()

After following all of the necessary steps on the TestFairy website to integrate the TestFairy SDK into iOS, I've run into a problem. I dragged the files into my project, I've checked "Copy files if needed", I've created the Bridging Header required to import TestFairy.
The app compiles and runs on the simulator but the error occurs when I try to archive the application.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Check if the user isn't logged in, make the login screen the launcher
if !userDefaultExists(forKey: "username") {
self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "LoginView")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
}
TestFairy.begin(appToken)
return true
}
The error message is "Use of unresolved identifier 'TestFairy'".
Disclaimer: I work at TestFairy
These sort of problems are most often related to a problem with your project settings. While copying the TestFairy library into your project, you may have added to it to a path that is not searched for during archiving. Cocoapods would indeed make sure that you would not have this sort of problem, however, if you ever wanted to revert back to dragging the library into your project, feel free to reach out to us at support#testfairy.com
This error occurs because of your bundle could not find your file so please select TestFairy.m file and check its target. Its target is selected for your project. If not then check it and select. then run again.
check below image--> Right side target is selected
I managed to find a workaround for the problem I faced. I installed TestFairy using Cocoapods instead of using the recommended TestFairy SDK integration technique (Drag and Drop).

Firebase.configure() in xCode cause Thread 1: signal SIGABRT : terminating with uncaught exception of type NSException on App Delegate

Firebase.configure causes crash on App delegate file once I run, showing the following next to app delegate class
Thread 1: signal SIGABRT
In console, it shows :
37 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Any help please?
Note: I have Google .plist file on the project , and the right one ( I tried several times in like 8 or 10 project till now, no success)
Pod installed :
Installing Firebase (4.3.0)
Installing FirebaseAnalytics (4.0.4)
Installing FirebaseCore (4.0.8)
Installing FirebaseInstanceID (2.0.4)
..
Code :
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
Please help me out, I really need it and it's been 2 days and like 12 hours infront of xCode
This issue seems to be happening when 'GoogleService-Info.plist' file is missing within your project path. Delete the existing 'GoogleService-Info.plist'. Download again from the Firebase service, and add the '.plist' File, make sure you select the correct project target. Once added, clean and build again.
Set the target membership for the plist file
select GoogleSErvice-Info.plist in the Xcode project navigator
then enable the target membership for the file in the utilities pane for File Inspector
I had the same issue, although the GoogleService-Info(1).plist file was already present in my Xcode project.
In my case, I had already an GoogleService-Info.plist file in my Downloads directory, from a previous project. Because of that, the next file had been automatically named "GoogleService-Info(1).plist" ...and this is how I've imported in Xcode.
Because of this minor renaming of the file, I've spend more than 1 hour not knowing why on earth my app crashes!
Make sure your Google.plist file has the right name, which is: GoogleService-Info.plist
Make sure that you have "GoogleService-Info.plist" is present within your project
replace FirebaseApp.configure() with Firebase.FirebaseApp.configure()

App Crashes on AppDelegate Class Declaration with EXC_BAD_ACCESS CODE 1 on iOS 9.1/9.2

I installed XCode 7.1 and 7.2 to update my app for iOS 9.1 and 9.2 respectively, but each time I run the app on simulators or devices the app crashes on the AppDelegate's class declaration as shown below. However, I have also XCode 7.0 and when I run my app on iOS 9.0 it works fine without any issue !.
The problem even if I compile the app for iOS 9.0 it would crashes on any device running iOS 9.1 or 9.2, I tried to change the initial view controller to be a simple plain one but it seems that it never reaches the point of loading view controllers and never reaches the beginning of func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool.
It seems that Apple did something with iOS 9.1 & 9.2. The app is written in swift, I enabled NSZombie and breakpoints to catch exceptions but I get no clue from the logs.
Debug Navigator:-
AppDelegate Class Declaration
That happens to me almost every time in new versions of Xcode/Swift/iOS. When I have had this problem I have erased that line and written it again.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
This happens when you have not set you variable types correctly. Check how you declare them. In my case i was trying to access a Bool as UIColor.
I've generally had this happen when there is a storyboard problem. For example, an error in:
storyboard.instantiateController(withIdentifier: "FooView")
Try putting breakpoints around controllers that are being loaded around where you are crashing to see if that's the problem.

Resources