Swift: App terminating due to uncaught exception 'NSUnknownKeyException' - ios

I'm developing a simple game and I am having trouble when a particular UIViewController (called SPSwipes.swift) is loaded. On the screen, there are three buttons: 5, 10, and 25. When one is picked, a variable is set in that scene and the player moves on to the main Game: GameScene.swift.
As far as I am aware, the variables are recognised in the GameScene, but there is a 'NSUnknownKeyException' error when I open up the SPSwipes view in the simulator. This is done by way of a segue. Here is the error in more detail:
2014-11-09 15:32:43.718 Swipe Racer[2644:1620056] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Swipe_Racer.SPSwipes 0x7fbf52d461b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key fiveSwipes.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c021f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010dd1bbb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010c021b79 -[NSException raise] + 9
3 Foundation 0x000000010c4397b3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x000000010bf6be80 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x000000010cd28c7d -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x000000010cb87f98 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x000000010cb88588 -[UIViewController loadView] + 109
8 UIKit 0x000000010cb887f9 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x000000010cb88c8e -[UIViewController view] + 27
10 UIKit 0x000000010caa7ca9 -[UIWindow addRootViewControllerViewIfPossible] + 58
11 UIKit 0x000000010caa8041 -[UIWindow _setHidden:forced:] + 247
12 UIKit 0x000000010cab472c -[UIWindow makeKeyAndVisible] + 42
13 UIKit 0x000000010ca5f061 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2628
14 UIKit 0x000000010ca61d2c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1350
15 UIKit 0x000000010ca60bf2 -[UIApplication workspaceDidEndTransaction:] + 179
16 FrontBoardServices 0x000000011383b2a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
17 CoreFoundation 0x000000010bf5753c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
18 CoreFoundation 0x000000010bf4d285 __CFRunLoopDoBlocks + 341
19 CoreFoundation 0x000000010bf4d045 __CFRunLoopRun + 2389
20 CoreFoundation 0x000000010bf4c486 CFRunLoopRunSpecific + 470
21 UIKit 0x000000010ca60669 -[UIApplication _run] + 413
22 UIKit 0x000000010ca63420 UIApplicationMain + 1282
23 Swipe Racer 0x000000010be380de top_level_code + 78
24 Swipe Racer 0x000000010be3811a main + 42
25 libdyld.dylib 0x000000010e507145 start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
As you can see, there is an issue with my first variable, fiveSwipes (and I would imagine that there would be errors with the two others). What does 'this class is not key value coding-compliant for the key fiveSwipes' mean? How should I go about fixing it?
My SPSwipes.swift file:
class SPSwipes: UIViewController {
var no_of_swipes = 0
#IBAction func fiveSwipes(sender: AnyObject) {
no_of_swipes = 5
//and so on
}
Thank you in advance,
Will

The problem was that the button was linked to numerous IBActions - three of which didn't exist. I right clicked on the button in the Interface Builder and removed the old and irrelevant links, fixing the problem.

For me it was because I had multiple views connected to non existent IBOutlets
To get an idea how to find out:
1- Click on the whole view controller
2- go to : Show the connector Inspector
There you will find all the not connected outlets

The exception is happening when attempting to load the view based on what you set up in Interface Builder. It's looking for fiveSwipes and not finding it. This can happen if you edited your code and forgot to update a connection in IB.
Have you made a connection in IB to something called fiveSwipes that isn't this function? Perhaps a variable called fiveSwipes? The way to fix the problem would be to find the element with the bad connection in IB and clear that connection.

This is an old question, the other answers din't help to fix my issue so would like to leave this answer here might help other people.
Our app contains multiple "Targets" now it happens that the ViewController is pointing to specific target and only on that target this ViewController works. When running on other target the app crashes with this error.
So, for those who has multiple "Targets" be sure to check the "Module" in the "Identity Inspector" and make sure that the "Inherit Module From Target" is checked.

Another possible reason for this is if you are initializing your Controller using nibName:bundle: and you pass it the wrong nib name - some other nib that is not for this controller. The end result is the same, you'll likely have a bunch of #IBOutlets that do not match up between the Controller and the nib.

Related

How do I debug: libc++abi.dylib: terminating with uncaught exception of type NSException?

Sorry for asking this noob question, I know it has been asked thousands of times before, I know because I've had this problem thousands of times before. But this time google isn't helping.
The error / terminal print:
libc++abi.dylib: terminating with uncaught exception of type NSException
I generally know what type of situations cause this because I have had this issue in the past and it was quite simple to fix, usually a misnamed function or a broken link between some UI element and my code, but right now I have no idea what could be causing it.
What I have already tried:
I've added tonnes of breakpoints on the starting ViewController and it goes through all the #IBOutlets without throwing any issues. I've added breakpoints in all the methods in the AppDelegate and it doesn't break anywhere there. The code crashes before it reaches any viewDidLoad() methods. I've cleaned my project, restarted XCode a thousand times and even broken and re-made every link between UI and code. Renamed and then reassigned every #IBAction.
At this point I don't even know what I haven't tried. Every stackoverflow posts is always about the same thing "check broken links etc" but that just isn't helping anymore. I can't remember what it was that I changed because I changed so many small things before I started getting this error. I tried putting everything back but that didn't seem to help.
When the app crashes:
Right after "applicationDidBecomeActve()" is finished the debugger goes into a bunch of machine code, then the app crashes and I get this:
Proof of correct linking:
[Images removed as they were unneccessary]
My main question(s):
If linking is not the issue here, what else could it be?
About NSLogs/stack traces
I would love to provide some sort of NSLog or stack trace as I have seen people ask and give for on other questions but I have no idea how. I cannot find anything on the internet that isn't from the stone age on how to turn them on. And everything else is just how to use the debugger, but I am using the debugger and all I am getting are brief glimpses of my code in a see of machine instructions until it finally just crashes.
EDIT:
Apparently I can only get logs when running on an emulator instead of physical device. Here are the logs I get when running on emulator:
objc[40258]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x123242998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x123067d38). One of the two will be used. Which one is undefined.
2016-11-04 16:26:47.463 KotConnect[40258:1345011] Unknown class ProgressViewContainer in Interface Builder file.
2016-11-04 16:26:47.500 KotConnect[40258:1345011] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x7fbfe3c0a030> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loadingView.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001105ca34b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000011002b21e objc_exception_throw + 48
2 CoreFoundation 0x00000001105ca299 -[NSException raise] + 9
3 Foundation 0x000000010fb3b26f -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
4 UIKit 0x0000000110e0580d -[UIView(CALayerDelegate) setValue:forKey:] + 173
5 UIKit 0x000000011114f79e -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000011056f590 -[NSArray makeObjectsPerformSelector:] + 256
7 UIKit 0x000000011114e122 -[UINib instantiateWithOwner:options:] + 1867
8 UIKit 0x0000000110ee1c21 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
9 UIKit 0x0000000110ee2543 -[UIViewController loadView] + 177
10 UIKit 0x0000000110ee2878 -[UIViewController loadViewIfRequired] + 201
11 UIKit 0x0000000110f2307b -[UINavigationController _layoutViewController:] + 55
12 UIKit 0x0000000110f23963 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 471
13 UIKit 0x0000000110f23ada -[UINavigationController _startTransition:fromViewController:toViewController:] + 133
14 UIKit 0x0000000110f24ce5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 874
15 UIKit 0x0000000110f25dc7 -[UINavigationController __viewWillLayoutSubviews] + 58
16 UIKit 0x000000011111cd6f -[UILayoutContainerView layoutSubviews] + 223
17 UIKit 0x0000000110e05f50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
18 QuartzCore 0x0000000110ac3cc4 -[CALayer layoutSublayers] + 146
19 QuartzCore 0x0000000110ab7788 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
20 QuartzCore 0x0000000110ab7606 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
21 QuartzCore 0x0000000110a45680 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
22 QuartzCore 0x0000000110a72767 _ZN2CA11Transaction6commitEv + 475
23 QuartzCore 0x0000000110a730d7 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
24 CoreFoundation 0x000000011056ee17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
25 CoreFoundation 0x000000011056ed87 __CFRunLoopDoObservers + 391
26 CoreFoundation 0x00000001105534b6 CFRunLoopRunSpecific + 454
27 UIKit 0x0000000110d3b7e6 -[UIApplication _run] + 434
28 UIKit 0x0000000110d41964 UIApplicationMain + 159
29 KotConnect 0x000000010d52cc8f main + 111
30 libdyld.dylib 0x00000001135c968d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Swift
Just add
NSSetUncaughtExceptionHandler { exception in
print(exception)
print(exception.callStackSymbols)
}
at the bottom of didFinishLaunchingWithOptions method of AppDelegate. It will give you the better info about the exception occurred.
Happy coding !
Once I was able to see my app log I could see my custom class was not being found. I'll leave the fix I found for this issue for any people who have this issue in the future:
Xcode 6 Strange Bug: Unknown class in Interface Builder file
This happened to me when I accidentaly removed one of my storyboards from my targets. Make sure to double check your Target Membership.

