Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
create_xcframework.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2#
3# Copyright 2013 The Flutter Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7import argparse
8import os
9import shutil
10import subprocess
11import sys
12
13
14def main():
15 parser = argparse.ArgumentParser(
16 description='Creates an XCFramework consisting of the specified universal frameworks'
17 )
18
19 parser.add_argument(
20 '--frameworks',
21 nargs='+',
22 help='The framework paths used to create the XCFramework.',
23 required=True
24 )
25 parser.add_argument('--name', help='Name of the XCFramework', type=str, required=True)
26 parser.add_argument('--location', help='Output directory', type=str, required=True)
27
28 args = parser.parse_args()
29
30 create_xcframework(args.location, args.name, args.frameworks)
31
32
33def create_xcframework(location, name, frameworks):
34 output_dir = os.path.abspath(location)
35 output_xcframework = os.path.join(output_dir, '%s.xcframework' % name)
36
37 if not os.path.exists(output_dir):
38 os.makedirs(output_dir)
39
40 if os.path.exists(output_xcframework):
41 # Remove old xcframework.
42 shutil.rmtree(output_xcframework)
43
44 # xcrun xcodebuild -create-xcframework -framework foo/baz.framework \
45 # -framework bar/baz.framework -output output/
46 command = ['xcrun', 'xcodebuild', '-quiet', '-create-xcframework']
47
48 for framework in frameworks:
49 command.extend(['-framework', os.path.abspath(framework)])
50
51 command.extend(['-output', output_xcframework])
52
53 subprocess.check_call(command, stdout=open(os.devnull, 'w'))
54
55
56if __name__ == '__main__':
57 sys.exit(main())
Definition main.py:1