Problem setting oAuth keys for iOS with product mode in example Setup App [Solved]

I’m trying to learn and get an iOS app working with product mode enabled, but I’m having a problem with oAuth keys. I’m not sure if I’m just making an error with the app name, or missing something else.

I’ve tried following along with the reference docs, but at the last point I get a build error on the var keys line saying: “Use of unresolved identifier ‘AB1exampleKeys’”

In AppDelegate.swift I have updated the section to:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        //var keys = YourappnameKeys()
        var keys = AB1exampleKeys()
        ParticleCloud.sharedInstance().OAuthClientId = keys.oAuthClientId()
        ParticleCloud.sharedInstance().OAuthClientSecret = keys.oAuthSecret()
        return true

In the Podfile I have:

target 'ios-app-particle-setup' do

    pod 'Particle-SDK'
    pod 'ParticleSetup'

    plugin 'cocoapods-keys', {
        :project => "AB1example",
        :keys => [

I installed cocoa pods-keys and ran pod install, providing the client ID and secret.
I set my product ID, name and product mode in ParticleSetupCustomization.m.

But whatever I replace “YourappnameKeys” with gives me an error. Please help!

Hello @bloukingfisher, welcome to app developer world :slight_smile:

Let me start with a little backstory. Our app uses few different keys. Those integrate with different systems such as crashlytics, firebase, particle cloud. For obvious reasons we cannot commit those keys to our opensource git repositories. I will look through doc’s, because AFAIK the cocoapods-keys plugin is no longer relevant for our project. I think we used this before, but I don’t think it was used since I joined the company.

Instead we ship a Keys.template.swift that is copy of our Keys.swift file that holds all of our keys. The go-to way is to:

  1. Copy Keys.template.swift, and rename it to Keys.swift
  2. Make sure XCode sees it by showing it in black/blue/green instead of red. Red is the color for files that should be in the project, but xcode cannot find them.
    2a) If for some reason xcode doesn’t see it, delete existing reference in xcode project and drag&drop newly created file into the project
  3. Populate the new Keys.swift with appropriate keys

Actually this got me thinking, that I will probably find some time (sometime in the near future) to register demo account in each of the systems we use and rework the template file to just have API keys for those example instances to reduce the effort needed to build tinker app on your own.

Hope this helps.


Thanks for the info @Raimis!

So I think the info applies to the Tinker IOS app. I’m actually testing out with the simpler Setup IOS app that the Particle reference documentation refers to. I’m not sure if the same applies to the setup example app?

I’ve created the Keys.swift file with my info populated under the folder iOS-app-particle-setup, and my product ID and name with product mode turned on in the customization file. However, I still get the same error when trying to create a new account. (Also, in the console the product is not set to beta mode which could cause the message about activation code.)

When I looked at Tinker I couldn’t see the easy customization ability or product mode that already exists in the setup example app.

Sorry, and here is the debug (product ID removed/obscured):

 ios-app-particle-setup[1820:4] Error signing up: Organization not found for user's role.
 ios-app-particle-setup[1820:4] ! createCustomer Failed (404): Organization not found for user's role.
    error = "Organization not found for user's role.";
    ok = 0;

My bad. Just by looking at the code you posted, for some reason I thought that you were trying to build Tinker app. Let me check that example app and get back to you.

@Raimis I’ve gone ahead tinkering with Tinker and that seems like a good starting point, perhaps better than the setup app I can’t get to authenticate.

I’ve got it working in the emulator (from what I can tell…new customer doesn’t show up on my dashboard since a new device isn’t provisioned, a known issue). Now I’m trying to provision it to my actual iPhone and I’m down to one build error, from photon-tinker-ios/Photon-Tinker/SPKTinkerViewController.m where it asks for
#import "Particle-Swift.h"
with error “File not found”

Any suggestions?

FYI, on tinker instructions it doesn’t mention also requiring a paid Apple developer account. On my free developer account it worked in the emulator, but wouldn’t provision to an actual device complaining about it. Once I realized and switched to my paid organization account it was resolved.

Regarding paid apple membership - it’s been a while since I didn’t have one, but I believe that’s still the case with everything iOS land - if you want to deploy to device, you need a paid membership :slight_smile: I think I’ve heard apple allowing to deploy to personal device nowadays, but to be honest, i don’t know how that works.

As for Particle-Swift.h… what xcode version do you use? That file is autogenerated by xcode and it’s used for obj-c code to see swift code (

Xcode 10.1 … now it’s not building for the emulator for the same reason. Ugh. Something broke somewhere.

Solved, thanks for the reference document @Raimis. :blush:
When I was changing the developer account I also changed the Product name setting…

Haha, happens :).

Back to original issue. I have created the barebone setup app. Here’s the source.

I have even left my auth keys, just to be sure it works. With this app I was able to create a new account.

To make it work, you only need 2 things:

  1. Switch developer account as you won’t have access to mine :slight_smile:
  2. Generate set of auth keys in console and copy paste them into the AppDelegate.swift

Hope this helps. Thanks for letting me know that docs are outdated. I will review them (hopefully soon… ish) to make sure onboarding is much smoother than it was for you.


That is awesome @Raimis, hours and hours easier! I’ve confirmed it works. Would be great to make this the source and instructions.

I would only suggest adding:
3. If you’re using product mode, make the required updates to ParticleSetupCustomization.m (product mode YES, productId, productName)

Thanks for letting me know about #3, that’s indeed an important point to mention in docs. I will make sure to look back at this thread when working on documentation update :slight_smile: