2 Commits c4992f64af ... cc53523b5f

Autore SHA1 Messaggio Data
  gjh cc53523b5f ios设置只支持iphone和ipad,设置最低支持macos的版本参数 1 settimana fa
  gjh 5d4ac3bebf ios版本检查逻辑优化 1 settimana fa
3 ha cambiato i file con 85 aggiunte e 2 eliminazioni
  1. 30 0
      ios/Runner.xcodeproj/project.pbxproj
  2. 2 0
      ios/Runner/Info.plist
  3. 53 2
      lib/funcs.dart

+ 30 - 0
ios/Runner.xcodeproj/project.pbxproj

@@ -610,8 +610,13 @@
610 610
 				PRODUCT_BUNDLE_IDENTIFIER = com.eitchsyh.instrument;
611 611
 				PRODUCT_NAME = "$(TARGET_NAME)";
612 612
 				PROVISIONING_PROFILE_SPECIFIER = "";
613
+				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
614
+				SUPPORTS_MACCATALYST = NO;
615
+				SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
616
+				SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
613 617
 				SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
614 618
 				SWIFT_VERSION = 5.0;
619
+				TARGETED_DEVICE_FAMILY = "1,2";
615 620
 				VERSIONING_SYSTEM = "apple-generic";
616 621
 			};
617 622
 			name = "Profile-hsjk";
@@ -751,9 +756,14 @@
751 756
 				PRODUCT_BUNDLE_IDENTIFIER = com.hst.instrument;
752 757
 				PRODUCT_NAME = "$(TARGET_NAME)";
753 758
 				PROVISIONING_PROFILE_SPECIFIER = "";
759
+				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
760
+				SUPPORTS_MACCATALYST = NO;
761
+				SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
762
+				SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
754 763
 				SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
755 764
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
756 765
 				SWIFT_VERSION = 5.0;
766
+				TARGETED_DEVICE_FAMILY = "1,2";
757 767
 				VERSIONING_SYSTEM = "apple-generic";
758 768
 			};
759 769
 			name = "Debug-hst";
@@ -858,8 +868,13 @@
858 868
 				PRODUCT_BUNDLE_IDENTIFIER = com.hst.instrument;
859 869
 				PRODUCT_NAME = "$(TARGET_NAME)";
860 870
 				PROVISIONING_PROFILE_SPECIFIER = "";
871
+				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
872
+				SUPPORTS_MACCATALYST = NO;
873
+				SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
874
+				SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
861 875
 				SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
862 876
 				SWIFT_VERSION = 5.0;
877
+				TARGETED_DEVICE_FAMILY = "1,2";
863 878
 				VERSIONING_SYSTEM = "apple-generic";
864 879
 			};
865 880
 			name = "Release-hst";
@@ -964,8 +979,13 @@
964 979
 				PRODUCT_BUNDLE_IDENTIFIER = com.hst.instrument;
965 980
 				PRODUCT_NAME = "$(TARGET_NAME)";
966 981
 				PROVISIONING_PROFILE_SPECIFIER = "";
982
+				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
983
+				SUPPORTS_MACCATALYST = NO;
984
+				SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
985
+				SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
967 986
 				SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
968 987
 				SWIFT_VERSION = 5.0;
988
+				TARGETED_DEVICE_FAMILY = "1,2";
969 989
 				VERSIONING_SYSTEM = "apple-generic";
970 990
 			};
971 991
 			name = "Profile-hst";
@@ -1128,9 +1148,14 @@
1128 1148
 				PRODUCT_BUNDLE_IDENTIFIER = com.eitchsyh.instrument;
1129 1149
 				PRODUCT_NAME = "$(TARGET_NAME)";
1130 1150
 				PROVISIONING_PROFILE_SPECIFIER = "";
1151
+				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
1152
+				SUPPORTS_MACCATALYST = NO;
1153
+				SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
1154
+				SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
1131 1155
 				SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
1132 1156
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1133 1157
 				SWIFT_VERSION = 5.0;
1158
+				TARGETED_DEVICE_FAMILY = "1,2";
1134 1159
 				VERSIONING_SYSTEM = "apple-generic";
1135 1160
 			};
1136 1161
 			name = "Debug-hsjk";
@@ -1167,8 +1192,13 @@
1167 1192
 				PRODUCT_BUNDLE_IDENTIFIER = com.eitchsyh.instrument;
1168 1193
 				PRODUCT_NAME = "$(TARGET_NAME)";
1169 1194
 				PROVISIONING_PROFILE_SPECIFIER = "";
1195
+				SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
1196
+				SUPPORTS_MACCATALYST = NO;
1197
+				SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
1198
+				SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
1170 1199
 				SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
1171 1200
 				SWIFT_VERSION = 5.0;
1201
+				TARGETED_DEVICE_FAMILY = "1,2";
1172 1202
 				VERSIONING_SYSTEM = "apple-generic";
1173 1203
 			};
1174 1204
 			name = "Release-hsjk";

+ 2 - 0
ios/Runner/Info.plist

@@ -68,5 +68,7 @@
68 68
 	<string>拍摄照片需要访问您的摄像头</string>
69 69
 	<key>ITSAppUsesNonExemptEncryption</key>
70 70
 	<false/>
71
+	<key>LSMinimumSystemVersion</key>
72
+	<string>12.0</string>
71 73
 </dict>
72 74
 </plist>

+ 53 - 2
lib/funcs.dart

@@ -509,8 +509,59 @@ Future<bool> checkNewVersion(BuildContext context, WidgetRef ref) async {
509 509
   } catch (e) {
510 510
     loge("检查更新转换版本号异常", error: e);
511 511
   }
512
-  if (versionCode >= serverCode) {
513
-    return false;
512
+  //ios的version和code都需要比较,因为对于同一版本,ios发布时会自动提升code
513
+  //不同版本又会从pubspec.yaml里填写的code重新计算
514
+  if (Platform.isIOS) {
515
+    if (info.version.isNullOrEmpty) {
516
+      logd("ios比较版本,服务器version为空");
517
+      return false;
518
+    }
519
+    //把服务器的版本号转为数字数组
520
+    List<int> serverVersionNums = info.version!.split(".").map((e) {
521
+      try {
522
+        return int.parse(e);
523
+      } catch (e) {
524
+        loge("转换服务器版本字符到异常", error: e);
525
+      }
526
+      return 0;
527
+    }).toList();
528
+    //把本地的版本号转为数字数组
529
+    List<int> currentVersionNums = packageInfo.version.split(".").map((e) {
530
+      try {
531
+        return int.parse(e);
532
+      } catch (e) {
533
+        loge("转换本地版本字符到异常", error: e);
534
+      }
535
+      return 0;
536
+    }).toList();
537
+    //如果本地长度小于服务器长度,则补齐本地数组
538
+    if (currentVersionNums.length < serverVersionNums.length) {
539
+      currentVersionNums.addAll(List.filled(
540
+          serverVersionNums.length - currentVersionNums.length, -1));
541
+    }
542
+    //从左到右比较数字大小,只要服务器有一个大于本地的就认为需要升级
543
+    bool needUpdate = false;
544
+    bool sameVersion = true;
545
+    for (int i = 0; i < serverVersionNums.length; i++) {
546
+      if (serverVersionNums[i] != currentVersionNums[i]) {
547
+        sameVersion = false;
548
+      }
549
+      if (serverVersionNums[i] > currentVersionNums[i]) {
550
+        needUpdate = true;
551
+        break;
552
+      }
553
+    }
554
+    //如果版本号都一致,就判断code的大小
555
+    if (!needUpdate && sameVersion && serverCode > versionCode) {
556
+      needUpdate = true;
557
+    }
558
+    return needUpdate;
559
+  }
560
+  //其他的只需要判断code
561
+  else {
562
+    if (versionCode >= serverCode) {
563
+      return false;
564
+    }
514 565
   }
515 566
   if (context.mounted) {
516 567
     showDialog(