热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Xcode10的胖框架脚本?

如何解决《Xcode10的胖框架脚本?》经验,为你挑选了1个好方法。

我在我的方案中的归档后期使用这个脚本来制作FAT二进制框架.一个可以在模拟器和实际设备上工作.

https://gist.github.com/gauravkeshre/eabb2a13ef6d673fadec84ca60b56b05

有谁知道如何将其转换为使用Xcode 10?

使用遗留构建系统可以修复错误,但我宁愿不依赖它.

这是脚本本身:

exec > /tmp/${PROJECT_NAME}_archive.log 2>&1

UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal

if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"

# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"

echo "Building for iPhoneSimulator"
xcodebuild -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone XS' ONLY_ACTIVE_ARCH=NO ARCHS='i386 x86_64' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode clean build

# Step 1. Copy the framework structure (from iphoneos build) to the universal folder
echo "Copying to output folder"
cp -R "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${FULL_PRODUCT_NAME}" "${UNIVERSAL_OUTPUTFOLDER}/"

# Step 2. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework/Modules/${TARGET_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Modules/${TARGET_NAME}.swiftmodule"
fi

# Step 3. Create universal binary file using lipo and place the combined executable in the copied framework directory
echo "Combining executables"
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${EXECUTABLE_PATH}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${EXECUTABLE_PATH}" "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${EXECUTABLE_PATH}"

# Step 4. Create universal binaries for embedded frameworks
for SUB_FRAMEWORK in $( ls "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Frameworks" ); do
BINARY_NAME="${SUB_FRAMEWORK%.*}"
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${SUB_FRAMEWORK}/${BINARY_NAME}" "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${TARGET_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}"
done

# Step 5. Convenience step to copy the framework to the project's directory
echo "Copying to project dir"
yes | cp -Rf "${UNIVERSAL_OUTPUTFOLDER}/${FULL_PRODUCT_NAME}" "${PROJECT_DIR}"

open "${PROJECT_DIR}"

fi

**BUILD SUCCEEDED**后输出日志中的错误:

Copying to output folder
cp: /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-universal/ContactAtOnceMessaging.framework/Modules/ContactAtOnceMessaging.swiftmodule: No such file or directory
cp: /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-iphonesimulator/ContactAtOnceMessaging.framework/Modules/ContactAtOnceMessaging.swiftmodule/.: unable to copy extended attributes to /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-universal/ContactAtOnceMessaging.framework/Modules/ContactAtOnceMessaging.swiftmodule: No such file or directory
cp: /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-universal/ContactAtOnceMessaging.framework/Modules/ContactAtOnceMessaging.swiftmodule/i386.swiftmodule: No such file or directory
cp: /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-universal/ContactAtOnceMessaging.framework/Modules/ContactAtOnceMessaging.swiftmodule/x86_64.swiftdoc: No such file or directory
cp: /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-universal/ContactAtOnceMessaging.framework/Modules/ContactAtOnceMessaging.swiftmodule/x86_64.swiftmodule: No such file or directory
cp: /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-universal/ContactAtOnceMessaging.framework/Modules/ContactAtOnceMessaging.swiftmodule/i386.swiftdoc: No such file or directory

然后:

fatal error: /Applications/Xcode 10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't create temporary output file: /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-universal/ContactAtOnceMessaging.framework/ContactAtOnceMessaging.lipo (No such file or directory)
ls: /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-universal/ContactAtOnceMessaging.framework/Frameworks: No such file or directory
Copying to project dir
cp: /Users/aaronbratcher/Library/Developer/Xcode/DerivedData/iOS-Messaging-SDK-dnynwhbesxdjhmedgaxbdcjgaksx/Build/Intermediates.noindex/ArchiveIntermediates/ContactAtOnceMessaging/BuildProductsPath/Release-universal/ContactAtOnceMessaging.framework: No such file or directory

一旦进入Release-universal文件夹,第一条路径就会动摇,因为没有.framework文件夹.相反,框架的内容就在那里.



1> AlexM..:

你不需要改变任何东西.只需在框架目标的构建设置中将skip_install设置为NO即可.在归档之前,还要从$ {PROJECT_DIR}中删除.framework.

如果仍然无效,请使用$ {PROJECT_NAME} _archive.log说出错的内容编辑您的问题.

编辑:还尝试在xcode 10中使用遗留系统构建.文件 - >工作区设置 - >构建系统

编辑2:由于某种原因,Xcode 10 post action bash脚本的行为与以前的Xcode版本不同.特别是线路:

cp -R "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${FULL_PRODUCT_NAME}" "${UNIVERSAL_OUTPUTFOLDER}/"

在Xcode 10中,这会将.framework的内容复制到$ {UNIVERSAL_OUTPUTFOLDER},而在Xcode 9.3中,它会将整个.framework复制到该文件夹​​中.

因此,如果您将此行更改为:

cp -R "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/" "${UNIVERSAL_OUTPUTFOLDER}"

该脚本在Xcode 10中可以正常工作.

我使用的脚本:

exec > /tmp/${PROJECT_NAME}_archive.log 2>&1

UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal

if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"

# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
#mkdir -p "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework" 

