-
-
Notifications
You must be signed in to change notification settings - Fork 294
Load and Save
Before starting any manipulation, you need to load the Xcode project file into an objcet that can be manipulated. And to allow the changes made, the project has to be saved back. This is what section will teach you how to do.
After importing the module, you can load the project file into an instance of XcodeProject
class. To do so, you just need to provide the path to the project.pbxproj
file that is always inside of your app .xcodeproj
folder
project = XcodeProject.load('myapp.xcodeproj/project.pbxproj')
This function returns a XcodeProject object that you will use for most of the manipulations.
In case something goes wrong during the parsing or writing, is a good idea to make a backup before starting to do any modifications to the file.
backup_file = project.backup()
This function returns the name of backup file created, in case you need to restore it or get rid of it after the save command is done.
To save the changes in your project you need to call the save method:
project.save()
Here there is an optional parameters:
path
: String, a new path to save the project to. If nothing is specified, the project will be written back on the original file, this is the default behavior.