Xcode 8 构建在 iOS 9.2 及以下版本上崩溃

Xcode 8 build crash on iOS 9.2 and below

当我使用 Xcode 8 GM Seed 和 运行 在 iOS 9.2 以下设备或模拟器上构建我的应用程序时,我在应用程序期间出现奇怪的 EXC_BAD_ACCESS 崩溃启动或应用程序启动后几秒钟。崩溃总是发生在不同的地方(添加子视图、[UIImage imageNamed:]、应用程序委托的主要方法等)。当我在 iOS 9.3+ 或 10 上 运行 时,我没有遇到这些崩溃,当我使用 Xcode build 时,我也没有遇到这些崩溃] 7 和 运行 在 iOS 9.2 及以下。有没有其他人经历过类似的事情?这是 Xcode 8 的已知问题吗?

同样的问题。

我不确定这是否是一个错误,但这是我的解决方案:确保您的图像资产没有 Adob​​e RGB (1998) 色彩空间

in xcode

查看已接受的答案https://forums.developer.apple.com/thread/60919

您可以使用 Preview.app

将 16 位资源保存为 8 位资源

How to resolve "ERROR ITMS-90682: Invalid Bundle - The asset catalog at 'Payload/XXXXX/Assets.car' can't contain 16-bit or P3 assets if the app supports iOS 8 or earlier."

With Xcode 8 GM, this error will occur if you include 16-bit or P3 assets in an app submission targeting iOS releases earlier then iOS 9.3. If your app requires wide color functionality you must change your Deployment Target to iOS 9.3 or later. If your app does not require wide color functionality and you wish to deploy it to older iOS versions then you should replace all 16-bit or P3 assets with 8-bit sRGB assets. You can find 16-bit or P3 assets by running “assetutil” on the asset catalog named in the error message from iTunes Connect. The following steps outline the process:

  1. Create an Inspectable .ipa file. In the Xcode Organizer (Xcode->Window->Organizer), select an archive to inspect, click “Export...", and choose "Export for Enterprise or Ad-Hoc Deployment". This will create a local copy of the .ipa file for your app.

  2. Locate that .ipa file and change its the extension to .zip.

  3. Expand the .zip file. This will produce a Payload folder containing your .app bundle.

  4. Open a terminal and change the working directory to the top level of your .app bundle cd path/to/Payload/your.app

  5. Use the find tool to locate Assets.car files in your .app bundle as shown below: find . -name 'Assets.car'

  6. Use the assetutil tool to find any 16-bit or P3 assets, in each Assets.car your application has as shown below. : sudo xcrun --sdk iphoneos assetutil --info /path/to/a/Assets.car > /tmp/Assets.json

  7. Examine the resulting /tmp/Assets.json and look for any contents containing “DisplayGamut": “P3” and its associated “Name". This will be the name of your imageset containing one or more 16-bit or P3 assets.

  8. Replace those assets with 8-bit / sRGB assets, then rebuild your app.

Update: If your Deployment Target is set to either 8.3 or 8.4 and you have an asset catalog then you will receive this same error message, even if you do not actually have 16-bit or P3 assets. In this case you will either need to lower your Deployment Target to 8.2, or move it up to 9.x.

我希望这个 bash 脚本可以帮助你。 输入参数是包含项目所有 xcassets 的目录。 此脚本会将 sRGB 配置文件设置为所有 png。 它帮助了我:)

#!/bin/bash
DIRECTORY=
echo "------------------------------"
echo "Passed Resources with xcassets folder argument is <$DIRECTORY>"
echo "------------------------------"
echo "Processing asset:"
XSAASSETSD="$(find "$DIRECTORY" -name '*.xcassets')"
for xcasset in $XSAASSETSD
do
    echo "---$xcasset"
    IMAGESETS="$(find "$xcasset" -name '*.imageset')"
    for imageset in $IMAGESETS
    do
        echo "------$imageset"
        FILES="$(find "$imageset" -name '*.png')"
        for file in $FILES 
        do
            echo "---------$file"
            sips -m "/System/Library/Colorsync/Profiles/sRGB Profile.icc" $file --out $file
        done
    done
done
echo "------------------------------"
echo "script successfully finished"
echo "------------------------------"

我能够重现该问题,它似乎与 Asset Catalog 中的图像有关。 Filed a bug with Apple(附带示例项目)

Apple 漏洞报告者:28371396

将项目的 iOS 部署目标 和所有目标的 Info 设置为相同的值。

在我的例子中,我的项目设置为 iOS 9.1,目标设置为 iOS 8.0 并在模拟器上崩溃 iOS 8.4

现在一切正常。

PS.: 再次清理运行之前的项目。

编辑脚本以在整个项目中将 png 文件转换为正确的格式并带有空格:

#!/bin/bash
DIRECTORY=
echo "------------------------------"
echo "Passed Resources with xcassets folder argument is <$DIRECTORY>"
echo "------------------------------"
echo "Processing asset:"

find "$DIRECTORY" -name '*png' -print0 | while read -d $'[=10=]' file; 
do 
    echo "---------$file"
    sips -m "/System/Library/Colorsync/Profiles/sRGB Profile.icc" "$file" --out "$file"
done

echo "------------------------------"
echo "script successfully finished"
echo "------------------------------"

为有类似问题的其他人添加...

应用程序在 iOS 9.0 - iOS 9.2 上崩溃,原因似乎是随机的/围绕 Storyboard 转换/围绕设置 UIImage(name...).. 找到这个主题:(https://forums.developer.apple.com/thread/61643)

如果您的应用程序针对 iOS 8.4,它将在 iOS 9.0 - 9.2 in Xcode 8.. 中崩溃。与 xcassets 有关。将部署目标设置为 8.2 或更低版本(我使用 8.0)为我修复了它。别开玩笑了。有史以来最严重的错误。

虽然问题已经得到解答,但接受的解决方案对我不起作用,因为我没有任何 16b/ch 资产。

我发现使用 lzfse 算法压缩的资产出现问题(您可以使用 assetutil 从 Assets.car 中找到有关压缩提取信息的信息)。不幸的是 Xcode IDE 不允许开发人员更改压缩算法,但是您可以通过手动编译资产并在 actool 命令中降低部署目标来做到这一点。

tl;博士;

  1. 存档
  2. 解压缩ipa
  3. 编译资产 - 您可以通过检查 Xcode report navigator
  4. 中的存档日志找到 xcode 为您的项目生成的资产编译器命令

示例命令:

xcrun actool --output-format human-readable-text --notices --warnings --minimum-deployment-target 8.0 --output-partial-info-plist info_partial.plist --app-icon AppIcon --launch-image LaunchImage --enable-on-demand-resources YES --sticker-pack-identifier-prefix {bundle_id}.sticker-pack --target-device iphone --target-device ipad --platform iphoneos --product-type com.apple.product-type.application --compile #{path_to_directory_containing_Assets_car} Assets/Assets.xcassets

  1. 压缩它。
  2. Resign