Xcode编译打包上架Flutter项目问题总结

1 篇文章 0 订阅
1 篇文章 0 订阅

一、编译运行过程遇到问题

1、控制台输出的报错信息中发现会有某些方法不存在,没有该命名的参数,或者是某些变量、参数不存在。

解决方法:在Flutter项目中pubspec.yaml将出现问题的插件的版本号切换为指定版本,即去掉 ^ 符号,因为有些插件用最新的可能会出现不兼容的问题,同时确保Flutter版本与开发项目时所用的版本一致。

2、[VERBOSE-2:platform_view_layer.cc(20)] Trying to embed a platform view but the PrerollContext does not support embedding

解决方法:进入项目目录下的IOS中的Runner,修改Info.plist

<key>io.flutter.embedded_views_preview</key>
<true/>

3、linked and embedded framework ‘App.framework’ was built for iOS Simulator linked and embedded framework ‘Flutter.framework’ was built for iOS Simulator

解决方法:
a、修改targets => Build Setting=>Validate WorkspaceNO
b、删除App.frameworkFlutter.framework后重新编译运行

4、运行过程控制台报0x000000010f8854d5 -[JPushPlugin setup:result:] + 437 6 Runner 0x000000010f8错误

解决方法:在项目中注释掉JPush插件以及相关代码即可

5、warning: The iOS deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99. (in target ‘flutter_local_notifications’ from project ‘Pods’)

解决方法:
a、进入项目目录下的IOS,修改底下的Podfile文件

post_install do |installer| 
	installer.pods_project.targets.each do |target| 
		target.build_configurations.each do |config| 
			if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 10.0 
				config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
			end 
		end
	end
end

b、上述方法有时候还不能完全解决,还需要在Xcode中进行修改,在左侧项目栏搜索8.0,将相关参数设置为10.0

6、The linked library ‘xxxx.a/Framework’ is missing one or more architectures required by this target: armv7.

解决方法:在Target=>Build Settings =>Excluded Architectures中添加以下代码

EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64=arm64 arm64e armv7 armv7s armv6 armv8 EXCLUDED_ARCHS=$(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT))

7、Unable to install “…” Domain: com.apple.dt.MobileDeviceErrorDomain Code

解决方法:重新配置证书,然后编译运行

8、FlutterWebView.h: No such file or directory (in target ‘webview_flutter’ from project ‘Pods’) 或者 The sandbox is not in sync with the Podfile.lock. Run ‘pod install’ or update your CocoaPods install

解决方法:进入项目目录下的ios,执行pod install后重新运行项目

9、fatal error: lipo: -extract x86_64 specified but fat file: …/Runner.app/Frameworks/App.framework/App does not contain that architecture
Failed to extract x86_64 for …/Runner.app/Frameworks/App.framework/App. Running lipo -info:Architectures in the fat file: …/Runner.app/Frameworks/App.framework/App are: arm64
Command PhaseScriptExecution failed with a nonzero exit code

解决方法:在终端里面进入项目根目录执行flutter clean,重新运行项目

10、通过svn上传项目后,再co下来无法运行,报错信息为:

Undefined symbols for architecture arm64:
"OBJC_CLASS$_JPushNotificationRequest", referenced from:
objc-class-ref in jpush_flutter(JPushPlugin.o)
"OBJC_CLASS$_JPUSHRegisterEntity", referenced from:
objc-class-ref in jpush_flutter(JPushPlugin.o)
"OBJC_CLASS$_JPUSHService", referenced from:
objc-class-ref in jpush_flutter(JPushPlugin.o)
"_kJPFNetworkIsConnectingNotification", referenced from:
-[JPushPlugin init] in jpush_flutter(JPushPlugin.o)
"OBJC_CLASS$_JPushNotificationIdentifier", referenced from:
objc-class-ref in jpush_flutter(JPushPlugin.o)
"OBJC_CLASS$_JPushNotificationTrigger", referenced from:
objc-class-ref in jpush_flutter(JPushPlugin.o)
"_kJPFNetworkDidRegisterNotification", referenced from:
-[JPushPlugin init] in jpush_flutter(JPushPlugin.o)
"OBJC_CLASS$_JPushNotificationContent", referenced from:
objc-class-ref in jpush_flutter(JPushPlugin.o)
"_kJPFNetworkDidSetupNotification", referenced from:
-[JPushPlugin init] in jpush_flutter(JPushPlugin.o)
"_kJPFNetworkDidCloseNotification", referenced from:
-[JPushPlugin init] in jpush_flutter(JPushPlugin.o)
"_kJPFNetworkDidLoginNotification", referenced from:
-[JPushPlugin init] in jpush_flutter(JPushPlugin.o)
"_kJPFNetworkDidReceiveMessageNotification", referenced from:
-[JPushPlugin init] in jpush_flutter(JPushPlugin.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决方法:
a、编辑 ~/.subversion/config文件
b、找到 # global-ignores=*.o *.lo *.la …… 这一行
c、删掉 # 号及其右边的 *.a
d、重新 importcheckout下来就不会有这样的问题

遇到问题不妨多试试flutter clean

二、打包过程遇到问题

1、ld: bitcode bundle could not be generated because …

解决方法:
a、修改targets => Build Setting =>Enable BitcodeNO
b、在终端中进入项目根目录,先后执行flutter cleanflutter build ios,接着就可重新打包

2、ERROR ITMS-90189: "Redundant Binary Upload. You’ve already uploaded a build with build number ‘1’ for…

解决方法:需要在targets => General => Identity 中修改对应的version以及Build,在原有基础上增加即可。

三、上架App Store遇到的问题

1、上架App Store时报错ERROR ITMS-90087: "Unsupported Architectures.The executable for …/Frameworks/Flutter.framework contains unsupported architectures ’[x86_64]’

解决方法:
targets =>Build Phases 中点击左上角加号 New Run Script Phase,在shell中添加(注意:第四行中Flutter.framework为报错信息里面的Flutter.framework)

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 'Flutter.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read    "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTAB LE_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	

2、使用Application Loader将ipa上传至App Store后,邮箱返回报错信息

ITMS-90683: Missing Purpose String in Info.plist - Your app’s code references one or more APIs that access sensitive user data. The app’s Info.plist file should contain a NSContactsUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you’re using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn’t contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).
ITMS-90683: Missing Purpose String in Info.plist - Your app’s code references one or more APIs that access sensitive user data. The app’s Info.plist file should contain a NSCalendarsUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you’re using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn’t contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

解决方法:进入项目目录下的ios => Runner,修改Info.plist,往里面增加键值对,报错信息需要什么就添加什么,全部添加也可以,最好说明该权限是用来干什么的,不然后续审核时候会被拒退。

<key>NSAppleMusicUsageDescription</key>
<string>是否允许此app访问媒体资料库</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>是否允许此app访问蓝牙</string>
<key>NSCalendarsUsageDescription</key>
<string>是否允许此app访问日历</string>
<key>NSCameraUsageDescription</key>
<string>是否允许此app访问相机</string>
<key>NSContactsUsageDescription</key>
<string>是否允许此app访问通讯录</string>
<key>NSHealthShareUsageDescription</key>
<string>是否允许此app访问健康分享</string>
<key>NSHealthUpdateUsageDescription</key>
<string>是否允许此app访问健康更新 </string>
<key>NSLocationAlwaysUsageDescription</key>
<string>是否允许此app访问位置</string>
<key>NSLocationUsageDescription</key>
<string>是否允许此app访问位置</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>是否允许此app在使用期间访问位置</string>
<key>NSMicrophoneUsageDescription</key>
<string>是否允许此app访问麦克风</string>
<key>NSMotionUsageDescription</key>
<string>是否允许此app访问运动与健身</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>是否允许此app访问相册</string>
<key>NSRemindersUsageDescription</key>
<string>是否允许此app访问提醒事项</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>是否允许此app访问语音识别</string>

如有问题,欢迎一起交流讨论。

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值