build_ios_config_only_test.dart 1.94 KB
Newer Older
1 2 3 4 5 6 7 8 9
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';

import '../src/common.dart';
10
import 'test_utils.dart';
11 12 13

void main() {
  test('flutter build ios --config only updates generated xcconfig file without performing build', () async {
14
    final String workingDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
15
    final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
16

17
    await processManager.run(<String>[
18
      flutterBin,
19
       ...getLocalEngineArguments(),
20
      'clean',
21
    ], workingDirectory: workingDirectory);
22
    final ProcessResult result = await processManager.run(<String>[
23
      flutterBin,
24
      ...getLocalEngineArguments(),
25 26 27 28 29 30 31
      'build',
      'ios',
      '--config-only',
      '--release',
      '--obfuscate',
      '--split-debug-info=info',
      '--no-codesign',
32
    ], workingDirectory: workingDirectory);
33

34 35 36
    printOnFailure('Output of flutter build ios:');
    printOnFailure(result.stdout.toString());
    printOnFailure(result.stderr.toString());
37 38 39

    expect(result.exitCode, 0);

40
    final File generatedConfig = fileSystem.file(
41
      fileSystem.path.join(workingDirectory, 'ios', 'Flutter', 'Generated.xcconfig'));
42 43 44

    // Config is updated if command succeeded.
    expect(generatedConfig, exists);
45
    expect(generatedConfig.readAsStringSync(), contains('DART_OBFUSCATION=true'));
46 47

    // file that only exists if app was fully built.
48
    final File frameworkPlist = fileSystem.file(
49
      fileSystem.path.join(workingDirectory, 'build', 'ios', 'iphoneos', 'Runner.app', 'AppFrameworkInfo.plist'));
50 51

    expect(frameworkPlist, isNot(exists));
52
  }, skip: !platform.isMacOS); // [intended] iOS builds only work on macos.
53
}