9

I'm trying to modify the project.pbxproj file of Xcode project using sed shell command on Mac Terminal to replace a string. I want to replace the field -

PRODUCT_BUNDLE_IDENTIFIER = com.example.71b9b4f2

to

PRODUCT_BUNDLE_IDENTIFIER = com.example.14a32d1e

Command used -

sed -i 's/com.example.71b94f2/com.example.14a32d1e/g' project.pbxproj

which produces the following output error-

sed: 1: "project.pbxproj": extra characters at the end of p command

I was earlier using Plistbuddy shell command to modify the field CFBUNDLEIDENTIFIER in info.plist but that doesn't change $(PRODUCT_BUNDLE_IDENTIFIER) in Xcode 7 build settings anymore.

My main aim is to modify the PRODUCT_BUNDLE_IDENTIFIER field of BUILD SETTINGS in Xcode using command line or any script.

JOM
  • 8,139
  • 6
  • 78
  • 111
Sarthak Singhal
  • 665
  • 2
  • 10
  • 26

1 Answers1

10

OSX requires the extension to be explicitly specified. The workaround is to set an empty string:

sed -i '' 's/com.example.71b94f2/com.example.14a32d1e/g' project.pbxproj
midori
  • 4,807
  • 5
  • 34
  • 62
  • Yup. Tried that, didn't work in this case. Already found this [here](http://myshittycode.com/2014/07/24/os-x-sed-extra-characters-at-the-end-of-l-command-error/) – Sarthak Singhal Oct 02 '15 at 16:22
  • it's weird because i just tried and it works for me on my macbook pro – midori Oct 02 '15 at 16:22
  • do you mind using python script? i can write python script for you – midori Oct 02 '15 at 16:26
  • 1
    found an alternative solution as well using [mod-pbxproj](https://github.com/kronenthaler/mod-pbxproj). Will share a detailed answer on how to use this as well for others. – Sarthak Singhal Oct 02 '15 at 16:29