Codesigning failed when building app from terminal

2.2k Views Asked by At

I'm trying to build my app using xcodebuild command in the terminal. It's failing to do so however, and giving me this error:

CodeSign build/Release-iphoneos/frameworkname.framework
    cd /path/frameworkname
    export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin"

Signing Identity:     "my signing identity"
Provisioning Profile: "provisioning profile"
                      (numbersandletters)

/usr/bin/codesign --force --sign numbersandletters /path/frameworkname/build/Release-iphoneos/frameworkname.framework
/path/frameworkname/build/Release-iphoneos/frameworkname.framework: bundle format unrecognized, invalid, or unsuitable
Command /usr/bin/codesign failed with exit code 1

** BUILD FAILED **

The following build commands failed:
    CodeSign build/Release-iphoneos/frameworkname.framework
(1 failure)

I'm using this command, while inside the project folder:

xcodebuild -target myprojectname -sdk iphoneos -configuration Release

Also tried adding -project myprojectname.xcodeproj but that doesn't make a difference, I still ge the same error.

I tried the script that was posted here but that didn't work for me either. I think it's because I don't have a Versions folder in my framework. That might be a place to start, but I don't know what to do tbh. Any help would be much appreciated :)

2

There are 2 best solutions below

0
On BEST ANSWER

We found a solution that would build our project. We used this command

xcodebuild -project testerProject.xcodeproj -sdk iphoneos -configuration Release clean build RUN_CLANG_STATIC_ANALYZER=NO -scheme testerProject archive

0
On

Try to build like this:

security unlock-keychain -p aPassword /Users/aUser/Library/Keychains/login.keychain && \ 
xcodebuild -scheme 'aScheme' Release archive CODE_SIGN_IDENTITY="AcodeSignIdentity" PROVISIONING_PROFILE="aProvisioningProfile"

Especially note the

1) Keychain unlock (unnecessary if you can unlock from the gui)

2) The use of a scheme