Xcode Swift app does not start after changing folder structure - swift

I'm new to swift and trying to create a basic app with Firebase. But when i tried to build and run the app on simulator, i get the following error:
Application launch for 'com.example.SnapchatClone' did not return a valid pid nor a launch error.
Domain: NSPOSIXErrorDomain
Code: 3
Failure Reason: No such process
User Info: {
DVTErrorCreationDateKey = "2022-12-19 18:25:55 +0000";
IDERunOperationFailingWorker = IDELaunchiPhoneSimulatorLauncher;
}
I'm not sure about the reason but I have relocated some files, like AppDelegate.swift and SceneDelegate.swift to Delegates folder, and View Controller files to ViewControllers folder.
I have tried to changed the DelegateClassName to '$(PRODUCT_MODULE_NAME).Delegate.SceneDelegate', clean and build again, restart the mac, adding a UIWindow definition to AppDelegate class. Nothing changes.
Can someone explain the error message and offer a solution?

Related

XPC connection interrupted in Xcode 7 for iOS 9

I recently updated to Xcode 7 and upgraded my iPhone to iOS 9. I have developed and released an iOS app that had worked perfectly fine on the latest version of iOS 8 and Xcode 6.
Upon trying to go through the process of updated the app for iOS 9 support, I am getting the most ridiculously strange error that has left me baffled.
I have done all the syntax corrections automatically through Xcode, and now my app builds properly. It even runs fine at first.
I have a button that segues to a view controller with a WebView. This view controller loads a link that will display either an image, website, or video from youtube. The content is loaded perfectly fine as always. However, the program will crash and reboot the simulator (and my iPhone) and send me to the lock screen when I click the Back button (I am on a navigation stack).
In Xcode, I get the following messages:
XPC Connection Interrupted.
Terminating since there is no system app.
I have Flurry analytics integrated in my app by the way, not sure if thats an issue.
How can I fix this issue? My searches for XPC connections do not seem to return problems similar to mine. I do not even have a clue what an XPC connection is, so why is this in my app anyway?
EDIT: I have found a workaround for the issue. I cannot really say it is a fix.
The crashing was occurring during the use of the method self.navigationController?.popViewControllerAnimated, when set to true. I happened to set this to false, and the crashing stops (now the transition looks awful).
I do not know why this works, and just adds to my confusion.
The problem lied in the storyboard for me as well. I created a new project and laid out the views and everything seemed to be working fine. I found these couple lines in the storyboard source (right click on storyboard and select view as -> source code) which weren't common between the working version and the broken version:
<keyCommands>
<keyCommand/>
</keyCommands>
I have no idea what those lines are supposed to do, or how they crept into my storyboard file, but they were what was crashing the app so hard that the phone had to restart. I removed those lines from my main project and everything worked again.
This error can be caused by executing a loop repeatedly. In my case it was a 'for' loop in which I reset the counting variable. As soon as I added an NSLog in the loop it was obvious.
I just faced the same problem. I don't know if that will help you, but I also think it's coming from the Storyboard:
In my case, the problem is coming from a UITextView. Whenever I try to change the default text inside it, I have this error. If I let the default text or leave it empty, the app works fine. Making an IBOutlet and changing the text programmatically works as well.
I tried with other UI elements, but only the UITextView seems to have this issue.
I have struggled with exact same error. Through a process of elimination I established that it had nothing to do with the any class but had to do with the storyboard. Luckily I keep regular backup copies and I tried to compare storyboards to establish what I had done - but could find nothing obvious.
The backup copy worked fine and I was able to copy my controller classes (from the faulty copy with the changes) into the backup copy and they worked fine.
I think there is a bug possibly in storyboards.
I have same error message when I place a subview in -layoutSubviews method:
-(void)layoutSubviews
{
[super layoutSubviews];
[self populateByImageViews];
}
It causes infinite cycle of layout process and crashes app. Don't place subviews in this place!
Deleting UITextView from the one of the view in Storybord removes the error in my case.
In valueChanged: method of a UIControl, I had the same problem
so I made the code inside valueChanged: to run in main thread and it solved the problem.
#IBAction func valueChanged(sender: AnyObject) {
dispatch_async(dispatch_get_main_queue(), {
//code
}
}
For me was some missing constraints with a UISearchBar, but the error was only in the simulator.
I only add some constraints and works better
For me it was xcode live issues caused by IB_DESIGNABLE
If you have any IB_DESIGNABLE in source files, the system's live tracker will check for issues in StoryBoard too. It may leads to unnecessary building.
To disable it-
Open Storyboard file. Editor -> Automatically Refresh Views (Uncheck)
If you needs to Disable Live issue tracking
XCode -> Preferences -> General -> Issues -> Uncheck Live Issues
Reference
My issue probably originated with some storyboard issue, but I cleaned the project, restarted Xcode AND restarted the simulator app and that fixed it.
When using QLPreviewController, I am confronted with this problem. Error messages as follows,
XPC connection interrupted
_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) invalid name (15)
Since XPC means OS X interprocess communication, so I think this can solve the problem, especial when updating the UI
dispatch_async(dispatch_get_main_queue(), ^{
// do what you want to do.
});
For Swift 4+, user
DispatchQueue.main.async {
//Your Code
}

