I tried to code sign an iOS application, These are the steps that i followed
security create-keychain -p password ${KEYCHAIN} security set-keychain-s
Had the same problem a while ago, adding
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k password ${KEYCHAIN}
solved it for me.