Skip to content

[Add2App IOS] Instant crash on MacOS12.0.1 xcode13.1 Library not loaded: @rpath/App.framework/App #92896

Closed
@yanwei49

Description

@yanwei49

crash is run on the Device, but it is normal on the simulator,It is normal before upgrading MacOS.
current version:Swift version:5.5.1,xcode version:13.1,flutter version:2.5.3
crash:

  Referenced from: /private/var/containers/Bundle/Application/8699A097-28EB-4B42-8566-994E5EC45F52/ceshiss.app/ceshiss
  Reason: image not found
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib

Activity

mamuseferha

mamuseferha commented on Nov 2, 2021

@mamuseferha

Hi @yanwei49
Can you please provide your flutter doctor -v and a minimal complete reproducible code sample?
Thank you

added
waiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds
on Nov 2, 2021
yanwei49

yanwei49 commented on Nov 2, 2021

@yanwei49
Author

flutter doctor -v:

✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-arm, locale
    zh-Hans-CN)
    • Flutter version 2.5.3 at /Users/***/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (3 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/***/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.11.2

[✓] 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.61.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.27.0

[✓] Connected device (3 available)
    • “***”的 iPhone (mobile)      •***            • ios
      • iOS 14.7.1 18G82
    • iPhone 13 Pro Max (mobile) • 58A9B499-A057-44DC-B1D5-0E4839622795 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • Chrome (web)               • chrome                               •
      web-javascript • Google Chrome 95.0.4638.69

! Doctor found issues in 1 category.
removed
waiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds
on Nov 2, 2021
geGao123

geGao123 commented on Nov 2, 2021

@geGao123

crash is run on the Device, but it is normal on the simulator,It is normal before upgrading MacOS. current version:Swift version:5.5.1,xcode version:13.1,flutter version:2.5.3 crash: Referenced from: /private/var/containers/Bundle/Application/8699A097-28EB-4B42-8566-994E5EC45F52/ceshiss.app/ceshiss Reason: image not found dyld: launch, loading dependent libraries DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib

I have similar situation.
current version: xcode version:13.1, flutter version:2.6.0-12.0.pre.554, macOS 12.0.1
when i create a new ios project(swift),and add flutter module.run on the device and get this

crash:
Library not loaded: @rpath/App.framework/App
Referenced from: /private/var/containers/Bundle/Application/E9FD692D-A9A6-40FC-A1B3-4B1BD5121BC2/flutter_test.app/flutter_test
Reason: tried: '/usr/lib/swift/App.framework/App' (no such file), '/private/var/containers/Bundle/Application/E9FD692D-A9A6-40FC-A1B3-4B1BD5121BC2/flutter_test.app/Frameworks/App.framework/App' (no such file), '/private/var/containers/Bundle/Application/E9FD692D-A9A6-40FC-A1B3-4B1BD5121BC2/flutter_test.app/Frameworks/App.framework/App' (no such file), '/private/var/containers/Bundle/Application/E9FD692D-A9A6-40FC-A1B3-4B1BD5121BC2/flutter_test.app/Frameworks/App.framework/App' (no such file), '/usr/lib/swift/App.framework/App' (no such file), '/private/var/containers/Bundle/Application/E9FD692D-A9A6-40FC-A1B3-4B1BD5121BC2/flutter_test.app/Frameworks/App.framework/App' (no such file), 
'/private/var/containers/Bundle/Application/E9FD692D-A9A6-40FC-A1B3-4B1BD5121BC2/flutter_test.app/Frameworks/App.framework/App' (no such file), '/private/
flutter doctor -v:
[✓] Flutter (Channel master, 2.6.0-12.0.pre.554, on macOS 12.0.1 21A559 darwin-x64, locale zh-Hans-CN)
    • Flutter version 2.6.0-12.0.pre.554 at /Users/timmy/Documents/sdk/Flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6e0ba60408 (3 hours ago), 2021-11-02 03:48:04 -0400
    • Engine revision c674d2cbc6
    • Dart version 2.15.0 (build 2.15.0-268.0.dev)
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/timmy/Documents/sdk/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/timmy/Documents/sdk/Android/sdk
    • Java binary at: /Users/timmy/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7784292/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

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

[✓] Android Studio (version 2020.3)
    • 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.10+0-b96-7281165)
maheshj01

maheshj01 commented on Nov 3, 2021

@maheshj01
Member

@yanwei49 are you trying to add flutter to an existing ios app? if yes can you please refer the add to app docs and share which option are you using Option A, B or C?

Thanks

added
waiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds
on Nov 3, 2021
maheshj01

