6

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.

Community
  • 1
  • 1
Rishi Joshi
  • 63
  • 1
  • 3

1 Answers1

5

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
Quanlong
  • 24,028
  • 16
  • 69
  • 79
  • 1
    Hey.. thanks for an answer..:) Okay.. so I used your steps and whoosh.. What I needed was achieved (though after figuring out what `sed` command does). But, there's one catch..! **sed** is replacing `"iPhone Developer"` with `""`, which means I need to have that value set to something I know (here, `"iPhone Developer"`). Similar case with Provisioning Profile. Can I not just overwrite whatever's written in those fields with what I need to have there?? – Rishi Joshi Sep 24 '15 at 01:42
  • I think you misunderstood me. The Codesigning and Provisioning Profile which comes with the project is not available on my MacBook so I cannot figure out what to put in the `sed` commands. The above commands work only if Codesign and Provisioning Profile is set to automatic. In all other cases like when Profile like this `15adc2c7-a08b-4541-a549-ea09f7deeeb4` and every time I get a project it's having some profile like this, which I need to overwrite with locally present profiles. – Rishi Joshi Sep 24 '15 at 05:40
  • If you don't have Codesinging Cert and Provisioning Profile locally? How can you build the project? And it's no difference where you get them. The value you need to set with `sed` is always same for the specific Cert and Profile – Quanlong Sep 24 '15 at 09:44
  • I'm having different version of the same Profile. As in, when a new device is added to profile, it's Profile Identifier changes from "ewer-qwe-qer" to something "zcnaj-dna-snf". Developer provided code is not having latest profile so I want to overwrite it with latest profile present on my mac. – Rishi Joshi Sep 24 '15 at 09:52
  • Then why not `grep -aA1 UUID /path/to/lastest/profile` is not work on your Mac? – Quanlong Sep 24 '15 at 10:07
  • Sorry for reverting to you late.. Got it solved.. I just didn't know how to fetch existing values of Codesign and Profile from that `project.pbxproj` file.. Got it..! Thanks.. – Rishi Joshi Oct 01 '15 at 07:10