使用 Flutter 在 Windows 环境中为 iOS 设备开发
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47006906/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Developing for iOS device in Windows environment with Flutter
提问by YYY
I'm new to Flutter, was just wondering if it's possible.
我是 Flutter 的新手,只是想知道这是否可能。
I've tried building the demo code using intellij with given instruction (https://flutter.io/setup/). It runs well on android device, but can't find the option to compile and run on my iOS device.
我已经尝试使用具有给定指令(https://flutter.io/setup/)的intellij 构建演示代码。它在 android 设备上运行良好,但找不到在我的 iOS 设备上编译和运行的选项。
回答by Suragch
You can do your main development on Linux or Windows with Android Studio or Visual Studio Code. Then use git to move the code to macOS to test it with Xcode on an iOS simulator/device and deploy it to the App Store.
您可以使用 Android Studio 或 Visual Studio Code 在 Linux 或 Windows 上进行主要开发。然后使用 git 将代码移动到 macOS 以在 iOS 模拟器/设备上使用 Xcode 进行测试并将其部署到 App Store。
You could do all development on macOS but you can't do all development on Linux or Windows. I'm not too pleased with Apple for making overpriced machines and then forcing us to buy them. Since I can't afford a fast Apple computer, I am planning to do most of my development on Linux and then just do testing and deployment on my painfully slow Mac Mini.
您可以在 macOS 上进行所有开发,但不能在 Linux 或 Windows 上进行所有开发。我对苹果制造价格过高的机器然后强迫我们购买它们不太满意。由于我买不起快速的 Apple 计算机,因此我计划在 Linux 上进行大部分开发工作,然后只在速度缓慢的 Mac Mini 上进行测试和部署。
Update
更新
It seems like there are more possibilities now. Read the following articles:
现在似乎有更多的可能性。阅读以下文章:
- How to sign Flutter apps for iOS automatically without a Mac
- Developing and debugging Flutter apps for iOS without a Mac
Personally, I ended up buying a MacBook Pro for way too much money. I have to admit that it is convenient, but I have done very little up to this point that really required it. I'm doing all of my learning and development in Android Studio and usually use the Android emulator. Every now and then I fire up the iOS simulator, but I haven't been required to.
就个人而言,我最终花了太多钱买了一台 MacBook Pro。我不得不承认它很方便,但到目前为止我几乎没有做真正需要它的事情。我所有的学习和开发都在 Android Studio 中进行,通常使用 Android 模拟器。我时不时地启动 iOS 模拟器,但我没有被要求启动。
My advice is to keep using your current system (Windows or Linux) for as long as you are learning and even while you are developing your first Flutter apps. Eventually you may appreciate the convenience of having the iOS Simulator and Xcode on the same machine, but there is certainly no rush.
我的建议是,只要你在学习,甚至在你开发你的第一个 Flutter 应用程序时,就继续使用你当前的系统(Windows 或 Linux)。最终,您可能会欣赏在同一台机器上安装 iOS 模拟器和 Xcode 的便利,但当然不会着急。
回答by Payam Khaninejad
You could do that with a Mac (or Hackintosh, or VM), but since we don't have access to a macOS machine we can use one remotely via Codemagicor Travis CI?—?completely free! (as long as your project is on a GitHub, Bitbucket or GitLab repository).
您可以使用 Mac(或 Hackintosh 或 VM)来做到这一点,但由于我们无法访问 macOS 机器,我们可以通过Codemagic或Travis CI远程使用一台?——完全免费!(只要您的项目位于 GitHub、Bitbucket 或 GitLab 存储库上)。
First, create an account or sign in to codemagic.io.
首先,创建一个帐户或登录codemagic.io。
Then, click the settings (gear) icon next to your app. Scroll down and click on “Build”. Make sure Mode is set to Debug, and select iOS under Build for platforms.
然后,单击应用旁边的设置(齿轮)图标。向下滚动并单击“构建”。确保 Mode 设置为 Debug,并在 Build for platform 下选择 iOS。
After that, build the app (Start your first build).
之后,构建应用程序(开始您的第一个构建)。
Codemagic will send you an .appfile via email. Rename it so that it ends with .zip. Extract it, and you'll get a folder called Runner.app. Create a folder called Payload and place Runner.app there. Finally , compress the folder called Payload?—?this will be your IPA file (you may rename it to .ipa).
Codemagic 将通过电子邮件向您发送一个.app文件。重命名它,使其以 .zip 结尾。解压它,你会得到一个名为 Runner.app 的文件夹。创建一个名为 Payload 的文件夹并将 Runner.app 放在那里。最后,压缩名为 Payload?-? 的文件夹,这将是您的 IPA 文件(您可以将其重命名为.ipa)。
Alternative: Building the app with Travis CIYou'll need to create an account on Travis CI and let it access your GitHub account.
替代方案:使用Travis CI构建应用程序 您需要在 Travis CI 上创建一个帐户并让它访问您的 GitHub 帐户。
Then, create .travis.yml on the root of your project with the following contents:
然后,使用以下内容在项目的根目录上创建 .travis.yml:
os: osx
language: generic
before_script:
- brew update
- brew install --HEAD usbmuxd
- brew unlink usbmuxd
- brew link usbmuxd
- brew install --HEAD libimobiledevice
- brew install ideviceinstaller
- brew install ios-deploy
- git clone https://github.com/flutter/flutter.git -b beta --depth 1
script:
- flutter/bin/flutter build ios --debug --no-codesign
cache:
directories:
- $HOME/.pub-cache
before_deploy:
- pushd build/ios/iphoneos
- mkdir Payload
- cd Payload
- ln -s ../Runner.app
- cd ..
- zip -r app.ipa Payload
- popd
回答by creativecreatorormaybenot
Apple has made compiling of iOS applications exclusively avaible to macOS.
Apple 已将 iOS 应用程序的编译专门用于 macOS。
You can read through this answer and threadto look into workarounds for getting it to work on Windows.
您可以通读此答案和线程,以研究使其在 Windows 上运行的变通方法。
Basically there is noother way for Flutter, but Xamarinand NativeScriptprovide support for it.
Flutter基本上没有其他方法,但Xamarin和NativeScript提供了支持。
回答by Pouya Samie
you can read this article
你可以阅读这篇文章
it uses some tools and CodeMagicto build Flutter app for Ios.
它使用一些工具和CodeMagic为 Ios 构建 Flutter 应用程序。
- put your app on GitHub (public) and give access to codemagic
- then you should build your app using code magic for IOS.
- then you should use Cydia Impactor for signing the file that CodeMagic has sent to you
- prepare your windows machine by installing libimobiledevice , ideviceinstaller,which.
- Modify Flutter code to not looking for Xcode
- Running and debugging
- 将您的应用程序放在 GitHub(公共)上并授予对codemagic 的访问权限
- 那么您应该使用适用于 IOS 的代码魔术来构建您的应用程序。
- 那么您应该使用 Cydia Impactor 对 CodeMagic 发送给您的文件进行签名
- 通过安装 libimobiledevice 、 ideviceinstaller 来准备你的 Windows 机器。
- 将 Flutter 代码修改为不查找 Xcode
- 运行调试
I have used this method it works fine you can hot reload and debug your app the downside is you have to enter apple id password in Cydia Impactor which for sure you should use a second apple id and after apple provisioning profile expiring you should sign your code with Cydia Impactor again. but it's so much cheaper than by a Mac or rent one.
我已经使用了这种方法,它工作正常,您可以热重新加载和调试您的应用程序,缺点是您必须在 Cydia Impactor 中输入 apple id 密码,这肯定您应该使用第二个 apple id,并且在 apple provisioning profile 到期后您应该签署您的代码再次使用 Cydia Impactor。但它比使用 Mac 或租用 Mac 便宜得多。
回答by emanuel sanga
I suggest you use a virtual machine to do your thing.. I had a Mojave MacOS installed on my Windows 10 and I had things running smoothly!
我建议你使用虚拟机来做你的事情..我在我的 Windows 10 上安装了 Mojave MacOS,并且运行顺利!
A Mojave image can be got from https://getintopc.com/softwares/operating-systems/mac-os-mojave-10-14-1-vmware-image-free-download/
Mojave 映像可以从https://getintopc.com/softwares/operating-systems/mac-os-mojave-10-14-1-vmware-image-free-download/ 获取
I found this useful as I had some things that I wanted out of the Mac world while I had a dell latitude.
我发现这很有用,因为我有一些我想要离开 Mac 世界的东西,而我有戴尔的纬度。
回答by Ned
I personally use Macincloud.com. While not free, it is a very cheap option compared to buying a Mac and much easier than trying to create a hackintosh VM. For the limited amount of dev required on a Mac for Flutter applications, this was a perfect solution for me.
我个人使用Macincloud.com。虽然不是免费的,但与购买 Mac 相比,这是一个非常便宜的选择,而且比尝试创建 hackintosh 虚拟机要容易得多。对于 Mac 上 Flutter 应用程序所需的有限开发量,这对我来说是一个完美的解决方案。