From effcc20dc247f51129069813260bf98595fe40e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wr=C3=B3blewski?= Date: Sat, 9 Mar 2024 14:08:47 +0100 Subject: [PATCH] chore: update code_push_app project --- .gitignore | 2 + example/android/app/build.gradle | 2 +- example/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/macos/Podfile | 2 +- .../macos/Runner.xcodeproj/project.pbxproj | 29 ++- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- examples/code_push_app/.gitignore | 2 - examples/code_push_app/.metadata | 34 +-- examples/code_push_app/README.md | 24 +- examples/code_push_app/analysis_options.yaml | 3 +- .../code_push_app/android/app/build.gradle | 22 +- .../android/app/src/debug/AndroidManifest.xml | 3 +- .../android/app/src/main/AndroidManifest.xml | 16 +- .../com/example/code_push_app/MainActivity.kt | 3 +- .../app/src/profile/AndroidManifest.xml | 3 +- examples/code_push_app/android/build.gradle | 15 +- .../code_push_app/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../code_push_app/android/settings.gradle | 31 ++- examples/code_push_app/assets/hot_update.evc | Bin 0 -> 206004 bytes .../.dart_eval/bindings/flutter_eval.json | 1 + examples/code_push_app/hot_update/.gitignore | 2 - examples/code_push_app/hot_update/.metadata | 4 +- .../code_push_app/hot_update/CHANGELOG.md | 4 + .../code_push_app/hot_update/pubspec.yaml | 42 +++- .../ios/Flutter/AppFrameworkInfo.plist | 2 +- .../code_push_app/ios/Flutter/Debug.xcconfig | 1 + .../ios/Flutter/Release.xcconfig | 1 + examples/code_push_app/ios/Podfile | 44 ++++ .../ios/Runner.xcodeproj/project.pbxproj | 150 ++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 13 +- examples/code_push_app/ios/Runner/Info.plist | 4 +- .../ios/RunnerTests/RunnerTests.swift | 12 + examples/code_push_app/lib/main.dart | 38 +-- examples/code_push_app/linux/CMakeLists.txt | 7 + .../code_push_app/linux/my_application.cc | 20 ++ .../macos/Flutter/Flutter-Debug.xcconfig | 1 + .../macos/Flutter/Flutter-Release.xcconfig | 1 + examples/code_push_app/macos/Podfile | 43 ++++ .../macos/Runner.xcodeproj/project.pbxproj | 232 +++++++++++++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 13 +- .../contents.xcworkspacedata | 3 + .../macos/Runner/Configs/AppInfo.xcconfig | 4 +- .../macos/Runner/MainFlutterWindow.swift | 2 +- .../macos/RunnerTests/RunnerTests.swift | 12 + examples/code_push_app/pubspec.yaml | 76 +++++- examples/code_push_app/web/index.html | 2 +- examples/code_push_app/web/manifest.json | 2 +- examples/code_push_app/windows/CMakeLists.txt | 9 +- .../windows/flutter/CMakeLists.txt | 7 +- .../code_push_app/windows/runner/Runner.rc | 2 +- .../code_push_app/windows/runner/utils.cpp | 9 +- .../windows/runner/win32_window.cpp | 2 +- .../windows/runner/win32_window.h | 2 +- 55 files changed, 819 insertions(+), 149 deletions(-) create mode 100644 examples/code_push_app/assets/hot_update.evc create mode 100644 examples/code_push_app/hot_update/.dart_eval/bindings/flutter_eval.json create mode 100644 examples/code_push_app/ios/Podfile create mode 100644 examples/code_push_app/ios/RunnerTests/RunnerTests.swift create mode 100644 examples/code_push_app/macos/Podfile create mode 100644 examples/code_push_app/macos/RunnerTests/RunnerTests.swift diff --git a/.gitignore b/.gitignore index e6f0667..1087692 100644 --- a/.gitignore +++ b/.gitignore @@ -122,8 +122,10 @@ app.*.symbols !/dev/ci/**/Gemfile.lock pubspec.lock **/*.evc +!examples/code_push_app/assets/hot_update.evc **/pubspec_overrides.yaml flutter_eval.json +!examples/code_push_app/hot_update/.dart_eval/bindings/flutter_eval.json .fvm/ .vscode/settings.json \ No newline at end of file diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6ca2344..d95b6ea 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -35,7 +35,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.example" - minSdkVersion 16 + minSdkVersion flutter.minSdkVersion targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/example/android/build.gradle b/example/android/build.gradle index c505a86..066d903 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index bc6a58a..cfe88f6 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/example/macos/Podfile b/example/macos/Podfile index dade8df..049abe2 100644 --- a/example/macos/Podfile +++ b/example/macos/Podfile @@ -1,4 +1,4 @@ -platform :osx, '10.11' +platform :osx, '10.14' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index b0494df..c4019c5 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -184,6 +184,7 @@ 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, + F963A3464E0005A7C318C3E6 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -202,7 +203,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { @@ -277,6 +278,7 @@ }; 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -312,6 +314,23 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; + F963A3464E0005A7C318C3E6 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -386,7 +405,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -465,7 +484,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -512,7 +531,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index fb7259e..5b055a3 100644 --- a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ + + + + + + + diff --git a/examples/code_push_app/android/app/src/main/kotlin/com/example/code_push_app/MainActivity.kt b/examples/code_push_app/android/app/src/main/kotlin/com/example/code_push_app/MainActivity.kt index 5b57dcb..97c055a 100644 --- a/examples/code_push_app/android/app/src/main/kotlin/com/example/code_push_app/MainActivity.kt +++ b/examples/code_push_app/android/app/src/main/kotlin/com/example/code_push_app/MainActivity.kt @@ -2,5 +2,4 @@ package com.example.code_push_app import io.flutter.embedding.android.FlutterActivity -class MainActivity: FlutterActivity() { -} +class MainActivity: FlutterActivity() diff --git a/examples/code_push_app/android/app/src/profile/AndroidManifest.xml b/examples/code_push_app/android/app/src/profile/AndroidManifest.xml index c8bc0fa..399f698 100644 --- a/examples/code_push_app/android/app/src/profile/AndroidManifest.xml +++ b/examples/code_push_app/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/examples/code_push_app/web/manifest.json b/examples/code_push_app/web/manifest.json index 3ee92d3..fa00980 100644 --- a/examples/code_push_app/web/manifest.json +++ b/examples/code_push_app/web/manifest.json @@ -32,4 +32,4 @@ "purpose": "maskable" } ] -} +} \ No newline at end of file diff --git a/examples/code_push_app/windows/CMakeLists.txt b/examples/code_push_app/windows/CMakeLists.txt index aa26640..93dfa4a 100644 --- a/examples/code_push_app/windows/CMakeLists.txt +++ b/examples/code_push_app/windows/CMakeLists.txt @@ -8,7 +8,7 @@ set(BINARY_NAME "code_push_app") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. -cmake_policy(SET CMP0063 NEW) +cmake_policy(VERSION 3.14...3.25) # Define build configuration option. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) @@ -52,6 +52,7 @@ add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") + # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) @@ -86,6 +87,12 @@ if(PLUGIN_BUNDLED_LIBRARIES) COMPONENT Runtime) endif() +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") diff --git a/examples/code_push_app/windows/flutter/CMakeLists.txt b/examples/code_push_app/windows/flutter/CMakeLists.txt index 930d207..903f489 100644 --- a/examples/code_push_app/windows/flutter/CMakeLists.txt +++ b/examples/code_push_app/windows/flutter/CMakeLists.txt @@ -10,6 +10,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake) # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") @@ -92,7 +97,7 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" - windows-x64 $ + ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS diff --git a/examples/code_push_app/windows/runner/Runner.rc b/examples/code_push_app/windows/runner/Runner.rc index 2c79d9b..27c9553 100644 --- a/examples/code_push_app/windows/runner/Runner.rc +++ b/examples/code_push_app/windows/runner/Runner.rc @@ -93,7 +93,7 @@ BEGIN VALUE "FileDescription", "code_push_app" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "InternalName", "code_push_app" "\0" - VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" + VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0" VALUE "OriginalFilename", "code_push_app.exe" "\0" VALUE "ProductName", "code_push_app" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" diff --git a/examples/code_push_app/windows/runner/utils.cpp b/examples/code_push_app/windows/runner/utils.cpp index f5bf9fa..b2b0873 100644 --- a/examples/code_push_app/windows/runner/utils.cpp +++ b/examples/code_push_app/windows/runner/utils.cpp @@ -47,16 +47,17 @@ std::string Utf8FromUtf16(const wchar_t* utf16_string) { } int target_length = ::WideCharToMultiByte( CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, nullptr, 0, nullptr, nullptr); + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); std::string utf8_string; - if (target_length == 0 || target_length > utf8_string.max_size()) { + if (target_length <= 0 || target_length > utf8_string.max_size()) { return utf8_string; } utf8_string.resize(target_length); int converted_length = ::WideCharToMultiByte( CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, utf8_string.data(), - target_length, nullptr, nullptr); + input_length, utf8_string.data(), target_length, nullptr, nullptr); if (converted_length == 0) { return std::string(); } diff --git a/examples/code_push_app/windows/runner/win32_window.cpp b/examples/code_push_app/windows/runner/win32_window.cpp index 041a385..60608d0 100644 --- a/examples/code_push_app/windows/runner/win32_window.cpp +++ b/examples/code_push_app/windows/runner/win32_window.cpp @@ -60,7 +60,7 @@ class WindowClassRegistrar { public: ~WindowClassRegistrar() = default; - // Returns the singleton registar instance. + // Returns the singleton registrar instance. static WindowClassRegistrar* GetInstance() { if (!instance_) { instance_ = new WindowClassRegistrar(); diff --git a/examples/code_push_app/windows/runner/win32_window.h b/examples/code_push_app/windows/runner/win32_window.h index c86632d..e901dde 100644 --- a/examples/code_push_app/windows/runner/win32_window.h +++ b/examples/code_push_app/windows/runner/win32_window.h @@ -77,7 +77,7 @@ class Win32Window { // OS callback called by message pump. Handles the WM_NCCREATE message which // is passed when the non-client area is being created and enables automatic // non-client DPI scaling so that the non-client area automatically - // responsponds to changes in DPI. All other messages are handled by + // responds to changes in DPI. All other messages are handled by // MessageHandler. static LRESULT CALLBACK WndProc(HWND const window, UINT const message,