/// <summary> /// Returns the path of the iOS XCFramework created when building a Flutter 2.* module /// and used for integrating Flutter into a native iOS app. /// </summary> public string GetIosXCFrameworkPath(FlutterModuleBuildConfig buildConfig) { Load(); switch (Type) { case DartProjectType.Module: return(GetIosXCFrameworkPath(_workingDir.FullName, _pubspecDocument, buildConfig)); default: throw new InvalidOperationException("This method is designed for Flutter modules only."); } }
/// <summary> /// Runs the "flutter build ios-framework" command to create an iOS framework /// to be integrated into a native iOS application (available only on macOS). /// </summary> public static void BuildIosFramework(string projectFolder, FlutterModuleBuildConfig buildConfig, bool verbose = false) { StringBuilder sb = new StringBuilder(); sb.Append("flutter build ios-framework "); if (buildConfig != FlutterModuleBuildConfig.Default) { if (!buildConfig.HasFlag(FlutterModuleBuildConfig.Debug)) { sb.Append("--no-debug "); } if (!buildConfig.HasFlag(FlutterModuleBuildConfig.Profile)) { sb.Append("--no-profile "); } if (!buildConfig.HasFlag(FlutterModuleBuildConfig.Release)) { sb.Append("--no-release "); } } FlutnetShell.RunCommand(sb.ToString(), projectFolder, verbose); }
/// <summary> /// Returns the path of the iOS Framework created when building a Flutter 1.* module with Flutter. /// </summary> public static string GetIosFrameworkPath(string flutterFolder, YamlDocument pubspecFile, FlutterModuleBuildConfig buildConfig) { return(GetIosFrameworkPathCore(flutterFolder, pubspecFile, buildConfig, false)); }
private static string GetIosFrameworkPathCore(string flutterFolder, YamlDocument pubspecFile, FlutterModuleBuildConfig buildConfig, bool xcframework) { // Please consider a Flutter module created with the following command: // // flutter create -t module --org com.example hello_world // // Now, build the module for iOS integration: // // flutter build ios-framework // // The output framework for Debug configuration is located under: // // <MODULE_FOLDER>\build\ios\Debug\App.xcframework (Flutter 2.*) // // or // // <MODULE_FOLDER>\build\ios\Debug\App.framework (Flutter 1.*) // <MODULE_FOLDER>\build\ios\framework\ string frameworkRootFolder = Path.Combine(flutterFolder, "build", "ios", "framework"); // Find the 'iosBundleIdentifier' info from the pubspec.yaml file string bundle = pubspecFile.GetScalarValue(new [] { "flutter", "module", "iosBundleIdentifier" }); string build; switch (buildConfig) { case FlutterModuleBuildConfig.Debug: build = "Debug"; break; case FlutterModuleBuildConfig.Profile: build = "Profile"; break; case FlutterModuleBuildConfig.Release: build = "Release"; break; default: throw new ArgumentOutOfRangeException(nameof(buildConfig), buildConfig, null); } // <MODULE_FOLDER>\build\ios\Debug\App.framework string path = Path.Combine(frameworkRootFolder, build, xcframework ? "App.xcframework" : "App.framework"); return(path); }
/// <summary> /// Returns the path of the Android AAR created when building a Flutter module. /// </summary> public static string GetAndroidArchivePath(string flutterFolder, YamlDocument pubspecFile, FlutterModuleBuildConfig buildConfig) { // Please consider a Flutter module created with the following command: // // flutter create -t module --org com.example hello_world // // Now, build the module for Android integration: // // flutter build aar // // The output AAR for Debug configuration is located under: // // <MODULE_FOLDER>\build\host\outputs\repo\com\example\hello_world\flutter_debug\1.0\flutter_debug-1.0.aar // <MODULE_FOLDER>\build\host\outputs\repo\ string repoRootFolder = Path.Combine(flutterFolder, "build", "host", "outputs", "repo"); // Find the 'androidPackage' info from the pubspec.yaml file string package = pubspecFile.GetScalarValue(new [] { "flutter", "module", "androidPackage" }); // <MODULE_FOLDER>\build\host\outputs\repo\com\example\hello_world\ string packageRootFolder = repoRootFolder; string[] packageFolders = string.IsNullOrEmpty(package) ? new string[0] : package.Split("."); foreach (string folder in packageFolders) { packageRootFolder = Path.Combine(packageRootFolder, folder); } string version = "1.0"; string build; switch (buildConfig) { case FlutterModuleBuildConfig.Debug: build = "debug"; break; case FlutterModuleBuildConfig.Profile: build = "profile"; break; case FlutterModuleBuildConfig.Release: build = "release"; break; default: throw new ArgumentOutOfRangeException(nameof(buildConfig), buildConfig, null); } // <MODULE_FOLDER>\build\host\outputs\repo\com\example\hello_world\flutter_debug\1.0\flutter_debug-1.0.aar string path = Path.Combine(packageRootFolder, $"flutter_{build}", version, $"flutter_{build}-{version}.aar"); return(path); }