【问题标题】:App stop running on iOS after upgrading Flutter and Xcode升级 Flutter 和 Xcode 后 App 在 iOS 上停止运行
【发布时间】:2021-08-31 23:39:17
【问题描述】:

升级 Flutter 2.2.0 和 Xcode 12.4 后,iOS 应用程序停止从 IDE 运行。但是,当我从 Xcode 本身运行时,应用程序会运行。

这里有一些日志可供查看。

Flutter 运行控制台输出

Launching lib/main.dart on iPhone SE (2nd generation) in debug mode...
Xcode build done.                                           38.3s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    1 warning generated.
    10 warnings generated.
    /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.m:309:42: warning: comparison of distinct pointer types ('NSString *' and 'NSNull * _Nonnull') [-Wcompare-distinct-pointer-types]
        if (_stripeAccount && _stripeAccount != [NSNull null]) {
                              ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
    /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.m:731:42: warning: 'startPollingSourceWithId:clientSecret:timeout:completion:' is deprecated: You should poll your own backend to update based on source status change webhook events it may receive. [-Wdeprecated-declarations]
                            [stripeAPIClient startPollingSourceWithId:sourceID clientSecret:clientSecret timeout:10 completion:^(STPSource *source, NSError *error) {
                                             ^
    In module 'Stripe' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:11:
    /Users/pc/Desktop/Kishan/touch_ticket_client_app/ios/Pods/Stripe/Stripe/PublicHeaders/STPAPIClient.h:370:243: note: 'startPollingSourceWithId:clientSecret:timeout:completion:' has been explicitly marked deprecated here
    - (void)startPollingSourceWithId:(NSString *)identifier clientSecret:(NSString *)secret timeout:(NSTimeInterval)timeout completion:(STPSourceCompletionBlock)completion NS_EXTENSION_UNAVAILABLE("Source polling is not available in extensions") DEPRECATED_MSG_ATTRIBUTE("You should poll your own backend to update based on source status change webhook events it may receive.");
                                                                                          ^
    In module 'Foundation' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:9:
    In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
    In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/AvailabilityMacros.h:183:64: note: expanded from macro 'DEPRECATED_MSG_ATTRIBUTE'
                #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
                                                                   ^
    /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.m:798:20: warning: 'setPublishableKey:' is deprecated: If you used [STPPaymentConfiguration sharedConfiguration].publishableKey, use [STPAPIClient sharedClient].publishableKey instead. If you passed a STPPaymentConfiguration instance to an SDK component, create an STPAPIClient, set publishableKey on it, and set the SDK component's APIClient property. [-Wdeprecated-declarations]
        [configuration setPublishableKey:nextPublishableKey];
                       ^
    In module 'Stripe' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:11:
    /Users/pc/Desktop/Kishan/touch_ticket_client_app/ios/Pods/Stripe/Stripe/PublicHeaders/STPPaymentConfiguration.h:126:50: note: property 'publishableKey' is declared deprecated here
    @property (nonatomic, copy, readwrite) NSString *publishableKey DEPRECATED_MSG_ATTRIBUTE("If you used [STPPaymentConfiguration sharedConfiguration].publishableKey, use [STPAPIClient sharedClient].publishableKey instead. If you passed a STPPaymentConfiguration instance to an SDK component, create an STPAPIClient, set publishableKey on it, and set the SDK component's APIClient property.");
                                                     ^
    /Users/pc/Desktop/Kishan/touch_ticket_client_app/ios/Pods/Stripe/Stripe/PublicHeaders/STPPaymentConfiguration.h:126:65: note: 'setPublishableKey:' has been explicitly marked deprecated here
    @property (nonatomic, copy, readwrite) NSString *publishableKey DEPRECATED_MSG_ATTRIBUTE("If you used [STPPaymentConfiguration sharedConfiguration].publishableKey, use [STPAPIClient sharedClient].publishableKey instead. If you passed a STPPaymentConfiguration instance to an SDK component, create an STPAPIClient, set publishableKey on it, and set the SDK component's APIClient property.");
                                                                    ^
    In module 'Foundation' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:9:
    In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
    In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/AvailabilityMacros.h:183:64: note: expanded from macro 'DEPRECATED_MSG_ATTRIBUTE'
                #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
                                                                   ^
    /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.m:1104:23: warning: 'metadata' is deprecated: Metadata is no longer returned to clients using publishable keys. Retrieve them on your server using yoursecret key instead. [-Wdeprecated-declarations]
                 TPSEntry(metadata),
                          ^
    In module 'Stripe' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:11:
    /Users/pc/Desktop/Kishan/touch_ticket_client_app/ios/Pods/Stripe/Stripe/PublicHeaders/STPPaymentMethod.h:138:89: note: 'metadata' has been explicitly marked deprecated here
    @property (nonatomic, nullable, readonly) NSDictionary<NSString*, NSString *> *metadata DEPRECATED_MSG_ATTRIBUTE("Metadata is no longer returned to clients using publishable keys. Retrieve them on your server using yoursecret key instead.");
                                                                                          ^
    In module 'Foundation' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:9:
    In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
    In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/AvailabilityMacros.h:183:64: note: expanded from macro 'DEPRECATED_MSG_ATTRIBUTE'
                #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
                                                                   ^
    /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.m:1377:16: warning: 'metadata' is deprecated: Metadata is no longer returned to clients using publishable keys. Retrieve them on your server using yoursecret key instead. [-Wdeprecated-declarations]
        if (source.metadata) {
                   ^
    In module 'Stripe' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:11:
    /Users/pc/Desktop/Kishan/touch_ticket_client_app/ios/Pods/Stripe/Stripe/PublicHeaders/STPSource.h:143:89: note: 'metadata' has been explicitly marked deprecated here
    @property (nonatomic, nullable, readonly) NSDictionary<NSString*, NSString *> *metadata DEPRECATED_MSG_ATTRIBUTE("Metadata is no longer returned to clients using publishable keys. Retrieve them on your server using yoursecret key instead.");
                                                                                          ^
    In module 'Foundation' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:9:
    In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
    In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/AvailabilityMacros.h:183:64: note: expanded from macro 'DEPRECATED_MSG_ATTRIBUTE'
                #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
                                                                   ^
    /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.m:1378:33: warning: 'metadata' is deprecated: Metadata is no longer returned to clients using publishable keys. Retrieve them on your server using yoursecret key instead. [-Wdeprecated-declarations]
            [result setValue:source.metadata forKey:@"metadata"];
                                    ^
    In module 'Stripe' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:11:
    /Users/pc/Desktop/Kishan/touch_ticket_client_app/ios/Pods/Stripe/Stripe/PublicHeaders/STPSource.h:143:89: note: 'metadata' has been explicitly marked deprecated here
    @property (nonatomic, nullable, readonly) NSDictionary<NSString*, NSString *> *metadata DEPRECATED_MSG_ATTRIBUTE("Metadata is no longer returned to clients using publishable keys. Retrieve them on your server using yoursecret key instead.");
                                                                                          ^
    In module 'Foundation' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:9:
    In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
    In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/usr/include/AvailabilityMacros.h:183:64: note: expanded from macro 'DEPRECATED_MSG_ATTRIBUTE'
                #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
                                                                   ^
    /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.m:1731:16: warning: 'STPBillingAddressFieldsZip' is deprecated: Use STPBillingAddressFieldsPostalCode [-Wdeprecated-declarations]
            return STPBillingAddressFieldsZip;
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
                   STPBillingAddressFieldsPostalCode
    In module 'Stripe' imported from /Users/pc/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/stripe_payment-1.0.10/ios/Classes/TPSStripeManager.h:11:
    /Users/pc/Desktop/Kishan/touch_ticket_client_app/ios/Pods/Stripe/Stripe/PublicHeaders/STPAddress.h:48:47: note: 'STPBillingAddressFieldsZip' has been explicitly marked deprecated here
        STPBillingAddressFieldsZip __attribute__((deprecated("Use STPBillingAddressFieldsPostalCode", "STPBillingAddressFieldsPostalCode"))) = STPBillingAddressFieldsPostalCode,
                                                  ^
    7 warnings generated.
    ld: building for iOS Simulator, but linking in object file built for iOS, file '/Users/pc/Desktop/Kishan/touch_ticket_client_app/ios/Pods/Stripe/InternalFrameworks/libStripe3DS2.a' for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Toast' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flutter' from project 'Pods')
Could not build the application for the simulator.
Error launching application on iPhone SE (2nd generation).
Exited (sigterm)

Flutter Doctor -v 输出

[✓] Flutter (Channel stable, 2.2.1, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-IN)
    • Flutter version 2.2.1 at /Users/pc/Desktop/flutter
    • Framework revision 02c026b03c (3 weeks ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/pc/Library/Android/sdk
    • Platform android-S, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

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

[✓] Connected device (2 available)
    • iPhone SE (2nd generation) (mobile) • 1996F394-57D4-419A-ABB6-C55113BED393 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • Chrome (web)                        • chrome                               • web-javascript • Google Chrome 91.0.4472.106

• No issues found!

到目前为止我所做的尝试:

1) 干净构建并运行

flutter clean
flutter build ios
flutter run

2) 执行命令后再次运行

flutter clean && \
rm ios/Podfile ios/Podfile.lock pubspec.lock && \
rm -rf ios/Pods ios/Runner.xcworkspace && \ 
flutter run

3) 删除 WorkspaceSettings.xcsettings 文件

rm -f ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

4) 修复的 PUB 捕获