maheshj01 commented on Nov 3, 2021

@maheshj01
Member

@geGao123 The error you are hitting seems different than the one reported here, I would advise you to please file a separate issue by filling in the details requested in the issue template.

Thanks

yanwei49

yanwei49 commented on Nov 3, 2021

@yanwei49
Author

@yanwei49 are you trying to add flutter to an existing ios app? if yes can you please refer the add to app docs and share which option are you using Option A, B or C?

Thanks

I use A,It is normal before upgrading the macOS system and xcode.

removed
waiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds
on Nov 3, 2021
Aflysun

Aflysun commented on Nov 3, 2021

@Aflysun

I had the same problem, also use A ,😭

changed the title [-]Instant crash on MacOS12.0.1 xcode13.1 Library not loaded: @rpath/App.framework/App[/-] [+][Add2App IOS] Instant crash on MacOS12.0.1 xcode13.1 Library not loaded: @rpath/App.framework/App[/+] on Nov 3, 2021
maheshj01

maheshj01 commented on Nov 3, 2021

@maheshj01
Member

@yanwei49 @Aflysun I tried running this add to app sample and it's working fine for me on macOS 12.0.1 with xcode 13, so this is likely not an issue with macOS version or Xcode version, Can you please share a complete project for us to have a look.

flutter doctor -v
[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-arm, locale en-GB)
    • Flutter version 2.5.3 at /Users/mahesh/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (3 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • 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 13.0, Build version 13A233
    • CocoaPods version 1.10.2

[✓] 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)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 60.1.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (3 available)
    • iPhone 12 Pro (mobile) • B622CBB7-F906-4FA7-8F49-FACEAAC905AB • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.0.1 21A559 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 95.0.4638.69

• No issues found!

Thanks

24 remaining items

WeMadeCode

WeMadeCode commented on Nov 8, 2021

@WeMadeCode

I have try to the macOS big Sur 11.3.1 + Xcode 13.1 and it's OK。But crashed in macOS Monterey 12.0.1 + Xcode 13.1. I suspect it has something to do with the system

WeMadeCode

WeMadeCode commented on Nov 8, 2021

@WeMadeCode

I tried running this add to app sample and it's working crash for me xcode13.1:

@yanwei49 @Aflysun, I did try running with Xcode 13.1 and the ios module runs fine in Xcode.

demo link:https://gitee.com/yanwei49/flutterdemo

Even this application builds successfully.

Please make sure you are running the .xcworkspace file, You can find the steps to run the application in the readme of sample app

@maheshmnj Why don't you try it on macOS Monterey 12.0.1

maheshj01

maheshj01 commented on Nov 8, 2021

@maheshj01
Member

@WeMadeCode I did please check flutter doctor #92896 (comment)

WeMadeCode

WeMadeCode commented on Nov 8, 2021

@WeMadeCode

[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-x64, locale zh-Hans-CN)
• Flutter version 2.5.3 at /Users/xxx/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 1811693 (3 weeks ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/xxx/Library/Android/sdk
✗ cmdline-tools component is missing
Run path/to/sdkmanager --install "cmdline-tools;latest"
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.1, Build version 13A1030d
• CocoaPods version 1.11.2

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

[✓] Android Studio (version 2020.3)
• 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.10+0-b96-7281165)

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

[✓] Connected device (2 available)
• iPhone (mobile) • 29a8d86ade875cec173ae3573439551cced781cd • ios • iOS 15.0.2 19A404
• Chrome (web) • chrome • web-javascript • Google Chrome 95.0.4638.69
! Error: iPhone is not connected. Xcode will continue when iPhone is connected. (code -13)

@maheshmnj

yeatse

yeatse commented on Nov 12, 2021

@yeatse
Contributor

Same problem here on macOS 12.0.1 & Xcode 13.1.

After some investigations, I found that when building on macOS Monterey, two new load commands (LC_DYLD_EXPORTS_TRIE & LD_DYLD_CHAINED_FIXUPS) are inserted into App.framework, which makes the old version of ruby-macho not so happy.

Problem disappeared after upgrading cocoapods to 1.11.0 and ruby-macho to 2.5.1. See CocoaPods/CocoaPods#10390

DayuEJ

DayuEJ commented on Nov 26, 2021

@DayuEJ

Please try update ruby and Cocoapods to latest version. can fix it. This problem make me feel sick. it wasted my day.......fuck!!!! good luck!!!!

ManuelOrtegaSSU

ManuelOrtegaSSU commented on Nov 29, 2021

@ManuelOrtegaSSU

Same problem here on macOS 12.0.1 & Xcode 13.1.

