Target file "macos" not found

756

Solution 1

You're missing a param in your command.
Run flutter run -d macos and it should work smoothly :)

Solution 2

delete macos and then run flutter create . inside your project root, it will generate missing targets without touching existing ones

Share:
756
iDecode
Author by

iDecode

Updated on December 28, 2022

Comments

  • iDecode
    iDecode over 1 year

    I can successfully build an iOS app with

    flutter build ios
    

    But when I try to turn the app in macOS using

    flutter run macos
    

    I get this error

    Target file "macos" not found.

    Although I have macos directory in my project root. But still I'm unable to run the app in macOS.


    Update

    After deleting macos folder and running flutter create .

    Recreating project .... macos/Runner.xcworkspace/contents.xcworkspacedata (created) macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (created) macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png (created) macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png (created) macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png (created) macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png (created) macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png (created) macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png (created) macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (created) macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png (created) macos/Runner/DebugProfile.entitlements (created) macos/Runner/Base.lproj/MainMenu.xib (created) macos/Runner/MainFlutterWindow.swift (created) macos/Runner/Configs/Debug.xcconfig (created) macos/Runner/Configs/Release.xcconfig (created) macos/Runner/Configs/Warnings.xcconfig (created) macos/Runner/Configs/AppInfo.xcconfig (created) macos/Runner/AppDelegate.swift (created) macos/Runner/Info.plist (created) macos/Runner/Release.entitlements (created) macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (created) macos/Runner.xcodeproj/project.pbxproj (created) macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (created) macos/Flutter/Flutter-Debug.xcconfig (created) macos/Flutter/Flutter-Release.xcconfig (created) macos/.gitignore (created) Running "flutter pub get" in practice... 2,611ms Wrote 29 files.

    All done! In order to run your application, type: $ cd . $ flutter run Your application code is in ./lib/main.dart.

    And now if I run flutter run macos, it again gives me the same error:

    Target file "macos" not found.

    Update-2

    I just ran flutter build macos and found that there are some errors in particular to macos. I think I need to resolve them first in order to make the app run in macos.

    • eeqk
      eeqk about 3 years
      do you have flutter-specific files inside this target?
    • iDecode
      iDecode about 3 years
      @mightybruno I'm sorry I don't understand what you mean by that.
    • FDuhen
      FDuhen about 3 years
      If you didn't touch the files in the macos folder, did you consider removing this folder and running again the flutter create . method ?
  • iDecode
    iDecode about 3 years
    I already tried this command before posting the question.
  • eeqk
    eeqk about 3 years
    sorry for misleading you, but you're right. You'd have to replace temp with your project name. I've tried running the command I've posted above and it created only missing targets
  • eeqk
    eeqk about 3 years
    have you enabled desktop target? flutter config --enable-macos-desktop
  • iDecode
    iDecode about 3 years
    I deleted the macos folder, ran the flutter create . it does show creation of files in the terminal but when I run the app, it again gives me the same error. Let me try flutter config... command now
  • eeqk
    eeqk about 3 years
    does it actually create macos folder? if not, try to run the command with config and rerun create
  • iDecode
    iDecode about 3 years
    HI, thanks for your input. I just realized there's an error in my project (only for macos), when I run flutter build ios, it builds. But I just did flutter build macos and I started seeing some error which I believe is the root cause of not making the app run in macos. Although the error is completely different but I think this could be an isue.
  • FDuhen
    FDuhen about 3 years
    At least your initial problem is fixed with the "-d" param you were missing ! GL Fixing your project :)
  • iDecode
    iDecode about 3 years
    When I run the app using the command you showed, the console did show the error. So, I'll accept your answer :)
  • FDuhen
    FDuhen about 3 years
    This command is the one used to generate a release build
  • iDecode
    iDecode about 3 years
    My bad haha. I meant is flutter run macos isn't essentially a flutter run -d macos.
  • iDecode
    iDecode about 3 years
    I'll upvote your post for sure, because now my app is up and running. I think config also played some role (although the main issue were the errors).