build method

  1. @override
Future build(
  1. String root
)
override

Implementation

@override
Future build(String root) async {
  final supportLdClassic = JSON(argResults?['supportLdClassic']).boolValue;
  logger.log('supportLdClassic: $supportLdClassic');

  /// 是否要去掉ld_classic
  if (!supportLdClassic) {
    final projectPath = join(
        environment.workspace, 'ios', 'Runner.xcodeproj', 'project.pbxproj');
    var contents = await File(projectPath).readAsString();
    contents = contents.replaceAll('''
				OTHER_LDFLAGS = (
					"\$(inherited)",
					"-ld_classic",
				);
''', '''
				OTHER_LDFLAGS = (
					"\$(inherited)",
				);
''');
    if (contents.contains('ld_classic')) {
      logger.log('去掉ld_classic失败!', status: LogStatus.error);
      exit(2);
    }
    await File(projectPath).writeAsString(contents);

    logger.log('已经去掉ld_classic', status: LogStatus.success);
  }

  if (dartDefineArgs
      .any((element) => element == '--dart-define=isStoreVersion=true')) {
    await RemoveIosSettingBundle(root: root).remove();
    logger.log('移出Setting.bundle 成功!');
  }

  await SetVersionBuildNumber(environment: environment).runInIos();
  /**
   *
cd $WROKSPACE/metaapp_flutter

fvm flutter clean
fvm flutter pub get
cd $WROKSPACE/ios
pod install

XCARCHIVE_PATH=$WROKSPACE/build/ios/Runner.xcarchive
xcodebuild -workspace Runner.xcworkspace -scheme Runner -archivePath $XCARCHIVE_PATH -configuration Release archive
xcodebuild -exportArchive -archivePath $XCARCHIVE_PATH -exportPath ../build/ios/ipa -exportOptionsPlist ExportOptions.plist

   */

  await Shell(workingDirectory: '${environment.workspace}/metaapp_flutter')
      .run('''
fvm flutter clean
fvm flutter pub get
''');

  await Shell(workingDirectory: '${environment.workspace}/ios').run('''
rm -rf Podfile.lock
pod install --repo-update
xcodebuild -workspace Runner.xcworkspace -scheme Runner -archivePath ../build/ios/Runner.xcarchive -configuration Release archive
xcodebuild -exportArchive -archivePath ../build/ios/Runner.xcarchive -exportPath ../build/ios/ipa -exportOptionsPlist ExportOptions.plist
''');

  // await BuildApp(
  //   platform: BuildPlatform.ios,
  //   root: root,
  //   buildName: environment.buildName,
  //   buildNumber: environment.buildNumber,
  // ).build();
}