Mapbox show Exception and terminate when using mbtiles in ios - ios

I am using MapBox example and I have imported my mbtiles file. I am getting this error:
MB Example[8517:c07] * Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '* -[NSURL
initFileURLWithPath:]: nil string parameter'
I have checked my mbtile file and its loading on x-code so there no problem with it.

RMMBTilesSource is indeed using that code. You need to make sure that your OSMBright.mbtiles file is part of the project's target and being added to your bundle so that it can be pulled up as a tile source. Like any resource that you need to use in your app, it's not enough to simply be part of the Xcode project.

The reason for the crash is clear from your question itself. reason : [NSURL initFileURLWithPath:]: nil string parameter. You are initializing NSURL without passing a nil parameter. Search for initFileURLWithPath and check wether the parameter is nil or not
[NSURL initFileURLWithPath:] // Pass a valid path here

Your question cannot be answered correctly in it's current format. You need to add the code related to the issue.
The issue is you are passing a nil parameter to the initFileURLWithPath method.
Possibly the mbtiles file is missing. So it'll return nil, also issue can be in the Mapbox.
Please check that you added it to the project correctly.

Had the same error. Are you sure you copied the MapBox.bundle from the .framework into your Xcode-Project as stated here:
https://www.mapbox.com/mapbox-ios-sdk/
?
That fixed it for me!

Related

Swift3 CoreData crash on iOS9 device

I have CoreData app that is perfectly working on iOS10, written in Swift3, supporting iOS 8.4 and above.
When I try to run it on iOS 9.3.5 I'm getting error:
2016-10-07 17:47:20.596 FormApp[710:179733] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet'
crashing on line:
form.addToOpenQuestions(openQuestion)
I have added #objc() to managed object classes. Then I'm getting new error:
CoreData: warning: Unable to load class named 'FormApp.Form' for entity 'Form'. Class not found, using default NSManagedObject instead.
It is happening on line:
let form = NSEntityDescription.insertNewObject(forEntityName: "Form", into: managedObjectContext) as! Form
My config:
All classes were generated by Xcode. I have tried deleting Module and all configurations. Anyone have idea how to make it work?
For some reason NSSet is expected, but your NSManagedObject code has NSOrderedSet, which is a subclass of NSObject. Try to remove "Arrangment: Ordered" checkmark in your core data model and refactor those relationships to NSSet.
Not sure why this happens in iOS 10 but not in iOS 9 though.
P.S. Perhaps you should reconsider your Core Data model? It looks like your Open/Closed questions are going to change their status. If so, I would recommend to make one Question entity with closed bool or status int.
I was having the same issue with iOS 9.3
The issue was same as mention by #alex above and i have solve as below
if #available(iOS 11.0, *) {
// use iOS 11-only feature
YOUR_CLASS.insertIntoClosedQuestion(YOUR_OBJECT, at: index)
} else {
// handle older versions
let orderset:NSMutableOrderedSet = Form.closeQuestion as! NSMutableOrderedSet
orderset.insert(YOUR_OBJECT, at: index)
YOUR_CLASS.addToClosedQuestion(orderset)
}
Hope it will helpful to others.

UIImage+ResizeMagick | NSInvalidArgumentException | iOS | Swift

