Setting Xcode Build Settings Terminal
Asked Answered
A

1

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.

Alan answered 23/9, 2015 at 14:59 Comment(0)
W
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
Wabash answered 23/9, 2015 at 15:40 Comment(6)
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??Alan
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.Alan
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 ProfileWabash
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.Alan
Then why not grep -aA1 UUID /path/to/lastest/profile is not work on your Mac?Wabash
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..Alan

© 2022 - 2024 — McMap. All rights reserved.