From 577abbedd12ac0e4dcb38a1d4bf93adcde6f36d0 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 18 Jun 2024 14:36:59 -0400 Subject: [PATCH 1/2] fix: flutter analyze issues --- .github/workflows/android.yml | 27 +++++++++++++++++++++++++++ .github/workflows/iOS.yml | 23 +++++++++++++++++++++++ .pre-commit-config.yaml | 6 ++++++ ios/Runner.xcodeproj/project.pbxproj | 20 ++++++++++++++++++++ ios/Runner/Runner.entitlements | 16 ++++++++++++++++ lib/main.dart | 7 ++++--- pubspec.yaml | 2 +- test/widget_test.dart | 12 ------------ 8 files changed, 97 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/android.yml create mode 100644 .github/workflows/iOS.yml create mode 100644 .pre-commit-config.yaml create mode 100644 ios/Runner/Runner.entitlements diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..44106eb --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,27 @@ +name: android workflow +on: +# schedule: +# - cron: "10 16 * * *" + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: '11' + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + - run: flutter pub get + - run: flutter test + - run: flutter build apk + - run: flutter build appbundle diff --git a/.github/workflows/iOS.yml b/.github/workflows/iOS.yml new file mode 100644 index 0000000..e577b69 --- /dev/null +++ b/.github/workflows/iOS.yml @@ -0,0 +1,23 @@ +name: iOS workflow +on: +# schedule: +# - cron: "10 16 * * *" + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 + with: + channel: 'stable' + architecture: x64 + - run: flutter pub get + - run: flutter test + - run: flutter build ios --release --no-codesign diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ef611ba --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: +- repo: https://github.com/dluksza/flutter-analyze-pre-commit + rev: "master" + hooks: + - id: flutter-analyze + args: [lib/*] diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 2fe7116..1544458 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -64,6 +64,7 @@ 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 98E3745CEF4D816C84FD66B5 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; AB6D9FCF30A11DCC4DD21990 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C27E012A2C21FAFD00A124DE /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; C649AD602487CF64D1C879B0 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -152,6 +153,7 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( + C27E012A2C21FAFD00A124DE /* Runner.entitlements */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, @@ -469,17 +471,23 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = FM3W26J2BY; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "Unofficial tpl app"; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.education"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.sangshuduo.unofficialtpl; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -653,17 +661,23 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = FM3W26J2BY; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "Unofficial tpl app"; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.education"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.sangshuduo.unofficialtpl; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -677,17 +691,23 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = FM3W26J2BY; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "Unofficial tpl app"; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.education"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 1.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.sangshuduo.unofficialtpl; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements new file mode 100644 index 0000000..912ea3c --- /dev/null +++ b/ios/Runner/Runner.entitlements @@ -0,0 +1,16 @@ + + + + + com.apple.developer.associated-domains + + tpl.ca + + com.apple.developer.authentication-services.autofill-credential-provider + + keychain-access-groups + + $(AppIdentifierPrefix)com.sangshuduo.unofficialtpl + + + diff --git a/lib/main.dart b/lib/main.dart index e834dbe..aade982 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -33,12 +33,13 @@ class MyApp extends StatelessWidget { colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), - home: UnofficialTPLca(), + home: const UnofficialTPLca(), ); } } class UnofficialTPLca extends StatefulWidget { + const UnofficialTPLca({super.key}); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect // how it looks. @@ -51,7 +52,7 @@ class UnofficialTPLca extends StatefulWidget { final String title = 'Unofficial tpl.ca app'; @override - _UnofficialTPLcaState createState() => _UnofficialTPLcaState(); + State createState() => _UnofficialTPLcaState(); } class _UnofficialTPLcaState extends State { @@ -69,7 +70,7 @@ class _UnofficialTPLcaState extends State { appBar: AppBar( title: Text(widget.title), ), - body: WebView( + body: const WebView( initialUrl: 'https://tpl.ca', javascriptMode: JavascriptMode.unrestricted,), ); diff --git a/pubspec.yaml b/pubspec.yaml index 4adacdd..8cf9640 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+1 +version: 1.0.1+1 environment: sdk: '>=3.4.3 <4.0.0' diff --git a/test/widget_test.dart b/test/widget_test.dart index 0ce968d..463d9a9 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -5,7 +5,6 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. -import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:unofficial_tpl/main.dart'; @@ -15,16 +14,5 @@ void main() { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); }); } From a6ed3f1ee3ca5160db36cc99711a59b42b618b7d Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 18 Jun 2024 15:54:00 -0400 Subject: [PATCH 2/2] fix: flutter build apk due to user-permission --- android/app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3eba23e..b1d24cf 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - +