Target file "macos" not found
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
iDecode
Updated on December 28, 2022Comments
-
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 about 3 yearsdo you have flutter-specific files inside this target?
-
iDecode about 3 years@mightybruno I'm sorry I don't understand what you mean by that.
-
FDuhen about 3 yearsIf you didn't touch the files in the macos folder, did you consider removing this folder and running again the
flutter create .
method ?
-
-
iDecode about 3 yearsI already tried this command before posting the question.
-
eeqk about 3 yearssorry 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 about 3 yearshave you enabled desktop target?
flutter config --enable-macos-desktop
-
iDecode about 3 yearsI 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 tryflutter config...
command now -
eeqk about 3 yearsdoes it actually create
macos
folder? if not, try to run the command withconfig
and reruncreate
-
iDecode about 3 yearsHI, 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 didflutter 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 about 3 yearsAt least your initial problem is fixed with the "-d" param you were missing ! GL Fixing your project :)
-
iDecode about 3 yearsWhen I run the app using the command you showed, the console did show the error. So, I'll accept your answer :)
-
FDuhen about 3 yearsThis command is the one used to generate a release build
-
iDecode about 3 yearsMy bad haha. I meant is
flutter run macos
isn't essentially aflutter run -d macos
. -
iDecode about 3 yearsI'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).