Search code examples
swiftxcodecocoacode-signing

How to fix dylib with invalid signature?


Yesterday I was having an issue to run my app after auto code signing. See the question I post here yesterday.

After spending some time to investigate the issue it turns out the framework certificate somehow corrupted.

The solution is to fix the invalid signature for the framework, and here is how to do so.

P.S. One thing we are certain is that we did tick the Sign On Copy checkbox.


Solution

  • NOTE: VideoBuilderLibrary is a custom framework we built.

    To test the code sign state,

    # Replace the framework to yours
    codesign -v 
    frameworks/VideoBuilderLibrary.framework/Frameworks/libavutil.55.dylib
    [no output]
    

    If there is any invalid signature,

    codesign -v 
    frameworks/VideoBuilderLibrary.framework/Frameworks/libavutil.55.dylib
    frameworks/VideoBuilderLibrary.framework/Frameworks/libavutil.55.dylib: 
    invalid signature (code or signature have been modified)
    In architecture: x86_64
    

    To resigned all dylib files in a framewor and fix this, run command below with "YOUR CERTIFICATE NAME" replaced with your cert file name,

    cd frameworks/VideoBuilderLibrary.framework/Frameworks
    ls | xargs codesign -f -s "YOUR CERTIFICATE NAME"