How to build an iOS app using the command line on macOS Sonoma?

Hello,

Now we support Apple applications and we are building applications on Mac laptops with regular updates. Our goal is to build an iOS app entirely through the command line using xcodebuild and other tools from Xcode Command Line Tools on a server with _macOS Sonoma (14.6.1) without a graphical user interface (only the command line)!!!

We need to build and regularly update iOS applications on clients and our accounts and we are looking for a solution to fully automate the login process for these accounts. Our goal is to automate these processes on a server without involving a customer.

Here’s what I need help with building and signing the app: What are the proper commands to build and sign the app using xcodebuild and put this application in Apple Store?

Server has:

xcode-select -version
  xcode-select version 2408.
xcodebuild -version
  Xcode 16.1 Build version 16B40.

In the first step, the certificates have been added to the keychain. We have two keychains. We can check it by running the command:

security list-keychains:  
`  "/Users/ec2-user/Library/Keychains/login.keychain-db"    
   "/Library/Keychains/System.keychain".`

All certificates are kept in login.keychain-db. We can check it:

security find-identity -p codesigning -v
  Answer is: `'Some hash "Apple Distribution: Name. (TEAM ID)"'.`

Profision file is kept in /Users/ec2-user/Library/MobileDevice/Provisioning\ Profiles/.

In the first step, we have added a cordova platform with iOS 11 version.

Command is:

cordova platform add ios. 

We tried to create a sign archive with automation but we couldn't do it because we got an error.

Our command is

xcodebuild \  -workspace "path/to/Packet-name Test.xcworkspace" \ 
 -scheme "Packet-name Test" \
 -sdk iphoneos \
 -configuration Release \
 -archivePath "./Packet-name Test.xcarchive" \  CODE_SIGN_STYLE=Automatic \
DEVELOPMENT_TEAM=XXXXXXXXXX \
 -allowProvisioningUpdates \
 archive

We get errors:

/Users/ec2-user/buildApps/MyNewApplication/packet-name.test/platforms/ios/Packet-name Test.xcodeproj: error: No Accounts: Add a new account in Accounts settings. (in target 'Packet-name Test' from project 'Packet-name Test')

/Users/ec2-user/buildApps/MyNewApplication/packet-name.test/platforms/ios/Packet-name Test.xcodeproj: error: No profiles for 'packet-name.test' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'packet-name.test'. (in target 'Packet-name Test' from project 'Packet-name Test')

We've read about this error so the decision is to create one-time passwords for this. Certainly last error is about a problem with login, but how we can fix it we don't know because we will be using different accounts for different applications. As a result, we have to use one-time passwords for different accounts.

We would appreciate detailed instructions, example commands, and references to documentation that might address this workflow.

Are you able to demonstrate the issue in a test project created from one of Xcode's templates, and using only Apple APIs? If not, you should check with the support resources provided by “Cordova” to get assistance with their software.

Unless another developer in the forums has experience with the third-party and can provide assistance.

You can find tips on creating and sharing a test project in Creating a Test Project.

Albert Pascual
  Worldwide Developer Relations.

How to build an iOS app using the command line on macOS Sonoma?
 
 
Q