echo "Building for iPhoneSimulator"
xcodebuild -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone XS' ONLY_ACTIVE_ARCH=NO ARCHS='i386 x86_64' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode clean build

# Step 1. Copy the framework structure (from iphoneos build) to the universal folder
echo "Copying to output folder"
cp -R "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/" "${UNIVERSAL_OUTPUTFOLDER}"

# Step 2. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework/Modules/${TARGET_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Modules/${TARGET_NAME}.swiftmodule"
fi

# Step 3. Create universal binary file using lipo and place the combined executable in the copied framework directory
echo "Combining executables"
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${EXECUTABLE_PATH}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${EXECUTABLE_PATH}" "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${EXECUTABLE_PATH}"

echo "Combining executables end"

# Step 4. Create universal binaries for embedded frameworks
for SUB_FRAMEWORK in $( ls "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Frameworks" ); do
BINARY_NAME="${SUB_FRAMEWORK%.*}"
echo "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${TARGET_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}"
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${SUB_FRAMEWORK}/${BINARY_NAME}" "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${TARGET_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}"
done

# Step 5. Convenience step to copy the framework to the project's directory
echo "Copying to project dir"
yes | cp -Rf "${UNIVERSAL_OUTPUTFOLDER}/${FULL_PRODUCT_NAME}" "${PROJECT_DIR}"

open "${PROJECT_DIR}"

fi


推荐阅读
  • imnewtotheswiftandxcodeworld,soimhavingaproblemtryingtointegrateapackagetomypro ... [详细]
  • imx6ull开发板驱动MT7601U无线网卡的方法和步骤详解
    本文详细介绍了在imx6ull开发板上驱动MT7601U无线网卡的方法和步骤。首先介绍了开发环境和硬件平台,然后说明了MT7601U驱动已经集成在linux内核的linux-4.x.x/drivers/net/wireless/mediatek/mt7601u文件中。接着介绍了移植mt7601u驱动的过程,包括编译内核和配置设备驱动。最后,列举了关键词和相关信息供读者参考。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • 树莓派语音控制的配置方法和步骤
    本文介绍了在树莓派上实现语音控制的配置方法和步骤。首先感谢博主Eoman的帮助,文章参考了他的内容。树莓派的配置需要通过sudo raspi-config进行,然后使用Eoman的控制方法,即安装wiringPi库并编写控制引脚的脚本。具体的安装步骤和脚本编写方法在文章中详细介绍。 ... [详细]
  • 本文介绍了在Mac上安装Xamarin并使用Windows上的VS开发iOS app的方法,包括所需的安装环境和软件,以及使用Xamarin.iOS进行开发的步骤。通过这种方法,即使没有Mac或者安装苹果系统,程序员们也能轻松开发iOS app。 ... [详细]
  • 其实之前也有下载过完整的android源码,但是从来没有对这个做过一些总结,在加上最近需要经常去看,索性就在从新下载,编译一下,其实这些东西官网上面都有。http:sou ... [详细]
  • Swagger2非全局、无需重复输入的Head参数(Token)配置网络上关于Swagger2的教程多如牛毛,作为关于Swagger加入全 ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • HDFS2.x新特性
    一、集群间数据拷贝scp实现两个远程主机之间的文件复制scp-rhello.txtroothadoop103:useratguiguhello.txt推pushscp-rr ... [详细]
  • 本文介绍了一些Java开发项目管理工具及其配置教程,包括团队协同工具worktil,版本管理工具GitLab,自动化构建工具Jenkins,项目管理工具Maven和Maven私服Nexus,以及Mybatis的安装和代码自动生成工具。提供了相关链接供读者参考。 ... [详细]
  • 本文介绍了在Linux下安装和配置Kafka的方法,包括安装JDK、下载和解压Kafka、配置Kafka的参数,以及配置Kafka的日志目录、服务器IP和日志存放路径等。同时还提供了单机配置部署的方法和zookeeper地址和端口的配置。通过实操成功的案例,帮助读者快速完成Kafka的安装和配置。 ... [详细]
  • 本文记录了在vue cli 3.x中移除console的一些采坑经验,通过使用uglifyjs-webpack-plugin插件,在vue.config.js中进行相关配置,包括设置minimizer、UglifyJsPlugin和compress等参数,最终成功移除了console。同时,还包括了一些可能出现的报错情况和解决方法。 ... [详细]
  • 本文讨论了如何使用Web.Config进行自定义配置节的配置转换。作者提到,他将msbuild设置为详细模式,但转换却忽略了带有替换转换的自定义部分的存在。 ... [详细]
  • 本文详细介绍了使用 SQL Load 和 Excel 的 Concatenate 功能将数据导入 ORACLE 数据库的方法和步骤,同时介绍了使用 PL/SQL tools 将数据导入临时表的方法。此外,还提供了一个转链接,可参考更多相关内容。摘要共计XXX字。 ... [详细]
  • 本文分析了Wince程序内存和存储内存的分布及作用。Wince内存包括系统内存、对象存储和程序内存,其中系统内存占用了一部分SDRAM,而剩下的30M为程序内存和存储内存。对象存储是嵌入式wince操作系统中的一个新概念,常用于消费电子设备中。此外,文章还介绍了主电源和后备电池在操作系统中的作用。 ... [详细]
author-avatar
非烦金美店
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有