Skip to content

Instantly share code, notes, and snippets.

@m4rr
Created February 7, 2018 11:54
Show Gist options
  • Save m4rr/bbb674e8182c8860d8b9a6cbb5a380e0 to your computer and use it in GitHub Desktop.
Save m4rr/bbb674e8182c8860d8b9a6cbb5a380e0 to your computer and use it in GitHub Desktop.
CircleCI Config YAML
jobs:
# ...
make_build:
macos:
xcode: "9.2.0"
steps:
- checkout
# ...
- run:
name: decode Certificates
context: org-global
command: base64 -D -o Certificates.p12 <<< $Certificates
- run:
name: make Provisioning Profiles directory
command: mkdir -pv ~/Library/MobileDevice/Provisioning\ Profiles/
- run:
name: decode Provisioning Profiles
context: org-global
command: base64 -D -o ~/Library/MobileDevice/Provisioning\ Profiles/App_Store.mobileprovision <<< $App_Store_Profile
# ...
@bunchito
Copy link

bunchito commented Apr 16, 2020

Thanks for sharing!
I am trying this but I think I am missing something from your article https://medium.com/@m4rr/circleci-2-0-and-the-ios-code-signing-df434d0086e2

I created an environment variable and paste as its value what we generate base64 -i Certificates.p12 | pbcopy
I don't know from where that Profile part is coming. Excuse my ignorance, I am a newbie.

bundle exec fastlane $FASTLANE_LANE
[⠋] 🚀 [⠙] 🚀 [⠹] 🚀 [⠸] 🚀 [⠼] 🚀 [⠴] 🚀 [⠦] 🚀 [⠧] 🚀 [✔] 🚀 
[23:08:13]: ------------------------------
[23:08:13]: --- Step: default_platform ---
[23:08:13]: ------------------------------
[23:08:13]: Driving the lane 'ios beta' 🚀
[23:08:13]: -----------------------------
[23:08:13]: --- Step: setup_circle_ci ---
[23:08:13]: -----------------------------
[23:08:13]: Creating temporary keychain: "fastlane_tmp_keychain".
[23:08:13]: $ security list-keychains -d user
[23:08:13]: ▸ "/Users/distiller/Library/Keychains/fastlane_tmp_keychain-db"
[23:08:13]: Found keychain '/Users/distiller/Library/Keychains/fastlane_tmp_keychain-db' in list-keychains, adding to search list skipped
[23:08:13]: Enabling match readonly mode.
[23:08:13]: --------------------------------
[23:08:13]: --- Step: import_certificate ---
[23:08:13]: --------------------------------
[23:08:13]: Setting key partition list... (this can take a minute if there are a lot of keys installed)
[23:08:13]: -----------------------
[23:08:13]: --- Step: build_app ---
[23:08:13]: -----------------------

Until here everything seems ok.

Then, I see this

[23:09:15]: $ xcodebuild -showBuildSettings -workspace src/MyApp.xcodeproj/project.xcworkspace -scheme MyApp
2020-04-15 23:09:17.217 xcodebuild[2004:10382]  DVTProvisioningProfileManager: Failed to load profile "/Users/distiller/Library/MobileDevice/Provisioning Profiles/App_Store.mobileprovision" (Error Domain=DVTProvisioningProfileProviderErrorDomain Code=1 "Failed to load profile." UserInfo={NSLocalizedDescription=Failed to load profile., NSLocalizedRecoverySuggestion=Profile is missing the required UUID property.})

I don't know what I am doing wrong. I would appreciate help! Thanks!

@m4rr
Copy link
Author

m4rr commented Apr 16, 2020

Hi,

Provisioning Profile also has to be encoded with base64, and put to CircleCI’s variables (same as with Certificate), then decoded to the “Provisioning\ Profiles” dir.

Don't hesitate to comment below if you have any further questions,
see you.

@bunchito
Copy link

Thanks for your quick answer, Marat! And for taking the time of writing the post.
I did that.
base64 -i MyAPP_App_Store_Provisioning.mobileprovision | pbcopy
Then I create a environment variable with the name App_Store_Profile and the value of the previous output.

This is the content of my Fastfile

default_platform :ios

platform :ios do

  before_all do
    setup_circle_ci
    import_certificate(
      keychain_name: ENV["MATCH_KEYCHAIN_NAME"],
      keychain_password: ENV["MATCH_KEYCHAIN_PASSWORD"],
      certificate_path: 'Certificates.p12',
      certificate_password: ENV["CERTIFICATE_PASSWORD"] || "default"
    )
  end

  desc "Build"
  lane :test do
    build_app(workspace: "MyApp.xcodeproj/project.xcworkspace", scheme: "MyApp")
  end

end

And when I run the lane test, here starts the error


[16:33:00]: $ set -o pipefail && xcodebuild -workspace MyApp.xcodeproj/project.xcworkspace -scheme MyApp -destination 'generic/platform=iOS' -archivePath /Users/distiller/Library/Developer/Xcode/Archives/2020-04-16/MyApp\ 2020-04-16\ 16.33.00.xcarchive archive | tee /Users/distiller/project/output/buildlogs/gym/MyApp-MyApp.log | xcpretty
[16:33:20]: ▸ ❌  error: No profiles for 'com.mytestingdomain.ios.myapp' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.mytestingdomain.ios.myapp'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'MyApp' from project 'MyApp')
[16:33:20]: ▸ ** ARCHIVE FAILED **

I also tried passing this to build_app

      export_method: "app-store",
      export_options: {
        provisioningProfiles: { 
          "com.mytestingdomain.ios.myapp" => "Name of the Provisioning Profile"
        }
      }  

I also tried passing -allowProvisioningUpdates

Any hint? Thanks a lot

But it is not working.

@m4rr
Copy link
Author

m4rr commented Apr 20, 2020

It seems the prov. profile doesn't match to the build step. It should match by bundle id, but also by the purpose of the build. Thus, prov. profile for the App Store distribution cannot be used for testing builds. But only for the App Store distribution.

@bhaktitud
Copy link

I have the same issue as you @bunchito did you manage to solve this? I've tried mentioned solutions but had no luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment