我不能再在模拟器上运行我的应用程序了。Online建议我编辑我的项目。Pbxproj,但这似乎不起作用。如何恢复在模拟器上运行项目的能力(并在设备上仍然能够这样做)?我正在开发另一个项目,该项目使用了许多相同的框架,但它运行在模拟器上。什么会导致类似的框架在一个项目中工作,而在另一个项目中不工作?
当前回答
Xcode 12.3
在我的案例中,我通过在Build Settings选项卡中简单地将Validate Workspace设置为Yes来解决这个问题
其他回答
这里的大多数答案都是为了让通用二进制文件的使用者绕过新的限制。但是,正如在其他地方提到的,现在是时候为框架作者迁移到Apple的XCFramework格式了。
如果您在使用聚合目标和lipo之前运行一个自定义构建脚本来创建通用二进制文件,那么可以直接迁移到生成.xcframework文件
首先,在构建设置中确保“build Libraries for Distribution”(BUILD_LIBRARY_FOR_DISTRIBUTION)设置为YES
然后,将使用lipo的现有聚合目标构建脚本替换为如下内容,这可以简单地展示如何制作“发布”框架:
# Universal Script
set -e
FRAMEWORK_NAME="your_framework_name"
IOS_SCHEME_NAME="your_scheme_name"
if [ -d "${SRCROOT}/build" ]; then
rm -rf "${SRCROOT}/build"
fi
SIMULATOR_ARCHIVE_PATH="${SRCROOT}/build/${FRAMEWORK_NAME}-iphonesimulator.xcarchive"
DEVICE_ARCHIVE_PATH="${SRCROOT}/build/${FRAMEWORK_NAME}-iphoneos.xcarchive"
OUTPUT_DIR="${SRCROOT}/framework_out_universal/"
# Simulator xcarchieve
xcodebuild archive \
-scheme ${IOS_SCHEME_NAME} \
-archivePath ${SIMULATOR_ARCHIVE_PATH} \
-configuration Release \
-sdk iphonesimulator \
SKIP_INSTALL=NO
# Device xcarchieve
xcodebuild archive \
-scheme ${IOS_SCHEME_NAME} \
-archivePath ${DEVICE_ARCHIVE_PATH} \
-sdk iphoneos \
-configuration Release \
SKIP_INSTALL=NO
# Clean up old output directory
rm -rf "${OUTPUT_DIR}"
# Create xcframwork combine of all frameworks
xcodebuild -create-xcframework \
-framework ${SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-framework ${DEVICE_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \
-output ${OUTPUT_DIR}/${FRAMEWORK_NAME}.xcframework
# Delete the most recent build.
if [ -d "${SRCROOT}/build" ]; then
rm -rf "${SRCROOT}/build"
fi
你可以调整上面有不同的输出dirs,不同的删除行为,支持多种配置(发布vs调试),但这对我来说是可行的。
最后,作为一次性步骤,删除导致您在本项目中提到的错误的your_framework_name.framework通用二进制文件。复制新构建的your_framework_name。Xcframework并将其添加到项目中,错误就会消失。
我想你所链接的框架只是为arm架构而构建的。你不能在模拟器中运行它。您将需要框架的作者来构建一个“通用框架”。
可能的原因是
framework which you are using may not be built for simulator architecture(x86_64), you can check the compatibility by going to framework folder (framework_name.framework --> modules --->framework_name.swiiftModule-->) in this path you should see arm/i386/x86_64 support files if you have updated to new Xcode, the frameworks you are using are not compatible to the newer compiler version, so vendor needs to share the recent compatible one, in this case you will not be able to run on both device and simulator
Xcode 12.3
在我的案例中,我通过在Build Settings选项卡中简单地将Validate Workspace设置为Yes来解决这个问题
No doubt that the fix in case of Xcode 12.3 is to setup the Validate Workspace property in the target's build setting. However if you check the diff after this change, the reason of the build error is the missing parameter (VALIDATE_WORKSPACE) from the project file, not the value of the parameter. So you don't need the value to be YES. You need to add the value to the project settings and you can leave it on the default value (NO). At the first time, it shows up in the Build Settings with NO, but only because that is the default value of the missing parameter.
TLDR; 在不更改项目设置的情况下,转到目标的构建设置,找到“验证工作区”,将其设置为YES,然后设置回NO。
推荐文章
- Xcode 4 -在新的Macintosh安装上的配置文件上“没有找到有效的签名标识”错误
- Xcode +删除所有断点
- 在iPhone上确定用户是否启用了推送通知
- 是否有可能禁用浮动头在UITableView与UITableViewStylePlain?
- Swift:理解// MARK
- 错误ITMS-9000:“冗余二进制文件上传。火车1.0版本已经有一个二进制版本上传。
- Swift -转换为绝对值
- 从父iOS访问容器视图控制器
- 自定义dealloc和ARC (Objective-C)
- 调整UITableView的大小以适应内容
- 在代码中为UIButton设置一个图像
- NSRange从Swift Range?
- UICollectionView中的单元格间距
- 我如何在我的iOS应用程序中每n分钟得到一个后台位置更新?
- 你常用的Xcode快捷键有哪些?