iosxcodecode-signingapple-developer

Fastlane, iOS Provisioning Profiles & Push Notification permissions (by example)


I am trying to get Fastlane to take the source code for my iOS app and build/codesign it into an archive/IPA file. Here is my Fastfile:

default_platform(:ios)

platform :ios do
  lane :staging do
    puts "iOS staging build"
    clean_build_artifacts
    disable_automatic_code_signing(path: "./ios/myappmobile.xcodeproj")
    build_app(
      scheme: "myappmobile",
      project: "./ios/myappmobile.xcodeproj",
      export_options: {
        signingStyle: "manual",
        provisioningProfiles: {
          "com.myapp" => "/Users/myuser/workspace/myapp/myappprovisioningprofile.mobileprovision"
        }
      },
      clean: true
    )
  end
end

It's important to note that /Users/myuser/workspace/myapp/myappprovisioningprofile.mobileprovision is a valid file path/location and is where I've downloaded my Provisioning Profile file to.

When I run fastlane ios staging I get the following error:

error: "myappmobile" requires a provisioning profile with the Push Notifications feature. Select a provisioning profile in the Signing & Capabilities editor. (in target 'myappmobile' from project 'myappmobile')

When I was creating my App and all relevant resources (Certificate, Provisioning Profile, etc.) I remember selecting a checkbox stating that I would like to give my app Push Notification capabilities.

So my first assumption was that Fastlane was finding my Provisioning Profile file (myappprovisioningprofile.mobileprovision) and perhaps something inside of it hadn't been configured correctly. But I get the same error even if I change the provisioningProfiles value from:

provisioningProfiles: {
  "com.myapp" => "/Users/myuser/workspace/myapp/myappprovisioningprofile.mobileprovision"
}

to gibberish:

provisioningProfiles: {
  "com.myapp" => "flim-flam-fizz-buzz"
}

What is going on here?! Why isn't Fastlane able to find my provisioning profile file (does it need to be a relative path for some reason?!). But then the craziest thing is: it knows that the app requires Push Notifications but without being able to read/parse the Provisioning Profile, so how does it know that Push Notifications are a requirement?!

Update

After re-configuring my build_app command with some recommended settings, I have gotten past the Push Notifications problem but am now running into this:

 error: No signing certificate "iOS Distribution" found: No "iOS Distribution" signing certificate matching team ID "<redacted>" with a private key was found. (in target 'myappmobile' from project 'myappmobile')

I have a distribution certificate (ios_distribution.cer) that I created off of the Apple Developer console (web) and downloaded. How can I configure Fastlane to "see" (or use) this certificate?


Solution

  • No need to enter the path, just name of your profile as it called in your apple account, here is the part of my fastfile

     export_options: {
            "signingStyle" => "manual", 
        provisioningProfiles: {
                "com.YOUR_APP.application" => "Distribution",
            "com.YOUR_APP.application.AB24Intents" => "AB24Intents",
            "com.YOUR_APP.application.ABRPWidget" => "ABRPWidget"
                    
            }