NSBundle initWithURL nil URL error when registering user with Shopify iOS SDK

I’m working on integrating the Shopify mobile SDK into my iOS app and running into a crash when trying to register a new user account. Every time I attempt to create a customer, the app crashes with an NSBundle initWithURL error.

Here’s the code I’m using:

NSArray *userCredentials = @[
    [BUYAccountCredentialItem itemWithEmail:self.emailTextField.text],
    [BUYAccountCredentialItem itemWithPassword:self.passwordTextField.text], 
    [BUYAccountCredentialItem itemWithFirstName:self.nameTextField.text]
];

BUYAccountCredentials *accountData = [BUYAccountCredentials credentialsWithItems:userCredentials];
BUYClient *shopifyClient = [[BUYClient alloc] initWithShopDomain:@"my-shop-domain" apiKey:@"my-api-key" appId:@"my-app-id"];

[shopifyClient createCustomerWithCredentials:accountData callback:^(BUYCustomer *newCustomer, BUYCustomerToken *authToken, NSError *createError){
    // callback code here
}];

The crash message I’m getting is:

Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ’ -[NSBundle initWithURL:]: nil URL argument’

What could be causing this nil URL issue? The credentials seem to be set up correctly but something is failing during the customer creation process.

This NSBundle crash happens when your iOS deployment target doesn’t match the Shopify SDK requirements. I hit this same issue upgrading an old project - had deployment target set to iOS 9.0 but the SDK needed iOS 10.0 minimum. The SDK tries loading resources that won’t work on older iOS versions, which causes the nil URL error when the bundle initializes. Check your project’s deployment target in build settings and compare it to what the SDK docs say you need. Also make sure you’re using the right SDK version for your iOS target - sometimes older SDK versions work better with legacy projects. One more thing - verify you’re calling the registration method on the main thread since some SDK operations need specific threads to access bundle resources correctly.

Had this exact crash 6 months ago with Shopify SDK customer registration. That NSBundle initWithURL nil error happens when the SDK can’t find its resource bundle. For me, I’d missed importing all the required Shopify SDK bundle resources into my project target. Go to your project navigator and make sure BuySDK.bundle is actually included in your app bundle. Check target settings > Build Phases and see if the bundle shows up in Copy Bundle Resources. If it’s not there, just drag BuySDK.bundle from your Pods/framework folder into that section. Also double-check your framework search paths in build settings. Once I added the missing bundle resources, registration worked perfectly.

first thing - double-check your shopify credentails. i’m betting the api key or app id is wrong, which makes the sdk fail when loading internal resources. log those values right before you call createCustomer and make sure they’re not nil or empty.

This happens when the Shopify SDK can’t access internal resources because of bad config parameters. I ran into the same thing when my shop domain was formatted wrong - you need just the domain name, not the full URL. Use “my-shop” instead of “my-shop.myshopify.com” or anything with https://. Also check if your app has customer creation permissions turned on in the Shopify partner dashboard. Without the right API permissions, the SDK can’t initialize properly and throws this NSBundle error. I’d start with a simple test using hardcoded credentials to see if it’s a config issue or something in your code.