Modify PRODUCT_BUNDLE_IDENTIFIER in project.pbxproj of Xcode
Asked Answered
S

1

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.

Scabby answered 2/10, 2015 at 15:14 Comment(0)
S
11

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
Smythe answered 2/10, 2015 at 16:15 Comment(4)
Yup. Tried that, didn't work in this case. Already found this hereScabby
it's weird because i just tried and it works for me on my macbook proSmythe
do you mind using python script? i can write python script for youSmythe
found an alternative solution as well using mod-pbxproj. Will share a detailed answer on how to use this as well for others.Scabby

© 2022 - 2024 — McMap. All rights reserved.