iOS Umbrella Framework - 协同设计问题

iOS Umbrella Framework - codesign problem

我有一个通过 Cocoapods 分发的 Umbrella Framework 作为销售框架并在发布模式下编译。

它与模拟器完美配合,但我对嵌套在伞层中的子框架的代码签名有问题。

这是错误:

dyld: Library not loaded: @rpath/Subframework.framework/Subframework
Referenced from: /private/var/containers/Bundle/Application/02AD328F-9E78-4D53-9C39-0C8639B00D81/sdkInteTest.app/Frameworks/Umbrella.framework/Umbrella
Reason: no suitable image found. Did find:
/private/var/containers/Bundle/Application/02AD328F-9E78-4D53-9C39-0C8639B00D81/sdkInteTest.app/Frameworks/Umbrella.framework/Frameworks/Subframework.framework/Subframework: code signature in (/private/var/containers/Bundle/Application/02AD328F-9E78-4D53-9C39-0C8639B00D81/sdkInteTest.app/Frameworks/Umnrella.framework/Frameworks/Subframework.framework/Subframework) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.

然后,如果我启动应用程序以使用以下脚本签署子框架:

pushd ${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/Frameworks/Umbrella.framework/Frameworks
for EACH in *.framework; do
echo "-- signing ${EACH}"
/usr/bin/codesign --force --deep --sign "${EXPANDED_CODE_SIGN_IDENTITY}" --entitlements "${TARGET_TEMP_DIR}/${PRODUCT_NAME}.app.xcent" --timestamp=none $EACH
done
popd

我收到这个错误:

/Users/xxx/Library/Developer/Xcode/DerivedData/sdkInteTest-bbfpzsxuhjomfmaumywyncnbwbla/Build/Intermediates.noindex/sdkInteTest.build/Debug-iphoneos/sdkInteTest.build/Script-F9547ACC224017BF0030EA0B.sh: line 3: pushd: /Users/xxx/Library/Developer/Xcode/DerivedData/sdkInteTest-bbfpzsxuhjomfmaumywyncnbwbla/Build/Products/Debug-iphoneos/sdkInteTest.app/Frameworks/Umbrella.framework/Frameworks: No such file or directory
-- signing *.framework
*.framework: No such file or directory
/Users/xxx/Library/Developer/Xcode/DerivedData/sdkInteTest-bbfpzsxuhjomfmaumywyncnbwbla/Build/Intermediates.noindex/sdkInteTest.build/Debug-iphoneos/sdkInteTest.build/Script-F9547ACC224017BF0030EA0B.sh: line 8: popd: directory stack empty

解决方案

问题是脚本在 pod 尚未附加时启动。 当所有 Pod 作业完成时,脚本应该是 运行。

I wrote a full guide to build an iOS Umbrella framework!

我找到的解决方案如下:

1) 第一步:

在集成项目(不是伞式项目)的 podfile 中,添加以下代码行以添加依赖项:

script_phase :name => 'Sign', :script => './sign.sh'

像这样:

target 'yourTarget' do

    # Pods for sdkInteTest
    #your pods goes here

    script_phase :name => 'Sign', :script => './sign.sh'
end

2)第二步:

比在测试集成项目根目录下的终端:

在终端输入:

touch sign.sh
chmod 777 sign.sh
open sign.sh

并在脚本文件中添加以下代码:

echo "Signing subframeworks"
pushd "${TARGET_BUILD_DIR}"/"${PRODUCT_NAME}".app/Frameworks/YOURFRAMEWORKNAME.framework/Frameworks
for EACH in *.framework; do
echo "-- signing ${EACH}"
/usr/bin/codesign --force --deep --sign "${EXPANDED_CODE_SIGN_IDENTITY}" --entitlements "${TARGET_TEMP_DIR}/${PRODUCT_NAME}.app.xcent" --timestamp=none $EACH
done
popd

echo "BUILD DIR ${TARGET_BUILD_DIR}"

记得重命名你的框架名称。

通过这种方式,您告诉 CocoaPods 在 pod 安装后 运行 一个脚本阶段。 不幸的是,这是一个 "client" 解决方案,我试图找到一个在框架级别应用的解决方案,但没有任何运气。