I recently started to automate the build and release of OctoBlast using Github Actions. In this post, I will show you how to build your application on the command line.
Building our application
We will be using
xcodebuild to create an archive of our application. This is the same command that is used by Xcode (I'm using versions 13 and 14) when building applications.
The script below creates an archive and then exports the application as an
.app file. You might want to run
xcodebuild -list to see the available schemes.
We will be using the
xcodebuild clean archive -scheme BuildingAppsOnTheCli -configuration Release -archivePath builds/archives/BuildingAppsOnTheCli.xcarchive
The above command will create an archive in the
builds └── archives └── BuildingAppsOnTheCli.xcarchive
Before we can export the archive, we need to create a
Info.plist file. This will tell
xcodebuild how to export the application. You can add a new
Property List file to the project via the UI.
If we try to export the archive now we will get an error about "teamID" not being specified. By default it will try to build an app to be distributed on the AppStore but we want to distribute it ourselves. To fix this, add the key
method and value
mac-application to the
Now running the following command again will export the archive to an
xcodebuild -exportArchive -archivePath builds/archives/BuildingAppsOnTheCli.xcarchive -exportPath builds/exports/BuildingAppsOnTheCli -exportOptionsPlist BuildingAppsOnTheCli/Info.plist
./builds directory will look like this:
builds ├── archives │ └── BuildingAppsOnTheCli.xcarchive └── exports └── BuildingAppsOnTheCli └── BuildingAppsOnTheCli.app
If we locate and run the build application, we will see that it works as expected.
Bringing it all together
rm -rf builds xcodebuild clean archive -scheme BuildingAppsOnTheCli -configuration Release -archivePath builds/archives/BuildingAppsOnTheCli.xcarchive xcodebuild -exportArchive -archivePath builds/archives/BuildingAppsOnTheCli.xcarchive -exportPath builds/exports/BuildingAppsOnTheCli -exportOptionsPlist BuildingAppsOnTheCli/Info.plist