After some investigations, I found that when building on macOS Monterey, two new load commands (LC_DYLD_EXPORTS_TRIE & LD_DYLD_CHAINED_FIXUPS) are inserted into App.framework, which makes the old version of ruby-macho not so happy.

Problem disappeared after upgrading cocoapods to 1.11.0 and ruby-macho to 2.5.1. See CocoaPods/CocoaPods#10390

This is working for me!! Thank you very much!

iamjjh

iamjjh commented on Dec 7, 2021

@iamjjh

sudo gem update ruby-macho
This is working for me

talzemingo

talzemingo commented on Dec 14, 2021

@talzemingo

Thanks iamjjh
sudo gem update ruby-macho
Works for me also

somepark

somepark commented on Dec 15, 2021

@somepark

sudo gem update ruby-macho
It's OK,Thank you!

AshineReal

AshineReal commented on Dec 22, 2021

@AshineReal

Same problem here on macOS 12.0.1 & Xcode 13.1.

After some investigations, I found that when building on macOS Monterey, two new load commands (LC_DYLD_EXPORTS_TRIE & LD_DYLD_CHAINED_FIXUPS) are inserted into App.framework, which makes the old version of ruby-macho not so happy.

Problem disappeared after upgrading cocoapods to 1.11.0 and ruby-macho to 2.5.1. See CocoaPods/CocoaPods#10390

This is right correctly solution for this problem !!!

AshineReal

AshineReal commented on Dec 22, 2021

@AshineReal

i find a way to solve this problem. 9906E9B3-E596-4371-BC17-01A43303ADFB find the pods-XXX-frameworks.sh file and add the install_framework "${PODS_ROOT}/../../flutter-camera-ui/.ios/Flutter/App.framework" in Debug and Release branch seperately (remember change your App.framework path) but i do not know why appear this problem, if someone know why please tell me.

it because , you fix procedure where really error lead to.

let's check right procedure , that should be.
podhelper.rb file which your project's podfile reference .

def install_flutter_application_pod(flutter_application_path)
  current_directory_pathname = Pathname.new File.expand_path('..', __FILE__)
  app_framework_dir = File.expand_path('App.framework', current_directory_pathname.to_path)
  app_framework_dylib = File.join(app_framework_dir, 'App')
  if !File.exist?(app_framework_dylib)
    # Fake an App.framework to have something to link against if the xcode backend script has not run yet.
    # CocoaPods will not embed the framework on pod install (before any build phases can run) if the dylib does not exist.
    # Create a dummy dylib.
    FileUtils.mkdir_p(app_framework_dir)
    `echo "static const int Moo = 88;" | xcrun clang -x c -dynamiclib -o "#{app_framework_dylib}" -`
  end

  # Keep pod and script phase paths relative so they can be checked into source control.
  # Process will be run from project directory.

  # defined_in_file is set by CocoaPods and is a Pathname to the Podfile.
  project_directory_pathname = defined_in_file.dirname
  relative = current_directory_pathname.relative_path_from project_directory_pathname
  pod 'xxxx_flutter', :path => relative.to_s, :inhibit_warnings => true

  flutter_export_environment_path = File.join('${SRCROOT}', relative, 'flutter_export_environment.sh');
  script_phase :name => 'Run Flutter Build xxxx_flutter Script',
    :script => "set -e\nset -u\nsource \"#{flutter_export_environment_path}\"\nexport VERBOSE_SCRIPT_LOGGING=1 && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build",
    :execution_position => :before_compile
end

it insert a build phase (Run Flutter Build xxxx_flutter Script) before compile ,
it run other script which can be found in FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.dart
notice params 'build'
func buildApp() build the app.framework and make it into your_flutter_project/.ios/Flutter directory.

then Embed Pods Frameworks script should embed app.framework which build last step. (which the script is generated by pod install)

final your flutter project is build & embed into your ios host project.

Now error comes from pod install , where ruby-macho could not recognize new mach load command . detail see ref:#92896 (comment)

so Pods-xxxx-frameworks generated with error effect install_framework line , that 's no app.framework path mention on it !!!

your fix solution mention the app.framework path , app.framework can be found and embed into your ios host project.

hope it clear to solve your question.

github-actions

github-actions commented on Jan 5, 2022

@github-actions

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

locked as resolved and limited conversation to collaborators on Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @yeatse@geGao123@iamjjh@yanwei49@somepark

        Issue actions

          [Add2App IOS] Instant crash on MacOS12.0.1 xcode13.1 Library not loaded: @rpath/App.framework/App · Issue #92896 · flutter/flutter