SecKey API returned: -25304 libswiftAVFoundation.dylib: unknown error -1=ffffffffffffffff error: Task failed with exit 1 signal 0

Hi,


Since 10.12 Sierra major update, I can't compile one of my iOS projects only on device. But weird, it's works fine on simulator.

So I tried to remove and resetup my dev account in Xcode, hard reboot, remove and resetup all certificates in keychain, etc.

I use XCode 8.0. I also tried it on Xcode 8.1 beta too, same result.


The error at end of compilation :


SecKey API returned: -25304, (null)/Users/***/Library/Developer/Xcode/DerivedData/***-epkppprfmidyatftsvnxgjqsawit/Build/Products/Debug-iphoneos/***.app/Frameworks/libswiftAVFoundation.dylib: unknown error -1=ffffffffffffffff

error: Task failed with exit 1 signal 0 { /usr/bin/codesign '--force' '--sign' 'C47B52FDE2CABFC81D33BED8937984AF8BC6DC33' '--verbose' '/Users/***/Library/Developer/Xcode/DerivedData/***-epkppprfmidyatftsvnxgjqsawit/Build/Products/Debug-iphoneos/**.app/Frameworks/libswiftAVFoundation.dylib'


Thank you for any help.

Replies

You could try deleting the ***-epkppprfmidyatftsvnxgjqsawit folder from the DerivedData folder, then recompile and see if it helps.

I am having the exact same issues and am stumped. The builds work fine in the simulator but give this error when building for a device or archiving. The device I am testing is iOS 9.3.1. I am currently updating another device to iOS 10 to see if this resolves the problem. Starting a new project gives the exact same error, so I do not think it is a permissions error as per https://forums.developer.apple.com/message/177695#177695.


I am completely at a loss on how to fix it. My gut is telling me it is an error in xcode 8, especially with it not working on new projects with no chages to the defaults Apple gives.

Just be aware that forum thread isn't a permissions issue, it is an issue where a resource fork was created for one or more files by finder or some other application.


That said, a fresh project does suggest it is something different.

I'm also getting this with Xcode 8 and Sierra. Perhaps this helps.. I can build from the Xcode command line and watch it code sign perfectly. But if I let Jenkins run that exact same command, it will fail with the "uknown error" from the original post.


Thoughts?

When you build via xcodebuild command did you see any UI prompt to ask for the permitting for private key access? I found my jenkins fails because it can't handle the prompt UI.

Can you please file a bug report about this at <https://developer.apple.com/bug-reporting>?


Did you get any alerts asking for access to your keychain items?


Are you running Xcode directly on this Mac, or are you running it across SSH or other remote access channel?


--gc

The underlying problem for me was that I codesign was requesting access to the keychain and I had to approve it before it worked.


Somehow this line didn't grant codesign access when the keychain was created:


security import ./osx_signing.p12 -k osx_signing.keychain -P MY_SUPER_PASSWORD -T /usr/bin/codesign


Actually with Sierra, even doing this still causes codesign to trigger a pop-up the very first time it is run. 🙂


security import ./osx_signing.p12 -k osx_signing.keychain -P MY_SUPER_PASSWORD -A

Hi MattOz,


I also got the same issue. But i solved it.. you just remove your old provisional profiles and create new profiles with new CertificateSigningRequest on updated mac OS. Then import in xcode and try, this problem will be solved.


Thanks,

Anu

I'm getting the same error on Jenkins, any luck solving it?

I have had the exact same problem as you described with Jenkins.

To solve it, move the certificates (from the project you are trying to build) in your keychain from login to system. This appearently gives admin rights to Jenkins to actually perform the build.


Hope it also works for you.

I had a similar issue on Bamboo. My solution was enabling "Allowing all applications to access this item" in Keychain Access for to the private key of certificate.

Did you ever find a resolution to your error? I have the exact same error, "SecKey API returned: -25304", ever since I updated to Sierra and have been unable to resolve this.

Worked for me on my Jenkins mac *****! 🙂 I tried setting allow all on all the keys but that didn't work.

I had the similar error like you.

I wrote a customized shell script for jenkins triggered, like this.

```

#!/bin/bash

ARCHIVE_DIRECTORY="$(pwd)/archive/MyProject.xcarchive"

KEYCHAIN_PATH="$(pwd)/productions.keychain"

xcodebuild -workspace "MyProject.xcworkspace" -scheme "MyProject" -configuration "Release" clean archive -archivePath $ARCHIVE_DIRECTORY DEVELOPMENT_TEAM=XXXXXXXXX OTHER_CODE_SIGN_FLAGS="--keychain ${KEYCHAIN_PATH}"

```


It give me this error

```

sent 8324036 bytes received 70 bytes 5549404.00 bytes/sec

total size is 8322783 speedup is 1.00

Code Signing /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyProject-cqlsevgbiaqwmfdjmfvxrmxleebn/Build/Intermediates/ArchiveIntermediates/MyProject/InstallationBuildProductsLocation/Applications/MyProject.app/Frameworks/Alamofire.framework with Identity iPhone Developer: Awesome developer (XXXXXXXXXX)

/usr/bin/codesign --force --sign 3341D7CE635CB81A90173ABBAA00FE7C7C2EF88D --keychain /Users/Shared/Jenkins/Home/jobs/MyProject-iOS/workspace/prod.keychain --preserve-metadata=identifier,entitlements "/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyProject-cqlsevgbiaqwmfdjmfvxrmxleebn/Build/Intermediates/ArchiveIntermediates/MyProject/InstallationBuildProductsLocation/Applications/MyProject.app/Frameworks/Alamofire.framework"

SecKey API returned: -25308, (null)/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyProject-cqlsevgbiaqwmfdjmfvxrmxleebn/Build/Intermediates/ArchiveIntermediates/MyProject/InstallationBuildProductsLocation/Applications/MyProject.app/Frameworks/Alamofire.framework: unknown error -1=ffffffffffffffff

Command /bin/sh failed with exit code 1


** ARCHIVE FAILED **

```