I'm using "UIImage+ResizeMagick" (iOS api by some developer for resizing image written in obj-c) in my swift project, but facing issues and getting the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage resizedImageByMagick:]: unrecognized selector sent to instance 0x7fe74c2065c0'
I know this error occurs when that function doesn't exists in that particular class or if we pass wrong parameters while calling the function but i don't think it's the case with my code (if i'm not wrong)
This class is written as: "UIImage(ResizeMagick)" and as per my knowledge it's a category so i can use the methods with every UIImage object. I've imported it in my class as #import "UIImage+ResizeMagick.h" and using it as:
UIImage *image = [UIImage imageNamed:#"validate-icon-tick.png"];
image = [image resizedImageByMagick:#"200x200"];
I'm using multiple libraries in my project that are written in obj-c but i'm using bridging header for this purpose. May be the problem with ResizeMagick is because of extensions vs categories difference in obj-c and swift.
Kindly tell me what i'm doing wrong or if is it possible or not. Thanks.
Fixed the issue for using extension (cocopods) in swift.
I've added #import <UIImage-ResizeMagick/UIImage+ResizeMagick.h> in my bridging header file. In controller i've used the methods of this extension as:
let image = oldImage.resizedImageByMagick("200x200")
Extensions vs Categories (in swift and objective-c) are well explained over here:stack overflow post link

Xamarin iOS Binding: Could not initialise an instance of the type, returned nil

I've bound an iOS library, SVGKit, to C# using Xamarin/Monotouch. After some issues I've managed to get the library to build ok.
My code can be found here: https://github.com/jamesmundy/SVGKit.Xamarin
Unfortunately, when I try to initialise a type from the class I receive the following error:
Could not initialize an instance of the type
'SVGKitBindings.SVGKFastImageView': the native 'init' method returned
nil. It is possible to ignore this condition by setting
MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.
The full stack trace is can be seen here.
Any idea as to what is causing this problem and what I can do to rectify it?
Update: Here is the full Build Output of my project. http://pastebin.com/f60wFm52
Update 2: Tried setting SmartLink to false and rebuilding, same error though a slightly different build output. http://pastebin.com/ApCAz2BP
Look at the source code for SVGKFastImageView init [1]:
- (id)init
{
NSAssert(false, #"init not supported, use initWithSVGKImage:");
return nil;
}
The managed exception is correct: you can't call this constructor.
[1] https://github.com/SVGKit/SVGKit/blob/cd47ae95e57c9490a9238173855ecbe83d4aaf44/Source/UIKit%20additions/SVGKFastImageView.m#L53

Writing an iOS 8 share extension without a storyboard

Does anyone know of a good way to write an iOS 8 share extension without the MainInterface.storyboard that comes with the template?
When I delete the file or remove the NSExtensionMainStoryboard from Info.plist, the extension stops working (nothing happens when you tap on the button in the share pane). We tried replacing NSExtensionMainStoryboard with NSExtensionPrincipalClass which also didn't work.
Any ideas?
Figured it out!
Turns out there's a weird module naming thing going on in Swift, so you can fix it by adding an #objc name to the class:
#objc(PrincipalClassName)
class PrincipalClassName: UIViewController {
...
and then set the NSExtensionPrincipalClass key to PrincipalClassName.
Instead of the #objc hack, the proper way to do it in Swift is to include the module name in NSExtensionPrincipalClass, i.e.,
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ActionViewController</string>
(Documenting the error otherwise:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: ...)'
Hopefully will help someone who run into this error in the future.)
Found the answers from these answers combined Answer 1 and Answer 2.
For Objective-C you will have to put the following in the info.plist of the App extension:
NSExtensionPrincipalClass and make sure that it is under NSExtension Dict
So full answer should be like this , in my case ActionViewController is the App extension viewController
Can't add a comment but it is no longer NSPrincipalClass rather it is NSExtensionPrincipalClass

RestKit - using colon in Paginator Path crashes

I am using RKPaginator to fetch objects from following URL:
http://devSite.com/api/products?pid=somePid&fl=p7:9&limit=5&offset=0
I am setting the path as follows :
NSString*urlPAth = [NSString stringWithFormat:#"http://devSite.com/api/products?pid=%#&fl=p7:9&limit=:perPage&offset=:offset", pid];
But it does give an error and crashes :
* Terminating app due to uncaught exception
'NSUnknownKeyException', reason: '[
valueForUndefinedKey:]: this class is not key value coding-compliant
for the key 9.
I know this is because of the colon, but couldn't fine any solution to fix this.
You can't use : in the path when you're using injected parameters because it will be treated as a parameter. If you need to use : then you either need to encode the colon (perhaps to %3A) or you need to inject that value as part of (or after) the parameter injection (which will probably require you to subclass the paginator).
In my case the URL have this scheme:
..elements/DOCCOMPANY_FILE:1502328/structure
That means in my case: "From element with key "DOCCompany:150.." GET its structure.
This will not work with the RKPaginator Class in restkit.
But if you can edit your local sources, add this to the RKPaginator or subclass it:
-(id)valueForUndefinedKey:(NSString *)key {
return [NSString stringWithFormat:#":%#",key];
}
This will ignore all unknown parameters in URL in the pagination class and works well for me.

Resources