Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set xcode "build setting" from terminal?

Is there anyway that I can change a setting in xcode without opening xcode? I have an automated xcodebuild / xcrun process going on but I need to change 1 value:

Targets > Select your target > Build Settings > Code Signing Resource Rules Path add : $(SDKROOT)/ResourceRules.plist

I can't find any file where I might put this line...

like image 529
nizzle Avatar asked Nov 27 '14 20:11

nizzle


People also ask

How do I change my build settings in Xcode?

Choose the project in the Project Navigator on the left. Select the Configurations target from the Targets section and click the Build Settings tab at the top. The Build Settings tab shows the build settings for the Configurations target. It's possible to expand this list with build settings that you define.

How do I reset Xcode project settings?

To reset a single project setting so that it's no longer bold, select the option in the project settings and hit the delete key.

What is Xcodebuild command?

DESCRIPTION. xcodebuild builds one or more targets contained in an Xcode project, or builds a scheme contained in an Xcode workspace or Xcode project. Usage To build an Xcode project, run xcodebuild from the directory containing your project (i.e. the directory containing the projectname. xcodeproj package).

What is Xcrun command?

DESCRIPTION. xcrun provides a means to locate or invoke coexistence- and platform- aware developer tools from the command-line, without requiring users to modify makefiles or otherwise take inconvenient measures to support mul- tiple Xcode tool chains.


2 Answers

What You can do is to run:

xcodebuild -target <target> -configuration <configuration> -showBuildSettings

This command shows all the settings that are filled for target and configuration passed. Find the name of the key that contains $(SDKROOT)/ResourceRules.plist (let call it THE_KEY) and then try:

xcodebuild -target <target> -configuration <configuration> THE_KEY=<new_value>

Don't guarantee that it will work.

like image 69
Opal Avatar answered Nov 16 '22 02:11

Opal


You could try pbxproj. This is a python module that helps you manipulate Xcode projects with commandline.

The related part to your probelm may be https://github.com/kronenthaler/mod-pbxproj/wiki/flags#add-code-sign

You can pip install pbxproj to have it.

And here's an example provided in the official repo:

from pbxproj import XcodeProject
# open the project
project = XcodeProject.load('myapp.xcodeproj/project.pbxproj')

# add a file to it, force=false to not add it if it's already in the project
project.add_file('MyClass.swift', force=False)

# set a Other Linker Flags
project.add_other_ldflags('-ObjC')

# save the project, otherwise your changes won't be picked up by Xcode
project.save()
like image 34
Hustlion Avatar answered Nov 16 '22 02:11

Hustlion