-
-
Save Bigpet/9c8f950aa5dd3ad99923d4d98cf87209 to your computer and use it in GitHub Desktop.
Strip sections from an xcode project that aren't supported by cocoapods.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2018 Google Inc. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# copied from https://gist.github.com/johnb003/59842c752cbbbdcde00e2ca8ca33d4cb | |
# modified by IMG.LY 2022 | |
import argparse | |
import os | |
import sys | |
def main(): | |
parser = argparse.ArgumentParser(description=( | |
"This script strips 'buildSettings' and 'buildStyles' sections from an " | |
"xcode PBXProject produced by cmake.")) | |
parser.add_argument("-p", help="Path to xcode project .pbxproj", | |
metavar="FILE", required=True) | |
args = parser.parse_args() | |
pbxproj = args.p | |
project_section = False | |
build_style_section = False | |
writing = True | |
with open(pbxproj, "r") as input_file: | |
lines_in = input_file.readlines() | |
with open(pbxproj, "w") as output_file: | |
for line in lines_in: | |
if "/* Begin PBXBuildStyle section */" in line: | |
build_style_section = True | |
elif "/* End PBXBuildStyle section */" in line: | |
build_style_section = False | |
elif "/* Begin PBXProject section */" in line: | |
project_section = True | |
elif project_section: | |
if "/* End PBXProject section */" in line: | |
project_section = False | |
# Found the thing inside the project section we need to strip. | |
if "buildSettings = {" in line or "buildStyles = (" in line: | |
writing = False | |
if not writing: | |
# Strip lines until the end of the sections above | |
if ");" in line or "};" in line: | |
writing = True | |
elif build_style_section: | |
pass | |
# writing _was_ True | |
else: | |
output_file.write(line); | |
return 0 | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment