我有一个Cocoapods作为供应商框架分发并在发布模式下编译的Umbrella框架。
它可以与模拟器完美配合,但是嵌套伞层中的子框架上的代码符号有问题。
这是错误:
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
答案 0 :(得分:1)
问题是脚本尚未启动Pod时启动。 完成所有Pod作业后,应运行脚本。
I wrote a full guide to build an iOS Umbrella framework!
我找到的解决方法如下:
在集成项目(不是伞项目)的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
在您的测试集成项目根目录的终端中:
在终端中输入:
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安装之后运行脚本阶段。 不幸的是,这是一个“客户端”解决方案,我试图找到一种可以在框架级别应用的解决方案。