1

I'm attempting to create a script that builds and archives my iOS project. My goal is to have a script that creates AdHoc and Distribution ipas.

I've attempted something like this:

xcodebuild -scheme MyApp -configuration AdHoc archive

It works when I execute this command in the terminal. But when I put it in a shell script file and then run it from the terminal:

sudo sh /Users/user/somepath/buildscript.sh

I get the following error:

Provisioning profile 'XXX-XXX-XXX-XXX-XXX' can't be found

What do you think?

1 Answer 1

2

The sudo invocation of the script cannot find what it needs because the certificates and provisioning profiles required will be stored in your account's keychain and Xcode library directories. sudo will be running as the administrator which can't see these.

You should't need to use sudo anyway. What part of your build process requires root privileges? If you want to somehow isolate this command, create a new user specifically for building, but install the appropriate certificate in the user's keychain, and drag the provisioning profile into Xcode while logged in as that user.

Sign up to request clarification or add additional context in comments.

2 Comments

I merely want to run the script file in the terminal. When executing /Users/user/somepath/buildscript.sh in the terminal in gives me "Permission denied". This is why I use sudo
You need to enable execution with chmod for it to work: chmod u+x /path/to/script.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.