gpt4 book ai didi

ios - 将 iOS 框架作为文件或 pod 分发

转载 作者:行者123 更新时间:2023-12-01 17:28:51 24 4
gpt4 key购买 nike

我尝试从客户端添加一个我们必须在我们的产品中使用的框架,并将其作为文件分发。

我面临的问题是该框架不适用于模拟器,当我想使用模拟器时,我必须使用框架的调试版本。但是我们发布到应用商店时不能包含调试版本,他们说会被拒绝。

当我用谷歌搜索这个问题时,看起来苹果不允许这种框架。还是最近有所改变?

我还找到了有关所谓的 FAT 框架的信息,这是新的东西吗?

我试图在 apple.com 上找到有关此的信息,但我没有找到任何可以解释这种情况的信息。

当我使用像 Firebase 这样作为 pod 分发的框架时,我没有这个问题。

这些框架之间有什么区别?
客户端可以使用框架做些什么,以便可以在模拟器和应用商店中使用它?

最佳答案

When I google this problem, it looks like Apple does not allow this kind of frameworks. Or has this been changed lately?



它的工作方式是 Apple 不允许将模拟器二进制文件(x86_64 和 i386)上传到应用商店。

I also find information about so called FAT frameworks, is that something new?



FAT 框架并不是什么新鲜事。它们基本上是 FAT 二进制文件的包装器。 FAT 二进制文件包含多个体系结构。

When I use a framework like Firebase that is distributed as pod I don't have this problem.



它们没有这个问题,因为它们是作为 Pod 分发的。这些框架具有 FAT 二进制文件,即同时包含设备(armv7、arm64)和模拟器(i386、x86_64)。然后真正的魔法发生在 Cocoapods 的末端。 Cocoapods 使用构建时脚本来去除不必要架构的二进制文件。

您可以使用 cocoapods 使用的相同脚本对您的框架执行相同的操作:)
#!/bin/sh
set -e

echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"

SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"

install_framework()
{
if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
local source="${BUILT_PRODUCTS_DIR}/$1"
elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
elif [ -r "$1" ]; then
local source="$1"
fi

local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"

if [ -L "${source}" ]; then
echo "Symlinked..."
source="$(readlink "${source}")"
fi

# use filter instead of exclude so missing patterns dont' throw errors
echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"

local basename
basename="$(basename -s .framework "$1")"
binary="${destination}/${basename}.framework/${basename}"
if ! [ -r "$binary" ]; then
binary="${destination}/${basename}"
fi

# Strip invalid architectures so "fat" simulator / device frameworks work on device
if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
strip_invalid_archs "$binary"
fi

# Resign the code if required by the build settings to avoid unstable apps
code_sign_if_enabled "${destination}/$(basename "$1")"

# Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
local swift_runtime_libs
swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
for lib in $swift_runtime_libs; do
echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
code_sign_if_enabled "${destination}/${lib}"
done
fi
}

# Signs a framework with the provided identity
code_sign_if_enabled() {
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
# Use the current code_sign_identitiy
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'"

if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
code_sign_cmd="$code_sign_cmd &"
fi
echo "$code_sign_cmd"
eval "$code_sign_cmd"
fi
}

# Strip invalid architectures
strip_invalid_archs() {
binary="$1"
# Get architectures for current file
archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
stripped=""
for arch in $archs; do
if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
# Strip non-valid architectures in-place
lipo -remove "$arch" -output "$binary" "$binary" || exit 1
stripped="$stripped $arch"
fi
done
if [[ "$stripped" ]]; then
echo "Stripped $binary of architectures:$stripped"
fi
}

只需将您的框架传递给 install_framework 方法,如下所示:
install_framework "$BUILT_PRODUCTS_DIR/BadgeSwift/BadgeSwift.framework"

关于ios - 将 iOS 框架作为文件或 pod 分发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42394079/

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