4

我是新来的,并试图在 iOS 上实现我的第一个应用程序,但是,我正面临这个问题,并从上周开始尝试解决它。

1.运行“flutter build ios”后,构建签名成功

2.项目存档也成功

(问题)但是当我点击验证应用程序时。我得到了以下问题,我花了很多时间并做了很多调试,但找不到这个问题的原因。

报错信息截图 在此处输入图像描述

终端输出:颤振医生 -v


[✓] Flutter (Channel stable, 1.22.3, on Mac OS X 10.15.7 19H2, locale en-GB)
• Flutter version 1.22.3 at /Users/sohumwahi/Library/flutter
• Framework revision 8874f21 (6 days ago), 2020-10-29 14:14:35 -0700
• Engine revision a1440ca392
• Dart version 2.10.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/sohumwahi/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.1, Build version 12A7403
• CocoaPods version 1.10.0

[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.50.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0

[✓] Connected device (1 available)
• iPhone 11 Pro (mobile) • 093FA4C3-39F3-4D69-B945-DDD155FDBD49 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-14-1 (simulator)

! Doctor found issues in 1 category.

4

2 回答 2

1

以下是解决此错误的方法:您必须将脚本添加到您的 xcode 中,该脚本将删除 3rd 方库的未使用代码。当你在 xcode 中打开你的 Flutter iOS 项目时,你会在构建阶段部分看到 Flutter 已经有一个脚本。不要乱用这个脚本,而是添加一个新脚本。就像这里是这张图片: 在此处输入图像描述

然后你会有这样的东西:

在此处输入图像描述

在此之后打开运行脚本并放置以下代码:

# Type a script or drag a script file from your workspace to insert its path.APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.

find "$APP_PATH" -name 'FRAMEWORK_NAME*.framework' -type d | while read -r
FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

EXTRACTED_ARCHS=()

for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o
"$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done

echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create
"${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done

如果您遇到错误,指出脚本中存在语法错误,请尝试删除在您尝试复制脚本时可能已复制的无法识别的字符,因为 xcode 不处理它们并且它发生在我身上。因此,复制代码并将其放置在能够处理此类字符的不同代码编辑器中(例如 Visual Studio),然后从某些行的末尾删除不需要的字符。所以现在你总共有两个脚本在运行

于 2020-11-13T17:45:03.257 回答
1

经过大量搜索和尝试,我发现我在配置时出错,一旦我解决了这个问题,我就成功地验证了应用程序并将其上传到 App Store。

于 2020-11-21T09:08:42.773 回答