I'm new in XCode and I'm trying to create a simple Webview that displays www.google.com website
But the Code does not RUN. I got an Error: Threat1: Signal SIGATBRT
Here is my code:
import UIKit
import WebKit
class ViewController: UIViewController {
#IBOutlet var WebView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "www.google.com")
let request = URLRequest(url: url!)
WebView.load(request)
// Do any additional setup after loading the view.
}
}
Questions Update
import UIKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { // <- The Error Pointing Here!!! -> Threat1: Signal SIGABRT
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Output Text
2020-01-16 09:58:27.127224+0200 wvApp2[6306:366786] -[__NSArrayM loadRequest:]: unrecognized selector sent to instance 0x600001f0c3c0
2020-01-16 09:59:21.186755+0200 wvApp2[6306:366786] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM loadRequest:]: unrecognized selector sent to instance 0x600001f0c3c0'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23c7127e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff513fbb20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23c91fd4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff23c75c4c ___forwarding___ + 1436
4 CoreFoundation 0x00007fff23c77f78 _CF_forwarding_prep_0 + 120
5 wvApp2 0x00000001038677ea $s6wvApp214ViewControllerC11viewDidLoadyyF + 890
6 wvApp2 0x0000000103867a8b $s6wvApp214ViewControllerC11viewDidLoadyyFTo + 43
7 UIKitCore 0x00007fff47a0ef01 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83
8 UIKitCore 0x00007fff47a13e5a -[UIViewController loadViewIfRequired] + 1084
9 UIKitCore 0x00007fff47a14277 -[UIViewController view] + 27
10 UIKitCore 0x00007fff480ca3cf -[UIWindow addRootViewControllerViewIfPossible] + 150
11 UIKitCore 0x00007fff480c9ac0 -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 232
12 UIKitCore 0x00007fff480cab43 -[UIWindow _setHidden:forced:] + 362
13 UIKitCore 0x00007fff480ddef1 -[UIWindow _mainQueue_makeKeyAndVisible] + 42
14 UIKitCore 0x00007fff482e9431 -[UIWindowScene _makeKeyAndVisibleIfNeeded] + 202
15 UIKitCore 0x00007fff4761d445 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1405
16 UIKitCore 0x00007fff4808f170 -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 1018
17 UIKitCore 0x00007fff4808f4b2 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 304
18 UIKitCore 0x00007fff47bfa7f5 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
19 FrontBoardServices 0x00007fff365d6165 -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 442
20 FrontBoardServices 0x00007fff365fc4d8 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.154 + 102
21 FrontBoardServices 0x00007fff365e0c45 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 220
22 FrontBoardServices 0x00007fff365fc169 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke + 355
23 libdispatch.dylib 0x0000000103b91d48 _dispatch_client_callout + 8
24 libdispatch.dylib 0x0000000103b94cb9 _dispatch_block_invoke_direct + 300
25 FrontBoardServices 0x00007fff3662237e __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
26 FrontBoardServices 0x00007fff3662206c -[FBSSerialQueue _queue_performNextIfPossible] + 441
27 FrontBoardServices 0x00007fff3662257b -[FBSSerialQueue _performNextFromRunLoopSource] + 22
28 CoreFoundation 0x00007fff23bd4471 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
29 CoreFoundation 0x00007fff23bd439c __CFRunLoopDoSource0 + 76
30 CoreFoundation 0x00007fff23bd3bcc __CFRunLoopDoSources0 + 268
31 CoreFoundation 0x00007fff23bce87f __CFRunLoopRun + 1263
32 CoreFoundation 0x00007fff23bce066 CFRunLoopRunSpecific + 438
33 GraphicsServices 0x00007fff384c0bb0 GSEventRunModal + 65
34 UIKitCore 0x00007fff48092d4d UIApplicationMain + 1621
35 wvApp2 0x00000001038689bb main + 75
36 libdyld.dylib 0x00007fff5227ec25 start + 1
37 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
This is the Output text from All Output Window. I think this will help to clear out all misunderstandings on this question. This output is from the Run of the app till the exception.
Recent Issues
Showing Recent Issues
Build target wvApp2 of project wvApp2 with configuration Debug
CompileStoryboard /Users/admin/DevSource/wvApp2/wvApp2/Base.lproj/Main.storyboard (in target 'wvApp2' from project 'wvApp2')
cd /Users/admin/DevSource/wvApp2
export XCODE_DEVELOPER_USR_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin/..
/Applications/Xcode.app/Contents/Developer/usr/bin/ibtool --errors --warnings --notices --module wvApp2 --output-partial-info-plist /Users/admin/Library/Developer/Xcode/DerivedData/wvApp2-ehhbosgmbdwuucejiweipdfuqjzt/Build/Intermediates.noindex/wvApp2.build/Debug-iphonesimulator/wvApp2.build/Base.lproj/Main-SBPartialInfo.plist --auto-activate-custom-fonts --target-device iphone --target-device ipad --minimum-deployment-target 13.2 --output-format human-readable-text --compilation-directory /Users/admin/Library/Developer/Xcode/DerivedData/wvApp2-ehhbosgmbdwuucejiweipdfuqjzt/Build/Intermediates.noindex/wvApp2.build/Debug-iphonesimulator/wvApp2.build/Base.lproj /Users/admin/DevSource/wvApp2/wvApp2/Base.lproj/Main.storyboard
/* com.apple.ibtool.document.warnings */
/Users/admin/DevSource/wvApp2/wvApp2/Base.lproj/Main.storyboard:Bvy-8R-dSa: warning: UIWebView is deprecated since iOS 12.0 [7]
I don't know what I am doing wrong,
How can I solve this? Anyone answer is welcome.
First, you should better let variables start with a lowercase letter (and types with a uppercase). This is the kind-of-convetion in Swift (and Java and C++ and C and almost any other programming language except C#):
#IBOutlet var webView: WKWebView!
(change this using refactor in Xcode, to sync the storyboard/xib)
Then, don't use explicit unwrapping, better use if let:
if let url = URL(string: "www.google.com") {
let request = URLRequest(url: url)
webView.load(request)
}
To your exception: The only other thing (besides that the explicit url! unwrapping could fail) might be that the outlet webView is nil. You could also check this:
if (webView == nil) {
print ("Ooops")
}
If it's nil, check the connections from the storyboard/xib.
Make sure that you import webKit framework in your project target.
Target -> General -> Linked Framework and Libraries -> click on the + -> add the webKit.framwork
If you have done that and it's still not working please show more of the error message you are getting.
Also on a side note for naming convention you should not start class properties with uppercase.
Leading uppercase names are reserved for classes, this way you will always know if the code is referring to a class or a property. So in your case:
// #IBOutlet var WebView: WKWebView! change this to
#IBOutlet var webView: WKWebView!
Related
I am trying to follow the steps to connect Firebase to an iOS App generated by Flutter.
In the final step, when adding the line FirebaseApp.configure() into the AppDelegate.swift file, the App builds OK, but then crashes upon execution, indicating a Signal Abortion on Thread 1...
Thread 1: signal SIGABRT
The code in AppDelegate.swift is the following:
import UIKit
import Flutter
import Firebase
#UIApplicationMain
#objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
FirebaseApp.configure()
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
};
}
The full Error log provided by Xcode is the following:
2019-11-18 07:11:34.664822-0500 Runner[82048:876634] - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2019-11-18 07:11:34.849351-0500 Runner[82048:876630] 6.13.0 - [Firebase/Core][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'.
2019-11-18 07:11:34.860414-0500 Runner[82048:876433] *** Terminating app due to uncaught exception 'com.firebase.core', reason: '`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23c4f02e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50b97b20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23c4ee6c +[NSException raise:format:] + 188
3 Runner 0x00000001040bf51a +[FIRApp configure] + 138
4 Runner 0x00000001040baea4 $s6Runner11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtF + 212
5 Runner 0x00000001040bb1f4 $s6Runner11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtFTo + 212
6 UIKitCore 0x00007fff47846788 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232
7 UIKitCore 0x00007fff47848197 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3980
8 UIKitCore 0x00007fff4784dce6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1281
9 UIKitCore 0x00007fff46f843c9 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122
10 UIKitCore 0x00007fff47471be1 _UIScenePerformActionsWithLifecycleActionMask + 83
11 UIKitCore 0x00007fff46f84edb __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198
12 UIKitCore 0x00007fff46f848ea -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 296
13 UIKitCore 0x00007fff46f84d08 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 818
14 UIKitCore 0x00007fff46f8459d -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 345
15 UIKitCore 0x00007fff46f88bcb __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 178
16 UIKitCore 0x00007fff4739769b +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 865
17 UIKitCore 0x00007fff4749051f _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 240
18 UIKitCore 0x00007fff46f888e6 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 153
19 UIKitCore 0x00007fff47490422 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 84
20 UIKitCore 0x00007fff46f88754 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 381
21 UIKitCore 0x00007fff46ddf123 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 657
22 UIKitCore 0x00007fff46dddca8 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 248
23 UIKitCore 0x00007fff46ddee4d -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 210
24 UIKitCore 0x00007fff4784c343 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 535
25 UIKitCore 0x00007fff473b920d -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
26 FrontBoardServices 0x00007fff36555225 -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 442
27 FrontBoardServices 0x00007fff3657b598 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.154 + 102
28 FrontBoardServices 0x00007fff3655fd05 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 220
29 FrontBoardServices 0x00007fff3657b229 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke + 355
30 libdispatch.dylib 0x00000001070ebd48 _dispatch_client_callout + 8
31 libdispatch.dylib 0x00000001070eecb9 _dispatch_block_invoke_direct + 300
32 FrontBoardServices 0x00007fff365a143e __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
33 FrontBoardServices 0x00007fff365a112c -[FBSSerialQueue _queue_performNextIfPossible] + 441
34 FrontBoardServices 0x00007fff365a163b -[FBSSerialQueue _performNextFromRunLoopSource] + 22
35 CoreFoundation 0x00007fff23bb2221 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
36 CoreFoundation 0x00007fff23bb214c __CFRunLoopDoSource0 + 76
37 CoreFoundation 0x00007fff23bb1924 __CFRunLoopDoSources0 + 180
38 CoreFoundation 0x00007fff23bac62f __CFRunLoopRun + 1263
39 CoreFoundation 0x00007fff23babe16 CFRunLoopRunSpecific + 438
40 GraphicsServices 0x00007fff38438bb0 GSEventRunModal + 65
41 UIKitCore 0x00007fff4784fb48 UIApplicationMain + 1621
42 Runner 0x00000001040bb45b main + 75
43 libdyld.dylib 0x00007fff51a1dc25 start + 1
44 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
A very interesting line in the above Error log:
Terminating app due to uncaught exception 'com.firebase.core', reason: '[FIRApp configure]; (FirebaseApp.configure() in Swift) could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/.'
So...
That message clearly suggests that there may be some issue with the GoogleService-Info.plist, like if it wasn't present... except that it IS indeed present, freshly downloaded from Firebase, it is located in the correct folder, and I have thoroughly reviewed the contents of the plist to verify the Bundle ID, Team ID and all other info is correct...
May anyone kindly please offer some suggestion to solve this problem?
THANKS
To check that you have included the file in your target do the following
Click on the file that you are checking
Click on the file inspector
Check that the file is included in your required target. Most apps only have one target.
When I attempted to add the FirebaseApp.configure() statement to my AppDelegate.swift file, the project would no longer build. So I removed those statements and continued on with the Firebase/Analytics setup. My app was able to eventually communicate with the Firebase server without that statement. It looks like the firebase plugins must be doing that for us. I added both firebase_core and firebase_analytics to my pubspec.yaml as:
firebase_core: ^0.4.0+9
firebase_analytics:
I have a Firebase integrated to my swift app. All the initialisation done is programmatically and the FirebaseApp.config() is called the very first thing in didLaunchWithOptions in the AppDelegate.
But for some random reason, whenever the app is in the background for a long time, the app just crashes on the run, i.e making it's state active.
Interestingly, this crash happens exactly 2 times in the following flow:
1. The App is idle in background
2. You bring it to the active mode(You just tap the icon to open the app. All this while the app isn't killed)
3. Tap 1 ---- The App Crashes----
4. Tap 2 ---- The App Crashes----
5. Tap 3 ---- The App Runs Normally ----
I tried to troubleshoot but all my efforts have gone in vain. I have tried setting up both the storyboards and programmatically launching app. Nothing works.
Following is the stack trace :
SpotMi-Dev[74741:2958059] *** Terminating app due to uncaught exception 'FIRAppNotConfigured', reason: 'Failed to get default Firebase Database instance. Must call `[FIRApp configure]` (`FirebaseApp.configure()` in Swift) before using Firebase Database.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d3816fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010c14aac5 objc_exception_throw + 48
2 CoreFoundation 0x000000010d381555 +[NSException raise:format:] + 197
3 SpotMi-Dev 0x0000000101be5ba1 +[FIRDatabase database] + 97
4 SpotMi-Dev 0x0000000101aaba6b $s10SpotMi_Dev13FBDataserviceCACycfc + 59
5 SpotMi-Dev 0x0000000101aac193 $s10SpotMi_Dev13FBDataserviceCACycfcTo + 19
6 SpotMi-Dev 0x0000000101aa696c $s10SpotMi_Dev13FBDataserviceCACycfC + 44
7 SpotMi-Dev 0x0000000101aa692c globalinit_33_8263DB418F9D5BC81149F56895386F46_func0 + 28
8 libdispatch.dylib 0x000000010ecaddb5 _dispatch_client_callout + 8
9 libdispatch.dylib 0x000000010ecaf83d _dispatch_once_callout + 66
10 libswiftCore.dylib 0x000000010e2c6579 swift_once + 25
11 SpotMi-Dev 0x0000000101aa69f4 $s10SpotMi_Dev13FBDataserviceC2dsACvau + 36
12 SpotMi-Dev 0x000000010180b013 $s10SpotMi_Dev9ProfileVCC18initializeUserPostyyF + 179
13 SpotMi-Dev 0x0000000101809278 $s10SpotMi_Dev9ProfileVCC11viewDidLoadyyF + 616
14 SpotMi-Dev 0x00000001018095b4 $s10SpotMi_Dev9ProfileVCC11viewDidLoadyyFTo + 36
15 UIKitCore 0x000000011589443b -[UIViewController loadViewIfRequired] + 1183
16 UIKitCore 0x0000000115894868 -[UIViewController view] + 27
17 UIKitCore 0x0000000115ebd4ad -[UIApplication(StateRestoration) _restoreApplicationPreservationStateWithSessionIdentifier:beginHandler:completionHandler:] + 6413
18 UIKitCore 0x0000000115eb8fdc -[UIApplication(StateRestoration) _doRestorationIfNecessary] + 211
19 UIKitCore 0x0000000115e8e2c9 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 208
20 UIKitCore 0x0000000115e8fcad -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3932
21 UIKitCore 0x0000000115e950c6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1617
22 UIKitCore 0x00000001156da6d6 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 904
23 UIKitCore 0x00000001156e2fce +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
24 UIKitCore 0x00000001156da2ec -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236
25 UIKitCore 0x00000001156dac48 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1091
26 UIKitCore 0x00000001156d8fba __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 782
27 UIKitCore 0x00000001156d8c71 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 433
28 UIKitCore 0x00000001156dd9b6 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 576
29 UIKitCore 0x00000001156de610 _performActionsWithDelayForTransitionContext + 100
30 UIKitCore 0x00000001156dd71d -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 223
31 UIKitCore 0x00000001156e26d0 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
32 UIKitCore 0x0000000115e939a8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 514
33 UIKitCore 0x0000000115a4adfa -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
34 FrontBoardServices 0x00000001133a4125 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 448
35 FrontBoardServices 0x00000001133aded6 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 283
36 FrontBoardServices 0x00000001133ad700 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 53
37 libdispatch.dylib 0x000000010ecaddb5 _dispatch_client_callout + 8
38 libdispatch.dylib 0x000000010ecb12ba _dispatch_block_invoke_direct + 300
39 FrontBoardServices 0x00000001133df146 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
40 FrontBoardServices 0x00000001133dedfe -[FBSSerialQueue _performNext] + 451
41 FrontBoardServices 0x00000001133df393 -[FBSSerialQueue _performNextFromRunLoopSource] + 42
42 CoreFoundation 0x000000010d2e8be1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
43 CoreFoundation 0x000000010d2e8463 __CFRunLoopDoSources0 + 243
44 CoreFoundation 0x000000010d2e2b1f __CFRunLoopRun + 1231
45 CoreFoundation 0x000000010d2e2302 CFRunLoopRunSpecific + 626
46 GraphicsServices 0x000000011034e2fe GSEventRunModal + 65
47 UIKitCore 0x0000000115e96ba2 UIApplicationMain + 140
48 SpotMi-Dev 0x000000010174287b main + 75
49 libdyld.dylib 0x000000010ed22541 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Following is the code from didLaunchWithOptions:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
#if DEVELOPMENT
print("Development Mode Started")
#else
print("Production Mode Started")
#endif
FirebaseApp.configure()
Messaging.messaging().delegate = self
//other app functions
return true
}
I am calling the Firebase API in the viewDidLoad of init controller. And this is the Service through which it gets called and this even contains the crash aswell.
class FBDataservice : NSObject {
static var ds = FBDataservice() //<------ Creates Error here on every single crash related to this issue
let DB_URL: DatabaseReference = Database.database().reference()
let ST_URL: StorageReference = Storage.storage().reference()
private lazy var _REF_BASE = DB_URL
}
And then I just call FBDataservice.ds._REF_BASE.child("something").observe( .Event, with (Datasnapshot)) in the viewDidLoad or viewDidAppear. I am just mostly fetching the data. And then push data like updating app RunCounts on didBecameActive in AppDelegate
Any help will immensely be appreciated. Cheers
Check FirebaseApp.app() if this is nil can you call the FirebaseApp.configure() again? You need to debug if this crashes in appDidBecomeActive: or didEneterInForeground: method.
Also please check where you use FirebaseDatabase at very first time after launching the application except the configuration line? I mean is in any ViewController or anywhere, we need to check the condition here.
Updated Question:
Regarding your updated question FBDataservice() where are you making its instance because as you create its instance it will create DB_URL and ST_URL url instances which are related to Firebase so probably Firebase is not configured before this. You can override its init method to check if Firebase is configured or not.
You took two variables which will be create in constructor whenever you will make an instance of this class.
Try one thing... replace
static var ds = FBDataservice()
with
static var ds: FBDataservice {
if FirebaseApp.app() == nil {
FirebaseApp.configure()
}
return FBDataservice()
}
I am a beginner in programming, and new to Stack Overflow as well. I'm still figuring out how codes and this website work, so I'm sorry if I didn't use them correctly. (I'm not a native English speaker, but I'll do my best to explain my question as well as possible)
I'm using Xcode Version 8.1, and Swift.
I'm building an app for my school project. I've already created To-Do-List App and Countdown Timer App. So, I want to put them together in one app now.
I created a new project and inserted Tab Bar Controller. Then copied all the files I used in To-Do-List and Countdown Timer apps, and set up the storyboard.
There are no caution marks, but when I run the simulator, an error comes up and the simulator stops. The error I got is "Thread 1: signal SIGABRT" in this line in AppDelegate.swift:
class AppDelegate: UIResponder, UIApplicationDelegate {
and the message in the console is:
2017-01-06 20:32:22.207 PP Final App[61701:3259153] Unknown class PomodoroViewController in Interface Builder file.
2017-01-06 20:32:22.713 PP Final App[61701:3259153] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fd7faf075d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key lbTimer.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001100c234b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010fb2321e objc_exception_throw + 48
2 CoreFoundation 0x00000001100c2299 -[NSException raise] + 9
3 Foundation 0x000000010f63326f -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
4 UIKit 0x000000011067f4ef -[UIViewController setValue:forKey:] + 88
5 UIKit 0x00000001108f379e -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x0000000110067590 -[NSArray makeObjectsPerformSelector:] + 256
7 UIKit 0x00000001108f2122 -[UINib instantiateWithOwner:options:] + 1867
8 UIKit 0x0000000110685c21 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
9 UIKit 0x0000000110686543 -[UIViewController loadView] + 177
10 UIKit 0x0000000110686878 -[UIViewController loadViewIfRequired] + 201
11 UIKit 0x00000001106870cc -[UIViewController view] + 27
12 UIKit 0x00000001106e52df -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 483
13 UIKit 0x00000001106e4721 -[UITabBarController transitionFromViewController:toViewController:] + 59
14 UIKit 0x00000001106e05e2 -[UITabBarController _setSelectedViewController:] + 365
15 UIKit 0x00000001106e0464 -[UITabBarController setSelectedViewController:] + 234
16 UIKit 0x000000011059e6e6 +[UIView(Animation) performWithoutAnimation:] + 90
17 UIKit 0x00000001106daa00 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 354
18 UIKit 0x00000001106dbb7a -[UITabBarController viewWillAppear:] + 206
19 UIKit 0x000000011068ca0f -[UIViewController _setViewAppearState:isAnimating:] + 692
20 UIKit 0x000000011068d11f -[UIViewController __viewWillAppear:] + 147
21 UIKit 0x000000011068e913 -[UIViewController viewWillMoveToWindow:] + 507
22 UIKit 0x0000000110595151 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 621
23 UIKit 0x00000001105a5cf0 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 451
24 UIKit 0x00000001105947a1 -[UIView(Hierarchy) addSubview:] + 838
25 UIKit 0x0000000110550f5b -[UIWindow addRootViewControllerViewIfPossible] + 849
26 UIKit 0x00000001105513a2 -[UIWindow _setHidden:forced:] + 293
27 UIKit 0x0000000110564cb5 -[UIWindow makeKeyAndVisible] + 42
28 UIKit 0x00000001104ddc89 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4818
29 UIKit 0x00000001104e3de9 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731
30 UIKit 0x00000001104e0f69 -[UIApplication workspaceDidEndTransaction:] + 188
31 FrontBoardServices 0x0000000113ed3723 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
32 FrontBoardServices 0x0000000113ed359c -[FBSSerialQueue _performNext] + 189
33 FrontBoardServices 0x0000000113ed3925 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
34 CoreFoundation 0x0000000110067311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
35 CoreFoundation 0x000000011004c59c __CFRunLoopDoSources0 + 556
36 CoreFoundation 0x000000011004ba86 __CFRunLoopRun + 918
37 CoreFoundation 0x000000011004b494 CFRunLoopRunSpecific + 420
38 UIKit 0x00000001104df7e6 -[UIApplication _run] + 434
39 UIKit 0x00000001104e5964 UIApplicationMain + 159
40 PP Final App 0x000000010f52c1cf main + 111
41 libdyld.dylib 0x000000011373c68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
In this message, I see "Unknown class PomodoroViewController in Interface Builder file." This is the problem, right? But I don't know why I got this message. Are there any problems in the file?
Is the way I use Tab Bar Controller right?
Here's the code file of Pomodoro View Controller:
PomodoroViewController
import UIKit
class PomodoroViewController: UIViewController {
#IBOutlet weak var lbTimer: UILabel!
let pomodoroTime: TimeInterval = 60 * 25 //Pomodoro Timer 25 minutes
let formatter = DateFormatter()
var theTime: TimeInterval = 0.0
override func viewDidLoad(){
super.viewDidLoad()
formatter.dateFormat = "mm:ss"
let startTime = Date(timeIntervalSinceReferenceDate: pomodoroTime)
lbTimer.text = formatter.string(from: startTime)
}
override func didReceiveMemoryWarning(){
super.didReceiveMemoryWarning()
}
#IBAction func countDown(_ sender: UIButton) {
theTime = pomodoroTime
Timer.scheduledTimer(timeInterval: 1.0,
target: self,
selector: #selector(PomodoroViewController.tickTimer(timer:)),
userInfo: nil,
repeats: true)
}
func tickTimer(timer: Timer){
theTime -= 1.0
let newTime = Date(timeIntervalSinceReferenceDate: theTime)
if theTime < 0.1 {
timer.invalidate()
}
}
}
and this is how the storyboard looks like:
storyboard
What this error means is:
You have a storyboard (or maybe a xib) that says that one of the view controllers is a PomodoroViewController. But...
PomodoroViewController does not exist when the app is running.
The message says that iOS tried to find PomodoroViewController but it wasn't there, so it tried to use UIViewController instead. Except UIViewController doesn't have the lbTimer property, which makes the app crash.
There are a couple of reasons this could happen:
You might have forgotten to copy PomodoroViewController to the new project.
If you did copy it, you might not be including it in the app target. [Files can be included in the Xcode project that don't get compiled, because you might use the same project file for more than one target.]
In the second case, make sure that the file is checked in the file inspector on the right side of the Xcode window:
I'm just beginning to learn swift, and I have trouble understanding what the console is trying to tell me with this error. I'm following the Apple's guide to learn swift and in the section "Connect the UI to Code" I'm having the following problem:
2016-02-22 01:06:54.121 FoodTracker[20300:502503] <CATransformLayer: 0x7fab3973cb90> - changing property contentsCenter in transform-only layer, will have no effect
2016-02-22 01:06:54.127 FoodTracker[20300:502503] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FoodTracker.ViewController 0x7fab394a9a00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key setDefaultLabelText.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001040b7e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000105df7deb objc_exception_throw + 48
2 CoreFoundation 0x00000001040b7aa9 -[NSException raise] + 9
3 Foundation 0x00000001044809bb -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x0000000104a63320 -[UIViewController setValue:forKey:] + 88
5 UIKit 0x0000000104c91f41 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x0000000103ff84a0 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x0000000104c90924 -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x0000000104a69eea -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x0000000104a6a816 -[UIViewController loadView] + 178
10 UIKit 0x0000000104a6ab74 -[UIViewController loadViewIfRequired] + 138
11 UIKit 0x0000000104a6b2e7 -[UIViewController view] + 27
12 UIKit 0x0000000104941ab0 -[UIWindow addRootViewControllerViewIfPossible] + 61
13 UIKit 0x0000000104942199 -[UIWindow _setHidden:forced:] + 282
14 UIKit 0x0000000104953c2e -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x00000001048cc663 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16 UIKit 0x00000001048d2cc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
17 UIKit 0x00000001048cfe7b -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x0000000107c8c754 -[FBSSerialQueue _performNext] + 192
19 FrontBoardServices 0x0000000107c8cac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
20 CoreFoundation 0x0000000103fe3a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x0000000103fd995c __CFRunLoopDoSources0 + 556
22 CoreFoundation 0x0000000103fd8e13 __CFRunLoopRun + 867
23 CoreFoundation 0x0000000103fd8828 CFRunLoopRunSpecific + 488
24 UIKit 0x00000001048cf7cd -[UIApplication _run] + 402
25 UIKit 0x00000001048d4610 UIApplicationMain + 171
26 FoodTracker 0x0000000103ed947d main + 109
27 libdyld.dylib 0x000000010690092d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Also, this is the code I'm running:
import UIKit
class ViewController: UIViewController {
//MARK: Propierties
#IBOutlet weak var nameTextField: UITextField!
#IBOutlet weak var mealNameLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
//MARK: Actions
#IBAction func setDefaultLabelText(sender: UIButton) {
mealNameLabel.text = "Default Text"
}
}
Thank you in advance for your help. Looking forward to it.
Already solved my problem. As I was just starting to code, I tried copying and pasting what I've written into a new file and it works perfectly now. No issues at all. It might have been some bug with the config. Thanks anyway.
I'm trying to integrate the braintree sdk payment system into my app. I've done everything in the instructions (https://developers.braintreepayments.com/guides/drop-in/ios/v3) and I'm getting a strange error. Here's my code:
#IBAction func purchase(sender: AnyObject) {
let dropInViewController: BTDropInViewController = braintree!.dropInViewControllerWithDelegate(self)
dropInViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Cancel, target: self, action: Selector("userDidCancel"))
dropInViewController.summaryTitle = "Pass"
dropInViewController.summaryDescription = "Purchase the product"
dropInViewController.displayAmount = "$5"
var navigationController: UINavigationController = UINavigationController(rootViewController: dropInViewController)
self.presentViewController(navigationController, animated: true, completion: nil)
}
and here's the error I'm getting when I touch the button to show the Braintree Drop In View
2015-12-15 20:06:39.764 TheDiner[1169:22409] +[UIColor bt_colorWithBytesR:G:B:]: unrecognized selector sent to class 0x104e4abc8
2015-12-15 20:06:39.828 TheDiner[1169:22409] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIColor bt_colorWithBytesR:G:B:]: unrecognized selector sent to class 0x104e4abc8'
*** First throw call stack:
(
0 CoreFoundation 0x000000010565bc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001061dcbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000105662fad +[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001055b913c ___forwarding___ + 988
4 CoreFoundation 0x00000001055b8cd8 _CF_forwarding_prep_0 + 120
5 TheDiner 0x0000000103004f70 -[BTUI borderColor] + 64
6 TheDiner 0x0000000102fd8564 -[BTDropInContentView initWithFrame:] + 964
7 UIKit 0x00000001040d7393 -[UIView init] + 62
8 TheDiner 0x00000001030f794e -[BTUIThemedView init] + 62
9 TheDiner 0x0000000102fe0cb2 -[BTDropInViewController initWithClient:] + 226
10 TheDiner 0x0000000102fbfba1 -[Braintree dropInViewControllerWithDelegate:] + 209
11 TheDiner 0x0000000102fa9e7c _TFC8TheDiner22ZiftPassViewController16purchaseZiftPassfS0_FPSs9AnyObject_T_ + 572
12 TheDiner 0x0000000102faa206 _TToFC8TheDiner22ZiftPassViewController16purchaseZiftPassfS0_FPSs9AnyObject_T_ + 54
13 UIKit 0x0000000104075d62 -[UIApplication sendAction:to:from:forEvent:] + 75
14 UIKit 0x000000010418750a -[UIControl _sendActionsForEvents:withEvent:] + 467
15 UIKit 0x00000001041868d9 -[UIControl touchesEnded:withEvent:] + 522
16 UIKit 0x00000001040c2958 -[UIWindow _sendTouchesForEvent:] + 735
17 UIKit 0x00000001040c3282 -[UIWindow sendEvent:] + 682
18 UIKit 0x0000000104089541 -[UIApplication sendEvent:] + 246
19 UIKit 0x0000000104096cdc _UIApplicationHandleEventFromQueueEvent + 18265
20 UIKit 0x000000010407159c _UIApplicationHandleEventQueue + 2066
21 CoreFoundation 0x000000010558f431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 CoreFoundation 0x00000001055852fd __CFRunLoopDoSources0 + 269
23 CoreFoundation 0x0000000105584934 __CFRunLoopRun + 868
24 CoreFoundation 0x0000000105584366 CFRunLoopRunSpecific + 470
25 GraphicsServices 0x0000000107c0fa3e GSEventRunModal + 161
26 UIKit 0x00000001040748c0 UIApplicationMain + 1282
27 TheDiner 0x0000000102fbea37 main + 135
28 libdyld.dylib 0x000000010694d145 start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
I'm using Xcode 6 for ios8. I have the braintree header file in the bridging header.
#import <Braintree/Braintree.h>
#endif
Please point me in the right direction I've been stuck on this for a few hours. I'm thinking maybe I need to import another header in my bridge file but when I do it gives errors as well. Thanks
So the issue causing the crash is this:
5 TheDiner 0x0000000103004f70 -[BTUI borderColor] + 64
It appears that borderColor is a class method on BTUI, but that method calls +[UIColor bt_colorWithBytesR:G:B:], and the runtime can't find the implementation for +[UIColor bt_colorWithBytesR:G:B:]. This method is defined in UIColor+BTUI.h
Make sure you that you were able to import all of the headers for Brain Tree in the bridging header if you are using swift.
Try importing the header for the category file UIColor+BTUI.h manually in the bridging header and do a clean build and try again....
Updated Steps:
I got this to work, looks like something is messed up in your project file... I ran into the same problems you were having. But try these steps:
1) Create a new xcode project, (no need for bridged headers file).
2) Then change your podfile to:
use_frameworks!
pod 'Braintree', '~> 3.9'
then do a pod update
3)then at the top of your ViewController class add import Braintree then do a clean build