Code signing of an application built with Fastlane and CocoaPods built as dynamic frameworks

I have a pretty normal fastlane and CocoaPods setup, but I have problems with code signing as fastlane tries to use an app provisioning profile to sign each CocoaPod. Error with this error:

[03:21:05]: [SHELL COMMAND]: set -o pipefail && krausefx-ipa build -w "MyApp.xcworkspace" -c "Release" -s "MyApp" --xcargs "PROVISIONING_PROFILE=g7ba10c8-cddd-490e-8eab-7ef35a511565 PRODUCT_BUNDLE_IDENTIFIER=com.example.MyApp" --no-clean --archive -d "/Users/app/Deployment" --ipa "MyApp.ipa" -m "/Users/app/Deployment/MyApp-distribution.mobileprovision" --verbose | xcpretty
[03:21:07]: [SHELL]: โ–ธ Building Pods/CocoaLumberjack [Release]
[03:21:07]: [SHELL]: 
[03:21:07]: [SHELL]: โŒฆ  Code Sign error: Provisioning profile does not match bundle identifier: The provisioning profile specified in your build settings ("com.example.MyApp Distribution") has an AppID of "com.example.MyApp" which does not match your bundle identifier "org.cocoapods.CocoaLumberjack".
...
[03:21:08]: [SHELL]: ** ARCHIVE FAILED **
[03:21:08]: [SHELL]: 
[03:21:08]: [SHELL]: 
[03:21:08]: [SHELL]: The following build commands failed:
[03:21:08]: [SHELL]: Check dependencies
[03:21:08]: [SHELL]: Check dependencies
[03:21:08]: [SHELL]: (2 failures)

      

Is there a way to tell ipa / shenzhen not to sign CocoaPods?


CocoaPods are built as dynamic structures. This is a subfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'CocoaLumberjack', '2.0.0'
pod 'HexColors', '~> 2.3'

      

This is Fastfile:

require 'fileutils'
require 'shellwords'

fastlane_version "1.12.0"

default_platform :ios

output_directory = File.expand_path('../Deployment')

platform :ios do

  before_all do
    FileUtils.mkdir_p(output_directory)
  end

  lane :production do
    sigh(
      output_path: output_directory,
      filename: "MyApp-distribution.mobileprovision",
    )

    xcodebuild_args = {
      PROVISIONING_PROFILE: Actions.lane_context[Actions::SharedValues::SIGH_UDID],
      PRODUCT_BUNDLE_IDENTIFIER: "com.example.MyApp",
    }
    xcodebuild_args = xcodebuild_args.map do |k,v|
      "#{k.to_s.shellescape}=#{v.shellescape}"
    end.join ' '

    ipa(
      workspace: "MyApp.xcworkspace",
      configuration: "Release",
      scheme: "MyApp",
      xcargs: xcodebuild_args,
      clean: false,
      archive: true,
      destination: output_directory,
      ipa: "MyApp.ipa",
    )
  end
end

      

+3


source to share


1 answer


Using custom variable env instead PROVISIONING_PROFILE

fixed the problem. This technique is documented in the fastlane docs on code signing .

These are the steps that work with Xcode 6:

Add custom variable to Xcode project

In the Xcode pbxproj file, set the PROVISIONING_PROFILE value to another variable, eg $(APP_PROVISIONING_PROFILE)

. You can choose any unique custom variable you want. The Code Signing section of the project should look like this:

Code Signing



Define a custom variable in Fastfile

In your Fastfile, define a custom variable and pass it to action ipa

with other xcargs. In the question code example, it looks like this:

xcodebuild_args = {
  # Define the custom variable instead of PROVISIONING_PROFILE
  APP_PROVISIONING_PROFILE: Actions.lane_context[Actions::SharedValues::SIGH_UDID],
  PRODUCT_BUNDLE_IDENTIFIER: "com.example.MyApp",
}

      

And all this to fix this particular error.

+2


source







All Articles