flutter pub cache repair 

【问题讨论】:

  • 这是通过ios模拟器还是通过您自己的设备?
  • 我都试过了,结果一样。
  • 您使用的是旧版本的 stripe_payment,更新到最新版本可能会解决问题

标签: xcode flutter


【解决方案1】:

您是否尝试运行这些命令?升级我的 Flutter 项目后,我也遇到了同样的问题,使用这些命令我能够在 iOS 上再次运行我的项目。

cd ios
pod deintegrate
rm Flutter/Flutter.podspec
rm podfile.lock
pod init 
pod install
flutter clean
flutter pub get
flutter run

并确保您的 podfile 中有 flutter_additional_ios_build_settings。

这通常是我的。

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
      config.build_settings['SWIFT_VERSION'] = '5.0' 
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
    flutter_additional_ios_build_settings(target)
  end
end

此外,请考虑使用pod install --repo-update 而不是pod install

另外,您可以尝试通过 .xcworkspace 文件在 Xcode 中运行您的项目吗?以我的经验,Xcode 在 iOS 模拟器上构建它没有问题,但颤振不能。所以我想弄清楚你是否遇到了和我一样的问题。

编辑:我还建议您将 Stripe 库更新到最新版本。

【讨论】:

  • @kishandhankecha 你有那个警告'iOS 模拟器部署目标',所以你需要先配置你的 podfile。如果您确实对 podfile、Xcode 配置文件或收到不同的错误消息等进行了任何更改,您能否更新问题以便社区可以快速帮助您。
  • 是的,我对 podfile 进行了更改,但我更新了 ios build 并且我还将 pods od ios 项目更新为 New Podfile
  • 我在收到错误后将IPHONEOS_DEPLOYMENT_TARGET 更改为14。这解决了错误日志中显示的警告,但我的构建没有运行。那是我的问题
  • 虽然如果我通过 Xcode 运行我的应用程序,它也会运行。问题是它没有从 android studio 或 VSCode 等任何 IDE 运行。
  • 是的@kishandhankecha 我了解你的情况。昨天我也发生了同样的事情,我在这里发布了一个问题:stackoverflow.com/questions/68206955/…
