gpt4 book ai didi

iOS Umbrella Framework - 代码设计问题

转载 作者:可可西里 更新时间:2023-11-01 01:49:59 25 4
gpt4 key购买 nike

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

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

这是错误:

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 安装后运行脚本阶段。不幸的是,这是一个“客户端”解决方案,我试图找到一个在框架级别应用的解决方案,但没有任何运气。

关于iOS Umbrella Framework - 代码设计问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55245473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com