App crashes using Facebook Login SDK when I go to the home screen

I originally downloaded the FBSDK's version 4.10 and integrated them into my application by placing them in the frameworks folder. Realizing that these would not get updated over time, I removed them completely and tried to add them as pods to my project. The pods installed successfully, I have imported them correctly in my bridging header file, and there were no other issues. The pods update installed version 4.11 which has caused me some headache.
I am using the FBSDKLoginKit to log a user into their account and retrieve information from that. I am able to get back a dictionary with the users information just fine. I then pass this information to the next ViewController with a segue. At any point after this, if I press the home button on my iPhone or simulator, the app will crash. The error I get is
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]:
attempt to insert nil object from objects[3]'
This exception also occurs if I let the user log in through facebook, segue to the new view controller, unwind to the previous view controller, and then attempt to log in again. I have attempted to log the user out once retrieving their pertinent information on the second screen, but the error still persists.
I have seen a similar question asked where the "solution" was that the FBSDKLoginKit writes the retrieved dictionary to a variable and if the dictionary it has retrieved back has nil values, it throws this error.
Is there anything I can do to catch this before it happens? Has anyone found a work around?
Here is my output from the simulator when I press home:
*** First throw call stack:
(
0 CoreFoundation 0x0000000106f03d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010643edeb objc_exception_throw + 48
2 CoreFoundation 0x0000000106e0023e -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 318
3 CoreFoundation 0x0000000106e125bb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
4 APPNAME 0x0000000101607a1e -[FBSDKTimeSpentData instanceSuspend] + 622
5 APPNAME 0x000000010160766b +[FBSDKTimeSpentData suspend] + 59
6 APPNAME 0x00000001015b5986 -[FBSDKAppEvents applicationMovingFromActiveStateOrTerminating] + 262
7 CoreFoundation 0x0000000106ecdc8c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
8 CoreFoundation 0x0000000106ecd9cb _CFXRegistrationPost + 427
9 CoreFoundation 0x0000000106ecd732 ___CFXNotificationPost_block_invoke + 50
10 CoreFoundation 0x0000000106f161e2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1986
11 CoreFoundation 0x0000000106dc5679 _CFXNotificationPost + 633
12 Foundation 0x000000010372ccd9 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
13 UIKit 0x0000000104a685ad -[UIApplication _deactivateForReason:notify:] + 629
14 UIKit 0x0000000104a6f1f1 __61-[UIApplication _sceneSettingsPreLifecycleEventDiffInspector]_block_invoke + 104
15 FrontBoardServices 0x0000000108f88d6c __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke27 + 213
16 Foundation 0x000000010377d5bb __NSIndexSetEnumerate + 1016
17 BaseBoard 0x000000010901ba8c -[BSSettingsDiff inspectChangesWithBlock:] + 116
18 FrontBoardServices 0x0000000108f83e4a -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 92
19 FrontBoardServices 0x0000000108f88b2f -[FBSSettingsDiffInspector inspectDiff:withContext:] + 317
20 UIKit 0x0000000104a70880 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 127
21 UIKit 0x0000000104a7052d -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 843
22 FrontBoardServices 0x0000000108f978c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
23 FrontBoardServices 0x0000000108f97741 -[FBSSerialQueue _performNext] + 178
24 FrontBoardServices 0x0000000108f97aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
25 CoreFoundation 0x0000000106e29301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
26 CoreFoundation 0x0000000106e1f22c __CFRunLoopDoSources0 + 556
27 CoreFoundation 0x0000000106e1e6e3 __CFRunLoopRun + 867
28 CoreFoundation 0x0000000106e1e0f8 CFRunLoopRunSpecific + 488
29 GraphicsServices 0x0000000108ae7ad2 GSEventRunModal + 161
30 UIKit 0x0000000104a72f09 UIApplicationMain + 171
31 APPNAME 0x00000001013a26d2 main + 114
32 libdyld.dylib 0x0000000107b0d92d start + 1
33 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Running my code step by step I find that the error occurs during the method:
fbLoginManager.logInWithReadPermissions(permissionsNeeded, fromViewController: self) { (result, error) -> Void in
//crashes before it enters this block
//my code here
}
It crashes before I can even check the error value. I will attempt to check the values by stepping into the fbsdk methods and update
As soon as I press OK on this screen for the second time it crashes. How can I debug this? The action isn't in my app, its in the browser so I'm not sure where to go from here..
I have came across this issues recently, and i solved it by adding this piece of code in Appdelegate.m.
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
For Swift 3 version:
func applicationDidBecomeActive(_ application: UIApplication) {
FBSDKAppEvents.activateApp()
}
Update to 4.12, it fixes the issue according to their release notes:
https://developers.facebook.com/docs/ios/change-log-4.x/
The part that says:
Fixed
Fixed cases where AppEvents could crash because of missing session id.
Fixed bug in some cases where access token expiration date was the refresh date.
Although this is not necessarily a comprehensive solution, I have exhausted my debugging methods. I have removed the FBSDK's from my podfile, run pod update to remove them from the project, and reinstalled the version 4.10 FBSDK's in my frameworks folder. I will update this question after trying again when facebook releases an updated version of the FBSDK's.

Bridging an ObjC project with the SalesForce SDK causes a crash due to inability to find a category in the SF SDK

I have an iOS project called Core.proj that includes the SalesForce SDK and it is written in Objective-C. This project utilises the SF SDK and links the binary to the SF libraries. It does a bunch of stuff to help manage my implementation of SF. It is included in all my other Obj-C projects and it works absolutely fine within them.
This is the first time I am using this project with Swift (2.1). I am using iOS 9 with Xcode 7.1.1. I added the Core.xcodeproj into my Swift project. I then created an ObjC file. Xcode then asks if I want to create a bridging header. I do. I have created a bridging header called Swift-Bridging-Header.h. This enables me to access the files in Core.xcodeproj via the bridging header. For example, I can access my own version of the Salesforce Authentication Manager from the bridging header.
In my app delegate, I want to now kick off OAuth (I'm keeping this minimal here):
let sharedManager = MyAuthenticationManager.sharedManager()
let successBlock: OAuthFlowSuccessCallbackBlock = { sfAuthInfo in }
let failureBlock: OAuthFlowFailureCallbackBlock = { sfAuthInfo in }
sharedManager.loginWithCompletion(successBlock, failure: failureBlock)
Full disclosure: each block that you see here takes the SFOAuthInfo object as an argument. In order to get Swift to read this block, I had to add SFOAuthInfo.h into the copy files.
Now this all compiles fine but when I tap to login and execute the above code, I get the following error:
2015-12-04 11:53:54.879 MyApp[19108:3494140] -[UIDevice macaddress]: unrecognized selector sent to instance 0x7fcfb4903230
2015-12-04 11:53:54.890 MyApp[19108:3494140] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIDevice macaddress]: unrecognized selector sent to instance 0x7fcfb4903230'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d6adf65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010f624deb objc_exception_throw + 48
2 CoreFoundation 0x000000010d6b658d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010d603f7a ___forwarding___ + 970
4 CoreFoundation 0x000000010d603b28 _CF_forwarding_prep_0 + 120
5 MyApp 0x000000010c869317 -[SFOAuthCredentials keyMacForService:] + 84
6 MyApp 0x000000010c8696b8 -[SFOAuthCredentials updateTokenEncryption] + 210
7 MyApp 0x000000010c8673ee -[SFOAuthCredentials initWithIdentifier:clientId:encrypted:] + 211
8 MyApp 0x000000010c84102c -[SFUserAccount initWithIdentifier:] + 197
9 MyApp 0x000000010c85f32d -[SFUserAccountManager createUserAccount] + 91
10 MyApp 0x000000010c831b41 -[SFAuthenticationManager loginWithCompletion:failure:account:] + 284
11 MyApp 0x000000010c831a0b -[SFAuthenticationManager loginWithCompletion:failure:] + 53
12 MyApp 0x000000010c60440c -[MyAuthenticationManager loginWithCompletion:failure:] + 124
13 MyApp 0x000000010c5dc58f _TFC18MyApp11AppDelegate5loginfS0_FT_T_ + 911
14 MyApp 0x000000010c5dfdc4 _TFC18MyApp25LandingPageViewController17loginButtonTappedfS0_FPSs9AnyObject_T_ + 68
15 MyApp 0x000000010c5dfe16 _TToFC18MyApp25LandingPageViewController17loginButtonTappedfS0_FPSs9AnyObject_T_ + 54
16 UIKit 0x000000010e1af1fa -[UIApplication sendAction:to:from:forEvent:] + 92
17 UIKit 0x000000010e313504 -[UIControl sendAction:to:forEvent:] + 67
18 UIKit 0x000000010e3137d0 -[UIControl _sendActionsForEvents:withEvent:] + 311
19 UIKit 0x000000010e312906 -[UIControl touchesEnded:withEvent:] + 601
20 UIKit 0x000000010e219aa3 -[UIWindow _sendTouchesForEvent:] + 835
21 UIKit 0x000000010e21a691 -[UIWindow sendEvent:] + 865
22 UIKit 0x000000010e1cc752 -[UIApplication sendEvent:] + 263
23 UIKit 0x000000010e1a7fcc _UIApplicationHandleEventQueue + 6693
24 CoreFoundation 0x000000010d5da0a1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
25 CoreFoundation 0x000000010d5cffcc __CFRunLoopDoSources0 + 556
26 CoreFoundation 0x000000010d5cf483 __CFRunLoopRun + 867
27 CoreFoundation 0x000000010d5cee98 CFRunLoopRunSpecific + 488
28 GraphicsServices 0x0000000113e46ad2 GSEventRunModal + 161
29 UIKit 0x000000010e1ad676 UIApplicationMain + 171
30 MyApp 0x000000010c5ddd8d main + 109
31 libdyld.dylib 0x00000001107a592d start + 1
32 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The SF SDK has a category called UIDevice+SFHardware.h. Within this category there is a method called 'macaddress'. So clearly it is not correctly reading this category. But why? As you can see from the stack trace it is reading the other files in the SF SDK correctly.
I tried a number of things to get this to work. For example, this: iOS - UUID generation throwing a strange exception but with UIDevice+SFHardware.h. I tried this: https://developer.salesforce.com/forums/?id=906F00000009CBvIAM. I completely rebuilt the project again to check my working.
I shouldn't need to add this file into my bridge as this UIDevice+SFHardware.h is only ever accessed from SF SDK which sits within an ObjC project.
I must have done something wrong though. Any help would be greatly appreciated.
I just went through this issue.
In your Project > Build Settings > Other Linker Flags add:
-ObjC
-all_load
My SalesforceSDK is in my Pod project. If you're doing the same, set those flags in your SalesforceMobileSDK-iOS project. If not, wherever the Salesforce SDK is getting compiled.
It turns out this was a combination of things. Firstly, I was missing the -ObjC linker flag in BOTH the Swift project and the Objc project. Thanks DarthVadar123451 for pointing that out. But I also realised I was missing two libraries: libz.dylib and libxml2.dylib. Once added, everything worked. I hope that helps anyone running into the same issue.

Twitter Login initialization via Parse not working: Swift

[Xcode V.7.0 Beta 6, OSX El Capitan, iOS9]
I'm trying to add the Twitter login using the latest version of the Parse SDK. I've tried several ways of integrating the Twitter Login with Parse but its not working. I've added my consumerkey/secret and it says that I need to initialize PFTwitterUtils which I have done.
You must call PFTwitterUtils initializeWithConsumerKey:consumerSecret: to use PFTwitterUtils" I posted the full error below as well as my github repository.
At the moment I didn't add the ParseTwitterUtils framework because it didn't say i needed to in the QuickStart guide on Parse.com. However, when I add the module I get a linker error. When i take it out, i get the error below.
Steps I took:
At first, I was having an issue with the PFTwitterUtils module not appearing or being recognized. I built the project adding the frameworks in this link: https://www.parse.com/apps/quickstart?app_id=discounts--6#parse_data/mobile/ios/swift/existing and using the SDK here: https://www.parse.com/apps/quickstart?app_id=fblogin--81#parse_data/mobile/ios/swift/existing
(similar problem to this link: No such module 'Parse' following Parse iOS Swift Quickstart guide)
I posted the issue on github, thinking it's a bug on their end:
https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/407
I was advised to check the Framework Search Path to see if the module lives inside the folder the search path is directing to. It looked good, but it still didn't work so I also tried adding another path to the ParseSDK and that also didn't work.
I then took a Parse-Starter-project from another source where the PFTwitterUtils worked (my github repository is below with the new frameworks) but then I get the error I mentioned below. I'm assuming this is the better way of going about it because now the PFTwitterUtils is recognized within Xcode but not when building the project. I also checked the callback URL when making an app on twitter. I found a stack overflow question that had a problem with the callback URL. I edited that as well and it still doesn't work.
Here is the error I'm getting:
2015-10-14 13:13:18.374 ParseStarterProject[3757:390022] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You must call PFTwitterUtils initializeWithConsumerKey:consumerSecret: to use PFTwitterUtils.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f9849b5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000111927deb objc_exception_throw + 48
2 CoreFoundation 0x000000010f9848ed +[NSException raise:format:] + 205
3 ParseStarterProject 0x000000010eddcd7e +[PFTwitterUtils logInInBackground] + 31
4 ParseStarterProject 0x000000010eddce30 +[PFTwitterUtils logInWithBlock:] + 48
5 ParseStarterProject 0x000000010edca6b1 _TFC19ParseStarterProject14ViewController11viewDidLoadfS0_FT_T_ + 417
6 ParseStarterProject 0x000000010edca8c2 _TToFC19ParseStarterProject14ViewController11viewDidLoadfS0_FT_T_ + 34
7 UIKit 0x00000001106cbd05 -[UIViewController loadViewIfRequired] + 877
8 UIKit 0x00000001106cc054 -[UIViewController view] + 27
9 UIKit 0x00000001105ab77c -[UIWindow addRootViewControllerViewIfPossible] + 61
10 UIKit 0x00000001105abe79 -[UIWindow _setHidden:forced:] + 302
11 UIKit 0x00000001105bd6dc -[UIWindow makeKeyAndVisible] + 43
12 UIKit 0x000000011053dd13 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4003
13 UIKit 0x000000011054413d -[UIApplication _runWithMainScene:transitionContext:completion:] + 1755
14 UIKit 0x0000000110541390 -[UIApplication workspaceDidEndTransaction:] + 188
15 FrontBoardServices 0x00000001193b57ac -[FBSSerialQueue _performNext] + 192
16 FrontBoardServices 0x00000001193b5b1a -[FBSSerialQueue _performNextFromRunLoopSource] + 45
17 CoreFoundation 0x000000010f8b0b21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
18 CoreFoundation 0x000000010f8a6a4c __CFRunLoopDoSources0 + 556
19 CoreFoundation 0x000000010f8a5f03 __CFRunLoopRun + 867
20 CoreFoundation 0x000000010f8a5918 CFRunLoopRunSpecific + 488
21 UIKit 0x0000000110540d2d -[UIApplication _run] + 402
22 UIKit 0x000000011054599e UIApplicationMain + 171
23 ParseStarterProject 0x000000010edcce6d main + 109
24 libdyld.dylib 0x0000000116bed92d start + 1
25 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
//
In the repository the ParseTwitterUtils.framework module isn't there. But once I import it I get a linker error.
Could it be that i'm missing a Framework Search Path? When i add the Framework Search Path where the frameworks live, it doesn't change anything. Any ideas of how to add the TwitterSDK with Parse with the current SDKs I'm using?
Here's the link to my repository. https://github.com/rinyfo4/ParseStarterProject-2/tree/c512acb4360d45927f0cc5b34505d3caacae728c
Any help means a lot. Thank you in advance.
Please let me know if I can provide more information.
I solved it. As i mentioned, I went to github and was helped.
This is the answer to what was going on:
According to this guide, to enable authentication with Twitter - you need to call PFTwitterUtils.initializeWithConsumerKey:consumerSecret:
The exception is being thrown about the fact that you simply didn't initialize the twitter utils, so there is no need to unlink/remove ParseTwitterUtils from Cocoapods.
pod 'ParseTwitterUtils' and ParseTwitterUtils.framework are mutually exclusive, as they are absolutely the same thing, with the only difference on how you install them.
Here is the solution: I needed to edit my AppDelegate didFinishLaunchingWithOptions method to reflect the following:
`Parse.enableLocalDatastore()
Parse.setApplicationId("...",
clientKey: "...")
PFTwitterUtils.initializeWithConsumerKey("...", consumerSecret:"...")`
Hope this helps whoever has this problem in the future.

Could not find a storyboard named

I have problem when I try to launch my app in iOS simulator,
I need someone to fix this please, I have tried everything but still I have the same problem
I got this error :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'MainStoryboard_iPhone.storyboard' in bundle NSBundle </Users/iYousef911/Library/Application Support/iPhone Simulator/7.1/Applications/F00ED8C4-145B-43C0-ACDA-C41EDC01D824/Azkar.app> (loaded)'
*** First throw call stack:
(
0 CoreFoundation 0x029c21e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x027418e5 objc_exception_throw + 44
2 UIKit 0x01965400 -[UIStoryboard name] + 0
3 UIKit 0x01401692 -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 53
4 UIKit 0x01401949 -[UIApplication _loadMainInterfaceFile] + 245
5 UIKit 0x0140054e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
6 UIKit 0x01414f92 -[UIApplication handleEvent:withNewEvent:] + 3517
7 UIKit 0x01415555 -[UIApplication sendEvent:] + 85
8 UIKit 0x01402250 _UIApplicationHandleEvent + 683
9 GraphicsServices 0x03d21f02 _PurpleEventCallback + 776
10 GraphicsServices 0x03d21a0d PurpleEventCallback + 46
11 CoreFoundation 0x0293dca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
12 CoreFoundation 0x0293d9db __CFRunLoopDoSource1 + 523
13 CoreFoundation 0x0296868c __CFRunLoopRun + 2156
14 CoreFoundation 0x029679d3 CFRunLoopRunSpecific + 467
15 CoreFoundation 0x029677eb CFRunLoopRunInMode + 123
16 UIKit 0x013ffd9c -[UIApplication _run] + 840
17 UIKit 0x01401f9b UIApplicationMain + 1225
18 Azkar 0x00002a4d main + 141
19 libdyld.dylib 0x0325f701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
This may be due to different reasons. Check the below:
Check the spelling of your storyboard name. Maybe it is different or capital letters may be different
Check your bundle resources contain this storyboard from by selecting Target->Build Phases->Copy Bundle Resources. If not add it by the below plus button.
Delete your app from the iOS Simulator. Then reinstall the app.
Try to rename the storyboard and apply same name in Main storyboard file base name in your application plist file.
I know this is an old post but just in case someone wanders in here with a similar problem. My issue was we have over a dozen targets and I was not selecting them when I created the SB.
In the left hand column, under File Inspector, make sure you check the membership that the file should belong to.
In info.plist please check if values for properties UISceneStoryboardFile and UIMainStoryboardFile are correct
<key>UISceneStoryboardFile</key>
<string>[MY_PROJECT_NAME]</string>
and
<key>UIMainStoryboardFile</key>
<string>[MY_PROJECT_NAME]</string>
In my case, I accidentally mistype the name of the storyboard……
The cache is messing up everything...run this on your terminal and make sure everything inside gets cleaned up...
sudo rm -rf $HOME/Library/Developer/Xcode/DerivedData/
I have this problem but it it fixed by. there is storyboard name problem. I have my all View Controllers in Main.storyboard so there the name is "Main" and after this, write the storyboard Identifier.

Resources