def testRemoveRunScriptNotFound(self): project = XcodeProject(self.obj) project.add_run_script(u'ls -la', insert_before_compile=True) self.assertEqual(project.objects[project.objects['1'].buildPhases[0]].shellScript, u'ls -la') self.assertEqual(project.objects[project.objects['2'].buildPhases[0]].shellScript, u'ls -la') project.remove_run_script(u'ls') self.assertEqual(project.objects[project.objects['1'].buildPhases[0]].shellScript, u'ls -la') self.assertEqual(project.objects[project.objects['2'].buildPhases[0]].shellScript, u'ls -la')
for build_phase_id in target.buildPhases: build_phase = project.objects[build_phase_id] if not isinstance(build_phase, PBXShellScriptBuildPhase): continue print("script #", id) thisscript = build_phase.shellScript # TODO: also remove and replace the bundled oF script that starts with 'mkdir -p "$TARGET_BUILD_DIR' if thisscript.strip().startswith('COMPANY'): if not foundScript: build_phase.shellScript = finalscript foundScript = True print("Replaced the bad script with the correct script.") else: # remove this script project.remove_run_script(build_phase.shellScript) print("Removed extra script.") else: print(thisscript.strip()[:10], " does not begin with ", 'COMPANY'.strip()) if thisscript.strip().startswith("mkdir -p "): project.remove_run_script(build_phase.shellScript) print("Removed extra oF app resources script.") # if (build_phase.shellScript.startswith("COMPANY_NAME")) or (build_phase.shellScript.startswith('mkdir -p "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Resources/"')): # print("found the script!") # print(build_phase.shellScript) # build_phase.shellScript = finalscript # foundScript = True # else: # print("this script doesn't start with companyname:", build_phase.shellScript) id += 1