How do you code framework packages for the Mac App Store?

After a recent submission, I got the following error:

Invalid signature - the enclosed application package (FooBar.app/Contents/Frameworks/GData.framework) is not signed, the signature is invalid or not signed with the Apple certificate of submission. For more information, see the Code and Application Sandbox Guide.

Invalid signature - the enclosed application package (FooBar.app/Contents/Frameworks/Growl.framework) is not signed, the signature is invalid or not signed with the Apple certificate of submission. For more information, see the Code and Application Sandbox Guide.

Invalid signature - the embedded libcurl application package (FooBar.app/Contents/Frameworks/libcurl.framework) is not signed, the signature is invalid or not signed with the Apple certificate of submission. For more information, see the Code and Application Sandbox Guide.

So, I signed all the frame packages in Technote 2206 :

codesign -f -v -s "3rd Party Mac Developer Application: Name" ./libcurl.framework/Versions/A/libcurl codesign -f -v -s "3rd Party Mac Developer Application: Name" ./libcurl.framework/Versions/A/libssh2.1.dylib codesign -f -v -s "3rd Party Mac Developer Application: Name" ./Growl.framework/Versions/A/Growl codesign -f -v -s "3rd Party Mac Developer Application: Name" ./GData.framework/Versions/A/GData 

Technote 2206 says:

Signature frames

When you see that frameworks are packages, it’s logical to conclude that you can sign the structure directly. However, it is not. To avoid problems when signing frameworks, make sure that you sign a specific version, unlike the whole structure:

# This is the wrong way:

codeign -s my-signature-identity ../ FooBarBaz.framework

# The right way:

codeign -s my-signature-identity ../ FooBarBaz.framework / Versions / A

And when I try to check the results, it looks good:

 % codesign -vvv FooBar.app/Contents/Frameworks/libcurl.framework FooBar.app/Contents/Frameworks/libcurl.framework: valid on disk FooBar.app/Contents/Frameworks/libcurl.framework: satisfies its Designated Requirement % codesign -vvv FooBar.app/Contents/Frameworks/Growl.framework FooBar.app/Contents/Frameworks/Growl.framework: valid on disk FooBar.app/Contents/Frameworks/Growl.framework: satisfies its Designated Requirement 

For fun, I tried to directly sign the frame package, and it was still rejected. But this is exactly what the documentation says.

Any guesses why this is considered invalid? I use the same certificate that I use for the code mark of my application - the one that worked in the past.

My only suggestion would be with existing plists (do I need to own identifiers in the Info.plists infrastructure?) Or rights - any suggestions?

+80
xcode itunesconnect codesign mac-app-store
Oct 08 '11 at 2:37 a.m.
source share
4 answers

Based on baptrs' answer, I developed this shell script that coordinates all my frameworks and other binary resources / auxiliary binaries (currently supported types: dylib, bundle and login):

 #!/bin/sh # WARNING: You may have to run Clean in Xcode after changing CODE_SIGN_IDENTITY! # Verify that $CODE_SIGN_IDENTITY is set if [ -z "${CODE_SIGN_IDENTITY}" ] ; then echo "CODE_SIGN_IDENTITY needs to be set for framework code-signing!" if [ "${CONFIGURATION}" = "Release" ] ; then exit 1 else # Code-signing is optional for non-release builds. exit 0 fi fi if [ -z "${CODE_SIGN_ENTITLEMENTS}" ] ; then echo "CODE_SIGN_ENTITLEMENTS needs to be set for framework code-signing!" if [ "${CONFIGURATION}" = "Release" ] ; then exit 1 else # Code-signing is optional for non-release builds. exit 0 fi fi ITEMS="" FRAMEWORKS_DIR="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" if [ -d "$FRAMEWORKS_DIR" ] ; then FRAMEWORKS=$(find "${FRAMEWORKS_DIR}" -depth -type d -name "*.framework" -or -name "*.dylib" -or -name "*.bundle" | sed -e "s/\(.*framework\)/\1\/Versions\/A\//") RESULT=$? if [[ $RESULT != 0 ]] ; then exit 1 fi ITEMS="${FRAMEWORKS}" fi LOGINITEMS_DIR="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Library/LoginItems/" if [ -d "$LOGINITEMS_DIR" ] ; then LOGINITEMS=$(find "${LOGINITEMS_DIR}" -depth -type d -name "*.app") RESULT=$? if [[ $RESULT != 0 ]] ; then exit 1 fi ITEMS="${ITEMS}"$'\n'"${LOGINITEMS}" fi # Prefer the expanded name, if available. CODE_SIGN_IDENTITY_FOR_ITEMS="${EXPANDED_CODE_SIGN_IDENTITY_NAME}" if [ "${CODE_SIGN_IDENTITY_FOR_ITEMS}" = "" ] ; then # Fall back to old behavior. CODE_SIGN_IDENTITY_FOR_ITEMS="${CODE_SIGN_IDENTITY}" fi echo "Identity:" echo "${CODE_SIGN_IDENTITY_FOR_ITEMS}" echo "Entitlements:" echo "${CODE_SIGN_ENTITLEMENTS}" echo "Found:" echo "${ITEMS}" # Change the Internal Field Separator (IFS) so that spaces in paths will not cause problems below. SAVED_IFS=$IFS IFS=$(echo -en "\n\b") # Loop through all items. for ITEM in $ITEMS; do echo "Signing '${ITEM}'" codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" --entitlements "${CODE_SIGN_ENTITLEMENTS}" "${ITEM}" RESULT=$? if [[ $RESULT != 0 ]] ; then echo "Failed to sign '${ITEM}'." IFS=$SAVED_IFS exit 1 fi done # Restore $IFS. IFS=$SAVED_IFS 
  • Save the file in your project. I save my copy in the Scripts subdirectory in my root project.
    • My name is codesign-frameworks.sh .
  • Add the “Run Script” build phase immediately after the “Copy built-in frameworks” build phase.
    • You can call it "Codesign Embedded Frameworks".
  • Paste ./codesign-frameworks.sh (or whatever you called your script above) into the text box of the script editor. Use ./Scripts/codesign-frameworks.sh if you store the script in a subdirectory.
  • Create an application. All nested structures will be encoded.

