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?
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.