【解决方案2】:

我之前也遇到过这个兼容性问题,但是因为项目不同,有
没有固定答案;

Step 1. 备份已有项目(我一般是直接创建压缩包);

第 2 步。使用 iOS 模拟器部署目标,更改为支持的最低版本 ios 9 而不是 iOS 8。(尝试运行)

第三步,根据日志提示,对代码进行一一调整,包括更换弃用方法、更新第三方库等。

重要提示:错误日志是你最好的帮手,按照说明处理,问题一定会解决的。

【讨论】:

  • 现在我认为解决这个问题的最佳方法是创建新的颤振项目,然后从现有项目中复制项目中重要的文件。
  • 解决问题是最终目的,方法不重要。@kishandhankecha
【解决方案3】:

经过多次尝试和应用可能的解决方案,现在我认为这个问题的答案取决于项目和依赖关系,不可能只有一个完美的解决方案。

- 从我这边来解决这个问题我所做的是:

  • 备份现有项目。
  • 创建一个新的颤振项目。
  • 将上述文件从现有项目复制到您刚刚创建的新项目中。

文件

 pubspec.yaml
 Androidmanifest.xml

文件夹

 assets
 lib

  • 除此文件和文件夹外,您还必须复制您在项目的 Android 或 ios 文件夹中手动更新的文件。

确保复制了项目所需的所有文件和文件夹后,尝试运行新创建的 Flutter 项目。

【讨论】:

    【解决方案4】:

    我更新了我的 firebase packege(如果你有的话,就这样做)然后:

    cd ios
    rm podfile.lock
    flutter clean
    flutter pub get
    pod install
    

    最后从代码product-&gt;clean build folder 清理项目然后从代码运行它

    希望能解决问题

    【讨论】:

    • 我从 Xcode 完成了干净的构建文件夹以及您提到的命令。
    猜你喜欢
    • 2021-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-04
    • 2021-08-18
    • 2021-11-15
    • 1970-01-01
    相关资源
    最近更新 更多