If you still get the error "Identity: twoiguous (matches: ...", please comment below. This should no longer be.

Updated 2012-11-14: adding support for frameworks with special characters in their name (this does not include single quotes) in "codesign-frameworks.sh".

Updated 2013-01-30: adding support for special characters in all paths (this should include single quotes) in "codesign-frameworks.sh".

Updated 2013-10-29: adding experimental dylib support.

Updated 2013-11-28: adding rights support. Improved support for experimental dilib.

Updated 2014-06-13: Troubleshooting code names using frameworks containing (nested) frameworks. This was done by adding the -depth option to find , which causes find do a depth traversal. This became necessary due to the problem described here . In short: the containing package can only be signed if its attached packages are already signed.

Updated 2014-06-28: adding support for experimental packages.

Updated 2014-08-22: Code Improvement and Failure Prevention for IFS Recovery.

Updated 2014-09-26: adding support for login items.

Updated 2014-10-26: checking quotes. This fixes the errors “line 31/42: too many arguments”, and the resulting error “code object not signed at all” for paths, including special characters.

Updated 2014-11-07: Resolving an ambiguous identification error (for example, "Mac Developer: Ambiguous ...") when using automatic identity resolution in Xcode. You no longer need to explicitly set the identifier and use "Mac Developer"!

Updated 2015-08-07: Improved semantics.

Improvements are welcome!

+41
Jul 01 '12 at 18:01
source share

Your comment shows that you signed the objects in the package version directory. "Technot" shows to sign the directory itself.

The following Technote combinations are better:

 codesign -f -v -s "3rd Party Mac Developer Application: Name" ./libcurl.framework/Versions/A codesign -f -v -s "3rd Party Mac Developer Application: Name" ./Growl.framework/Versions/A codesign -f -v -s "3rd Party Mac Developer Application: Name" ./GData.framework/Versions/A 
+10
Dec 02 2018-11-11T00:
source share

Here is how I fixed it:

  • Enter the build settings of your target.
  • Mark the line "Other code signing flags"
  • Enter value - deep in release parameter
  • Close xcode
  • Go into the derived data folder on your Mac and delete the old derived data (default path: / Users / YOUR_USER_NAME / Library / Developer / Xcode / DerivedData)
  • Open Xcode and create

After building the archive and submit the application again ...

+4
Sep 11 '15 at 12:20
source share

One thing that I haven't mentioned here is that you need to have your Info.plist inside / Resources inside the version directory. Otherwise, when you try to sign the directory with the version, you will receive an invalid, invalid or inappropriate package format error.

I have provided a more extended answer here: How Codesign Growl.framework for Sandboxed Mac App

0
Aug 09 '13 at 15:06 on
source share



All Articles