How to codesign ios app?

How to codesign ios app in teamcity?

I put bash script before build step

security unlock-keychain ~/Library/Keychains/teamcity.keychain-db -p [password]
codesign --force -s "iPhone Distribution: Hello world (QWERTY123)" %env.plistfile%

Build falied on

Step 4/6: archive (Xcode Project) (3s)
[14:34:19] [Step 4/6] Building project: /Users/username/buildAgent/work/c41583c97a2d7a55/AppName.xcodeproj
[14:34:19] [Step 4/6] Using Xcode 8.1
[14:34:19] [Step 4/6] Starting: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace AppName.xcodeproj/project.xcworkspace -scheme AppName archive -archivePath archive/AppName.xcarchive
[14:34:19] [Step 4/6] in directory: /Users/username/buildAgent/work/c41583c97a2d7a55
[14:34:20] [Step 4/6] User defaults from command line:
[14:34:20] [Step 4/6] IDEArchivePathOverride = /Users/username/buildAgent/work/c41583c97a2d7a55/archive/AppName.xcarchive
[14:34:21] [Step 4/6] BoothApp (BUILD) (1s)
[14:34:21] [BoothApp (BUILD)] === BUILD TARGET BoothApp OF PROJECT BoothApp WITH CONFIGURATION Release ===
[14:34:21] [BoothApp (BUILD)] Check dependencies
[14:34:22] [BoothApp (BUILD)] No profile matching 'AppNameDistribution' found: Xcode couldn't find a profile matching 'AppNameDistribution'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the General tab of the target editor.
[14:34:22] [BoothApp (BUILD)] Code signing is required for product type 'Application' in SDK 'iOS 10.1'
[14:34:22] [Step 4/6] ** ARCHIVE FAILED **
[14:34:22] [Step 4/6] The following build commands failed:
[14:34:22] [Step 4/6] Check dependencies
[14:34:22] [Step 4/6] (1 failure)
[14:34:22] [Step 4/6] Process exited with code 65
[14:34:22] [Step 4/6] Step archive (Xcode Project) failed
0
12 comments
Avatar
Permanently deleted user

Hello,

 

Could you please try your command on your Mac agent under the same user that the agent is running?

It seems your agent is missing a provisioning profile, which is required in your Xcode project. You need to login to your Mac agent and install that provisioning profile.

0
Avatar
Permanently deleted user

Step for provisioning profiles

echo "provisioning setup"
cp -f %provisioning.dir.path%/*.mobileprovision %system.xcode.provisioning.dir%

where %provisioning.dir.path%/ - directory with actual provision profiles in project

%system.xcode.provisioning.dir% - "~/Library/MobileDevice/Provisioning" "Profiles" - system folder for xcode

Or this incorrect?

0
Avatar
Permanently deleted user

Hello,

 

The whitespace in "~/Library/MobileDevice/Provisioning" "Profiles" does not seem to be correct - shouldn't it be "~/Library/MobileDevice/Provisioning\ Profiles" ?

Could you please double-check if the files are copied to the proper folder on an agent after the provisioning step, e.g. by listing the folder contents?

0
Avatar
Permanently deleted user

\ didn't help, same 65 error

0
Avatar
Permanently deleted user

Hello,

 

Could you please double-check whether the files you copy are located in the proper folder on an agent, e.g. list the contents of %system.xcode.provisioning.dir% at the end of the 'provisioning setup' step?

0
Avatar
Permanently deleted user

added ls %system.xcode.provisioning.dir%

red arrow - my provision

0
Avatar
Permanently deleted user

Hello,

 

Here is a similar issue described, it may also help you.

0
Avatar
Permanently deleted user

Hmm... I don't think so, echo in bash step working normally (all files displaying from Mobileprovision displaying in teamcity log)

0
Avatar
Permanently deleted user

I am sorry, there was a wrong link in the previuos message, corrected.

0
Avatar
Permanently deleted user

I turned off macos system protection, placed provision to System/Library/MobileDevice/Provisioning Profiles

but got same error

trying this solution with keychain

http://stackoverflow.com/questions/16550594/jenkins-xcode-build-works-codesign-fails

got new identify, but nothing happened->error 65

0
Avatar
Permanently deleted user

Hello,

Just copying doesn't work in this case, as it does not install certificates into the keychain.

Please refer to
https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html article to make it work.
Basically, you have two options here:

  1. Login to your agent with your Developer's account to download the certificate. It's easy, but you'll need to refresh it periodically.
  2. Export Your Developer Profile from your Development machine and Import it to the agent. We suppose it can be done automatically.
0
Avatar
Permanently deleted user

Well...its magic

I removed sertificate from all keychains (teamcity, system)

add manually to system -> archiving success 

0

Please sign in to leave a comment.