问题
I want to change build settings of a .xcodeproj without using Xcode IDE but through terminal commands (Codesigning Identity and Provisioning Profile to be exact).
I have searched all over but only found commands to build/archive the project from terminal, which I Do Not Want. What I want is to just change the settings, so that when I open the project in Xcode, it has the signing identities and provisioning profile set to what I had set in Terminal.
Xcodebuild command just builds/archives the project using what I pass as parameters, it doesn't set them as values in build settings of project.
Running xcodebuild -target <target-name> -showBuildSettings
in terminal, where my project resides, gives me complete build settings of the project but I didn't get any method to set them.
Also I read here about using -setObject
, but that also didn't help me as it also builds the code using parameters values I gave instead of actually setting them.
Currently using Xcode 6.3 and Xcode 7.
Any kind of help will be appreciated.
回答1:
All Xcode settings is actually store in <project-name>.xcodeproj/project.pbxproj
.
It looks like
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
...
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES;
};
Code Signing Identity is controlled by CODE_SIGN_IDENTITY
key and Provisioning Profile is controlled by PROVISIONING_PROFILE
key.
The project.pbxproj
is a text file that can be edited by traditional text processing tools in CLI, such as sed with
sed -ie 's/CODE_SIGN_IDENTITY = "iPhone Developer"/CODE_SIGN_IDENTITY = ""/g' <project-name>.xcodeproj/project.pbxproj
sed -ie 's/PROVISIONING_PROFILE = ""/PROVISIONING_PROFILE = "1c28c979-6bef-4917-aa34-92aecd91315c";/g' <project-name>.xcodeproj/project.pbxproj
You can get the list of available Signing Identities with
security find-identity -v -p codesigning
For PROVISIONING_PROFILE
, it's a UUID of provisioning file, it can be fetched with
grep -aA1 UUID /path/to/mobileprovision
来源:https://stackoverflow.com/questions/32743012/setting-xcode-build-settings-terminal