Example #1
0
        /// <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);
        }
Example #2
0
        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);
        }
Example #3
0
        void _loadAllProjectInformation()
        {
            // Load all the info in the metadata file
            string projectType = _metadataDocument.GetScalarValue(new[] { "project_type" });

            switch (projectType)
            {
            case "app":
                _type = DartProjectType.App;
                break;

            case "module":
                _type = DartProjectType.Module;
                break;

            case "package":
                _type = DartProjectType.Package;
                break;

            default:
                throw new ArgumentException("Unrecognized dart project type:");
            }

            // Check che correctness for the pubspec yaml document
            CheckPubspecDocument(_pubspecDocument, _type.Value);

            _name        = _pubspecDocument.GetScalarValue(new[] { _nameYaml });
            _description = _pubspecDocument.GetScalarValue(new[] { _descriptionYaml });
            _author      = _pubspecDocument.GetScalarValue(new[] { _authorYaml });
            _homepage    = _pubspecDocument.GetScalarValue(new[] { _homepageYaml });
            _version     = _pubspecDocument.GetScalarValue(new[] { _versionYaml });

            _dependencies    = GetDependencies(_pubspecDocument);
            _devDependencies = GetDevDependencies(_pubspecDocument);
            _sdk             = _pubspecDocument.GetScalarValue(new[] { _environmentYaml, _sdkYaml });
        }