Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # coding: utf-8
- """
- This script file automatically inserts the import of the libraries used for 'ResourceKit'.
- Insert new 'Run Script' before 'Compile Sources' in Build Phases.
- And fill this code.
- python $SRCROOT/script/generated_resource.py LIBRARY_1 LIBRARY_2 LIBRARY_3 ...
- """
- import os.path
- import sys
- generated_file = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'Resource.generated.swift')
- output = ''
- if len(sys.argv) == 1:
- sys.exit(0)
- libraries = sys.argv[1:]
- with open(generated_file, 'r') as f:
- for line in f.readlines():
- if line.startswith('import'):
- if line == 'import UIKit\n':
- output += line + '\n'.join(map(lambda item: 'import {}'.format(item), libraries)) + '\n'
- elif line.replace('import ', '').replace('\n', '') in libraries:
- continue
- else:
- output += line
- with open(generated_file, 'w') as f:
- f.write(output)
Add Comment
Please, Sign In to add comment