Just hit a problem where I need to work with a external framework and bundle.
While the frame is imported and its functions can be called just fine, one of it's methods tries to load a nib from the accompanying bundle, which ends in a NSInternalInconsistencyException for the reason
"Could not load NIB in bundle".
I noticed that while the bundle is in the Copy Bundle Resources and can be found by calling Bundle.allBundles, the error message says the bundle is "not yet loaded". Is there something I was supposed to do so the bundle could be loaded beforehand?
Update: I did not provide the related code earlier because the error happened as a colateral effect of a framework call, so I don't know exactly how the nib is "loaded".
The code itself is this:
if let request = AUTRequest.init(transactionType: .debitGeneric) {
AUTCTFClient.executeTransaction(with: request, from: self) { (_response) in
if let response = _response {
print(response)
}
}
}
self is the current viewcontroller and the error happens after the executeTransaction call but before the response block execution.
Is this somehow related to the Bundle not being loaded or is the framework at fault himself?
If you are using code do load the nib, you need to make sure you are loading it from the correct bundle:
let bundle = Bundle(for: ClassName.self)
let view = bundle.loadNibNamed("nib_name", owner: nil, options: nil)![0]
If you are using storyboard, please make sure to select to correct Module (the framework). You can select module in the Identity Inspector (in interface builder press cmd+alt+3).
After trying to find solutions for a while, the most obvious answer is that the framework in question was compiled with missing files, that the "AUTCTFClient.executeTransaction" tries to call in its execution. This point is "confirmed" by older versions of the framework showing some kind of progress view on execution. (but sadly they were not usable in our case)
If you somehow got this problem, it'll probably be best to ask the owners(or search) for an updated or stable version of their framework.
Related
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?
I am trying to implement UI testing with BDD using Cucumberish framework.
I understand quite well the Feature files parsing system and I managed to tests some UI elements of the main screen.
However I would like to load any controller from storyboard before using UI testing on the corresponding screen.
Here is my initialization code:
#objc class CucumberishSwiftInit: NSObject {
#objc class func CucumberishSwiftInit()
{
var application : XCUIApplication!
//A closure that will be executed just before executing any of your features
beforeStart { () -> Void in
application = XCUIApplication()
}
//A Given step definition
Given("the app is running") { (args, userInfo) -> Void in
application.launch()
let bundle = Bundle.main
// I double checked the storyboard name and I can access it in my Unit Tests target
// application crashes here
let storyboard = UIStoryboard(name: "Main", bundle: bundle)
// never executed
Swift.print("storyboard \(storyboard)")
}
let bundle = Bundle(for: CucumberishSwiftInit.self)
Cucumberish.executeFeatures(inDirectory: "Features", from: bundle, includeTags: nil, excludeTags: ["skip"])
}
}
Some feature file:
#run #welcome
Feature: Some feature
Some feature desc
Scenario: Can load screen
Given the app is running
...
The application crashed on the UIStoryboard init statement, caught "NSInvalidArgumentException", "Could not find a storyboard named 'Main' in bundle NSBundle (loaded). I have no clue why as it is working using with my unit tests.
The error you're getting is due to the fact that the .storyboard file you are trying to load is not part of the bundle of the application you are running.
The reason that's happening is that when you run a UI test your code is not running in the same process as your application, and it can only interact with it through the XCUIApplication proxy. (The mechanics might be slightly different, but that's gist, unfortunately there's little documentation that I can link.)
UI testing is a different style of testing than what you can do with XCTest. Programmatically loading an instance of a screen from a .storyboard is not possible.
In other words, you can't use any code from your app in your UI tests, but rather have to interact with it like a real user would, and write assertions for what's on the screen.
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 :) !
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.
I'm currently using TTThumbsViewController in my project. I'm getting all the urls for TTPhotoVersionLarge and TTPhotoVersionThumbnail from the web so I can't tell that a url for the thumb images will work or not.
Currently the TTThumbsViewController will just display an empty image if the thumb url can't be loaded.
So I want to be notified if a thumb fails to load and do extra error handling when that happens like:
Try to load the url for TTPhotoVersionLarge
If that fails again display an error image (which is included in the bundle)
I have looked into the three20 code but can't find a proper place where I can implement this proper error handling.
The Three20 library is great, but I've found that it's often hard to change parts of their library such as this. For instance, TTThumbsViewController basically only allows you to set the dataSource and then takes care of the rest. If you want more control, perhaps look into code such as AQGridView: http://quatermain.tumblr.com/post/528737778/aqgridview-lives-for-my-ipad-dev-camp-hackathon
I've chosen to use that over Three20's equivalent because it gives you more control over what happens with your data.
Edit: In response to using TTThumbsViewController heavily, you may want to look at this method in TTTHumbsViewController.m:
- (NSString*)URLForPhoto:(id<TTPhoto>)photo {
if ([photo respondsToSelector:#selector(URLValueWithName:)]) {
return [photo URLValueWithName:#"TTPhotoViewController"];
} else {
return nil;
}
}
It looks like you should be able to specify a different value there so long as you can find something to add to the if statement determining if the initial loading failed from the dataSource.