NSInternalInconsistencyException uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: NSBundle with name

I'm having a strange error in my iOS app. Everything was working well since yesterday and today I made some improvements on a view controller that has nothing to do with the AppDelegate and when I tried to test the changes I've made on the simulator, I got this error :
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in
bundle: 'NSBundle
(loaded)' with name 'xxx'
I searched a lot in Google and this website to try to find a solution, and all the topics I found were talking about problems with xib files. However, I'm using Storyboards and my app is iOS6.1 only so I have no xib files ... I also checked that the storyboard was included in "Build Phases" and everything seems right :s. I know that this error could happen when some files were included in the Finder but not in Xcode, however that's not the case for me: I always included the files directly in Xcode and checked the "copy files to directory" option. I even tried to revert the changes I made, and I still have this issue so I really don't know what is going on. My app is really simple at this stage, I just have a couple of view controllers connected through a navigation controller and 1 external framework (AFNetworking). My AppDelegate (where the error seems to happen) is clean: I didn't add anything to the sample code that was provided by Xcode.
I'm really stuck with this issue and I hope you could find a way to help me solve it.
First, try using the Xcode/Product/Clean menu item. If that doesn't do it then go to the Organizer, switch to Projects, and delete the Derived folder for your project. If you do the second, quit Xcode and start again just to be sure all is wiped.
EDIT: if you want, zip the thing up, and send it to my email address in my profile. I can only spend a few minutes with it but will at least take a look.
EDIT2: learned a few things here, but no fix. What you are seeing is that the StoryBoard is trying to product the rootViewController, and fails - the app delegate never even gets messaged. The EventsTVC class gets sent initWithCoder:, and then later is asked for its nibName, which it returns. This nibName is an identifier into the storyboard - and is what internally Apple must be using to construct a nib. However, that fails. You can see the name by adding this to EventsTVC:
- (NSString *)nibName
{
NSLog(#"NIB NAME %#", [super nibName]);
}
What I did to reproduce the problem was create a new StoryBoard Master/Detail app, and add this to the rootviewcontroller:
- (NSString *)nibName
{
NSLog(#"NIB NAME %#", [super nibName]);
return [[super nibName] stringByAppendingString:#"foo"];
}
This of course makes the nibName bogus, and it causes the app to fail where yours does, with the same message.
You have two choices: you can burn a DTS incident on this - see if you can get Apple to fix it (might take a few days), or you can just redo the project, and copy as much of what you can back into the new App.
In any case it would be really great if you could send the same zip file to Apple and create a bug report on it. I suspect that the storyboard is corrupt internally, but there are no public methods to use to delve into it (look at UIStoryBoard).
Since ios7 and Xcode 5, it does this to me every morning ! I don't know what kind of mess they did in xcode but it's annoying. If you want to pass this bug, go to organizer, then delete the "derived data" (if somehow it doesn't want to delete, go delete it in terminal with a good old rm -rf), then run you app, it will crash again, this time go to you simulator and click on reset settings and everything. Now run your App again your done :) !

"Could not load NIB in bundle" error on iPhone but not on Simulator

Up until yesterday I had a perfectly working app on my iPhone. I made a few tweaks yesterday and now the app works on my simulator but not on the iPhone. The error message I am getting is right after the "applicationDidFinishLaunching" finishes.
The error is:
'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle ....> (loaded)' with name 'RootViewController''"
The weird thing is, I don't have any xib files called RootViewController. I renamed mine a month ago to CategoryViewController and this has worked fine up until yesterday. I verified in each of my viewControllers that there is no reference to a "RootViewController".
I searched with "CTRL+shift+F" "RootViewController" and there is no file in my project that mentions this.
The tweaking I was doing had to do with the target info.plist and I only added the Application supports iTunes file sharing option. Here is my info.plist in case I messed something up:
I also had run "Clean" for the first time yesterday.
I verified that my MainWindow.xib file has all the connections it is supposed to have and compared this against the original sample project I used as a base.
I tried reverting the project back to an earlier snapshot when I am positive it worked and now that doesn't even work. It seems my iPhone bundle got corrupt. But it does the same thing even after I delete the app from my iPhone and try again.
How do I go about debugging this? I have spent 10 hours already trying to fix this and really need some help.
The Xcode templates create an Info.plist file that specifies the main nib file.
-The default nib name is "MainWindow".
-The default version of that nib file contains a Navigation controller that references a view named "RootViewController".
However, each of those can have variations for iPhone or iPad. Those files have ~iphone or ~ipad added to the end. They system will pick the variation automatically by suffix.
You could have gotten a different nib file for that reason which tried to load RootViewController.
Also, if you have a view or view controller inside your nib that references RootViewController, the OS will try to load it. (It instantiates almost everything in a nib file once it is opened.)
This was resolved by refactoring and renaming my first viewController back to RootViewController. The moral of the story is do not change the name of the RootViewController. There are built in references to it that are not easily changed. There is no real need to use a different name. Once I did this, everything worked again.

Error on empty project: "this class is not key value coding-compliant for the viewcontroller."

this error drives me crazy. I already spent hours on fixing this, unfortunately without success.
I tested my app in simulator, everything works fine. I'am testing it on my device (iphone 4 with ios 4.3.3) the app won't start.
So I tried creating a new project, build and go. And the end of the error now says instead of viewcontroller, key window.
To get further information about the error I setup an exeption breakpoint whicht breaks on throw and on all exeptions. Something interesting happend now: when I am launching the empty project on my iphone I get a warning:
warning: Unable to read symbols for /Users/xxx/Library/Developer/Xcode/DerivedData/testing-cmaekkzgdqyseidlqkorvrdvvodg/Build/Products/Debug-iphoneos/OLDAPP.app/testing (file not found). (The app which I am runnning is called testapp, not OLDAPP?! This was my last project!)
Some further errors now occure:
Unknown class OLDAPPAppDelegate in Interface Builder file. and Unknown class RootViewController in Interface Builder file.
I did clean all targets and made a clean build. Nothing changes…
I didn't change anything in IB, just edited the provisioning profile to run the app on my phone.
Help is very appreciated here :-) Hopefully someone can help me I would be really thankful.
The whole error message: *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UICustomObject 0x18b410> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key window.'
This happens to me if I change the name of an outlet on the ViewController which was connected to something in the View in Interface Builder. For example, renaming 'labelFirstName' to 'lblFirstName' and forgetting to break and recreate the connection in IB.
I had the same problem where there were no !'s in my XIB and no re-naming problems. To fix it, I just created a new XIB, copied in the view from the old XIB, and rewired all the connections.

IPhone App Build Successful But nothing shows

Very new to Iphone development here, I have a project which is successfully building (which is a first for me :) It loads the simulator but it just closes as soon as it loads, how can I debug this? It appears the Interface Builder xib files are not loading, I've added a xib thats from a hello world project, (they have different project names) Is this an issue?
Any advice would help,
Thanks!
You probably have an error in the Debugger Console. If it has to do with the XIB, it could be that you simply got the name wrong.
Another simple mistake is trying to use Outlets before viewDidLoad is called (for instance, in init).
In either case -- the message in the console will help.