Mac 上的 Flutter 项目(从 Windows 复制)
Posted
技术标签:
【中文标题】Mac 上的 Flutter 项目(从 Windows 复制)【英文标题】:Flutter project on Mac (copied from Windows) 【发布时间】:2020-04-17 09:57:27 【问题描述】:我从朋友那里收到了 Flutter 项目,用于在 Mac 上构建 ios 版本的应用程序(Catalina 和 Xcode 11.3)。 Flutter 项目是在 Windows 中制作并为 android 制作的。现在我应该在同一项目的 Mac 上制作 iOS 版本。
我和我的朋友对 Flutter 很陌生。我几乎没有 Xcode 经验(构建导出的 Unity 项目)。
我想了解 Flutter 需要做什么。我可以创建测试项目并在模拟器中运行它。但是这个项目行不通。
flutter doctor -v 的输出似乎没问题:
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57,
locale en-GB)
• Flutter version 1.12.13+hotfix.5 at
/Users/donkeygames/Development/Flutter/flutter
• Framework revision 27321ebbad (2 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/donkeygames/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3, Build version 11C29
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
[✓] Connected device (1 available)
• iPhone 11 Pro Max • 41E09B8C-2D5A-4F0E-8557-2C93BE37B6E6 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• No issues found!
我尝试清理构建文件夹并重新创建项目:
干净利落 颤振创建。
Recreating project ....
ios/.gitignore (created)
ios/Assets/.gitkeep (created)
ios/alylatu.podspec (created)
ios/Classes/TestAppPlugin.m (created)
ios/Classes/SwiftTestAppPlugin.swift (created)
ios/Classes/TestAppPlugin.h (created)
example/ios/Runner.xcworkspace/contents.xcworkspacedata (created)
example/ios/Runner/Info.plist (created)
example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
(created)
example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
(created)
example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md (created)
example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
(created)
example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.pn
g (created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.pn
g (created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json (created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
(created)
example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
(created)
example/ios/Runner/Base.lproj/LaunchScreen.storyboard (created)
example/ios/Runner/Base.lproj/Main.storyboard (created)
example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
(created)
example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (created)
example/ios/Flutter/Debug.xcconfig (created)
example/ios/Flutter/Release.xcconfig (created)
example/ios/Flutter/AppFrameworkInfo.plist (created)
example/ios/.gitignore (created)
example/test/widget_test.dart (created)
example/alylatu_example.iml (created)
example/.gitignore (created)
example/.metadata (created)
example/android/app/src/profile/AndroidManifest.xml (created)
example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png (created)
example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png (created)
example/android/app/src/main/res/drawable/launch_background.xml (created)
example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png (created)
example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png (created)
example/android/app/src/main/res/values/styles.xml (created)
example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png (created)
example/android/app/src/main/AndroidManifest.xml (created)
example/android/app/src/debug/AndroidManifest.xml (created)
example/android/gradle/wrapper/gradle-wrapper.properties (created)
example/android/gradle.properties (created)
example/android/.gitignore (created)
example/android/settings.gradle (created)
example/android/app/build.gradle (created)
example/android/app/src/main/kotlin/com/shahxad/TestApp_example/MainActivity.k
t (created)
example/android/build.gradle (created)
example/android/TestApp_example_android.iml (created)
example/pubspec.yaml (created)
example/README.md (created)
example/ios/Runner/Runner-Bridging-Header.h (created)
example/ios/Runner/AppDelegate.swift (created)
example/ios/Runner.xcodeproj/project.pbxproj (created)
example/lib/main.dart (created)
example/.idea/runConfigurations/main_dart.xml (created)
example/.idea/libraries/Flutter_for_Android.xml (created)
example/.idea/libraries/Dart_SDK.xml (created)
example/.idea/libraries/KotlinJavaRuntime.xml (created)
example/.idea/modules.xml (created)
example/.idea/workspace.xml (created)
Running "flutter pub get" in example... 4.6s
Wrote 74 files.
All done!
[✓] Flutter: is fully installed. (Channel stable, v1.12.13+hotfix.5, on Mac OS X
10.15.2 19C57, locale en-GB)
[✓] Android toolchain - develop for Android devices: is fully installed.
(Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS: is fully installed. (Xcode 11.3)
[✓] Android Studio: is fully installed. (version 3.5)
[✓] Connected device: is fully installed. (1 available)
In order to run your application, type:
$ cd example
$ flutter run
Your application code is in example/lib/main.dart.
Your plugin code is in ./lib/TestApp.dart.
Host platform code is in the "android" and "ios" directories under ..
To edit platform code in an IDE see
https://flutter.dev/developing-packages/#edit-plugin-package.
颤动运行 lib/TestApp.dart
Launching lib/TestApp.dart on iPhone 11 Pro Max in debug mode...
Expected ios/Runner.xcodeproj but this file is missing.
No application found for TargetPlatform.ios.
Is your project missing an ios/Runner/Info.plist?
Consider running "flutter create ." to create one.
flutter build ios lib/alylatu.dart
Expected ios/Runner.xcodeproj but this file is missing.
Application not configured for iOS
我什至尝试将文件从测试项目复制到 TestApp 文件夹,但没有成功。
我应该将 TestApp 项目配置为 iOS 项目吗? 我没有安装 Brew。我应该安装它和其他东西吗?
有什么想法吗?
【问题讨论】:
尝试在 projet 文件夹中运行flutter create .
。
项目是应用程序还是插件? flutter create
输出显示它为插件而不是应用程序创建文件,但您正试图将其作为应用程序运行。
一些文件丢失或者被删除运行flutter create ios
【参考方案1】:
我收到了类似以下的错误:
Expected ios/Runner.xcodeproj/project.pbxproj but this file is missing.
No application found for TargetPlatform.ios.
Is your project missing an ios/Runner/Info.plist?
Consider running "flutter create ." to create one.
问题是我从 Git 存储库中克隆了项目。 project.pbxproj 文件位于 .gitignore 中。所以,我创建了一个新的 Flutter 项目并将其他文件复制到其中。
【讨论】:
【参考方案2】:这对我有用:
1) 创建一个新的颤振项目。 2)运行项目并确保其顺利运行。 3) 验证项目运行后,转到您的新项目:
项目目录 iOS 文件夹复制以下内容:
Runner.xcodeproj 和 Runner.xcworkspace
将这些粘贴到您的旧项目(Project/ios)中,然后保存并运行。这对我有用,希望它会有所帮助。
【讨论】:
以上是关于Mac 上的 Flutter 项目(从 Windows 复制)的主要内容,如果未能解决你的问题,请参考以下文章
Flutter 中的共享首选项错误 - Mac 上的 iOS
M1 Mac 上的 Pod 安装错误 - 使用 shared_preferences 等本机代码的 Flutter 项目