Xcode 15创建Objective-C网络框架报错:PhaseScriptExecution执行失败
Xcode 15构建Objective-C网络框架失败问题
我正尝试使用Xcode 15创建最低支持iOS 14.0版本的Objective-C网络框架,操作步骤如下:
- 依次选择「新建>项目>framework>Objective-C>storyboard>创建」;
- 将项目自动生成的
NetworkManager.h文件设置为Public; - 添加
MyNetworkRequest.h和MyNetworkRequest.m两个文件; - 通过检查器将
MyNetworkRequest.h设置为Public; - 在
NetworkManager.h中添加#import <NetworkManager/MyNetworkRequest.h>; - 进入「项目>Target>Build Setting」,设置
SKIP_INSTALL = NO和Build Libraries for distribution = YES; - 添加构建框架的脚本:选择顶部栏的Target>Edit scheme>Archive>Post action>Add run script,粘贴以下脚本:
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-Universal # Build Device and Simulator versions xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build # Copy the framework structure (from iphoneos build) to the universal folder cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/" # iOS - Copy the framework structure to the universal folder (clean it first) rm -rf "${UNIVERSAL_OUTPUTFOLDER}" # Make sure the output directory exists mkdir -p "${UNIVERSAL_OUTPUTFOLDER}" # Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory BUILD_PRODUCTS="${SYMROOT}/../../../../Products" cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" # Create universal binary file using lipo and place the combined executable in the copied framework directory lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_PRODUCTS}/Debug-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}" # Copy the framework to the project directory cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}" # Open the project directory in Finder #open "${PROJECT_DIR}" fi
- 构建并生成归档;
构建完成后遇到的问题:右键打开归档查看内容,发现所有嵌套文件夹中均未包含框架,且过程中抛出错误:Command PhaseScriptExecution failed with a nonzero exit code。
内容的提问来源于stack exchange,提问作者Priyanka Wadher Mistry
相关产品推荐
相关产品推荐

