Skip to content

Commit

Permalink
feat: Mac Catalyst builds (#360)
Browse files Browse the repository at this point in the history
This change disables the Lua embedding step as this doesn't work with
Catalyst builds thanks to an Xcode/SwiftPM bug. Instead, we're relying
on a separate build step to catch Lua syntax errors in CI. It's
imperfect, but better than nothing.
  • Loading branch information
jbmorley committed Sep 11, 2024
1 parent 7fc9d10 commit a3d496f
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 246 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:

APPLE_DISTRIBUTION_CERTIFICATE_BASE64: ${{ secrets.PERSONAL_APPLE_DISTRIBUTION_CERTIFICATE_BASE64 }}
APPLE_DISTRIBUTION_CERTIFICATE_PASSWORD: ${{ secrets.PERSONAL_APPLE_DISTRIBUTION_CERTIFICATE_PASSWORD }}
MACOS_DEVELOPER_INSTALLER_CERTIFICATE_BASE64: ${{ secrets.PERSONAL_MACOS_DEVELOPER_INSTALLER_CERTIFICATE_BASE64 }}
MACOS_DEVELOPER_INSTALLER_CERTIFICATE_PASSWORD: ${{ secrets.PERSONAL_MACOS_DEVELOPER_INSTALLER_CERTIFICATE_PASSWORD }}

APPLE_API_KEY_BASE64: ${{ secrets.PERSONAL_APPLE_API_KEY_BASE64 }}
APPLE_API_KEY_ISSUER_ID: ${{ secrets.PERSONAL_APPLE_API_KEY_ISSUER_ID }}
Expand Down
File renamed without changes.
27 changes: 27 additions & 0 deletions ExportOptions-macCatalyst.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>destination</key>
<string>export</string>
<key>installerSigningCertificate</key>
<string>C44BC9291462AE6729496E2CAC18CE475688F8CD</string>
<key>manageAppVersionAndBuildNumber</key>
<false/>
<key>method</key>
<string>app-store-connect</string>
<key>provisioningProfiles</key>
<dict>
<key>uk.co.inseven.opolua</key>
<string>OpoLua Mac Catalyst App Store Profile</string>
</dict>
<key>signingCertificate</key>
<string>91DADFE184A1526FA94D4513D5B4C75E1DB3B252</string>
<key>signingStyle</key>
<string>manual</string>
<key>teamID</key>
<string>QS82QFHKWB</string>
<key>uploadSymbols</key>
<true/>
</dict>
</plist>
239 changes: 19 additions & 220 deletions OpoLua.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions OpoLua/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand Down
1 change: 1 addition & 0 deletions OpoLua/Model/Sound.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import AudioUnit
import AVFoundation
import Combine
import CoreAudio
import Foundation

class PlaySoundRequest: Scheduler.Request {
Expand Down
2 changes: 2 additions & 0 deletions OpoLua/OpoLua.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.personal-information.photos-library</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions OpoLua/View Controllers/AllProgramsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ class AllProgramsViewController : UICollectionViewController {
}

private func configureRefreshControl() {
#if !targetEnvironment(macCatalyst)
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(refreshControlDidChange(_:)), for: .valueChanged)
collectionView.refreshControl = refreshControl
#endif
}

override func viewWillAppear(_ animated: Bool) {
Expand Down
2 changes: 2 additions & 0 deletions OpoLua/View Controllers/DirectoryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ class DirectoryViewController : UICollectionViewController {
}

private func configureRefreshControl() {
#if !targetEnvironment(macCatalyst)
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(refreshControlDidChange(_:)), for: .valueChanged)
collectionView.refreshControl = refreshControl
#endif
}

override func viewWillAppear(_ animated: Bool) {
Expand Down
Binary file not shown.
59 changes: 35 additions & 24 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ BUILD_DIRECTORY="$ROOT_DIRECTORY/build"
TEMPORARY_DIRECTORY="$ROOT_DIRECTORY/temp"

KEYCHAIN_PATH="$TEMPORARY_DIRECTORY/temporary.keychain"
ARCHIVE_PATH="$BUILD_DIRECTORY/OpoLua.xcarchive"
MACOS_ARCHIVE_PATH="${BUILD_DIRECTORY}/Archive-macOS.xcarchive"
IOS_ARCHIVE_PATH="${BUILD_DIRECTORY}/Archive-iOS.xcarchive"
ENV_PATH="$APP_DIRECTORY/.env"
RELEASE_SCRIPT_PATH="$SCRIPTS_DIRECTORY/release.sh"

Expand Down Expand Up @@ -75,20 +76,6 @@ if [ -f "$ENV_PATH" ] ; then
source "$ENV_PATH"
fi

function xcode_project {
xcodebuild \
-project OpoLua.xcodeproj "$@"
}

function build_scheme {
# Disable code signing for the build server.
xcode_project \
-scheme "$1" \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO "${@:2}"
}

# Ensure the Lua source compiles.
cd "$SRC_DIRECTORY"
luac -p *.lua
Expand All @@ -100,7 +87,9 @@ IOS_XCODE_PATH=${IOS_XCODE_PATH:-/Applications/Xcode.app}
sudo xcode-select --switch "$IOS_XCODE_PATH"

# List the available schemes.
xcode_project -list
xcodebuild \
-project OpoLua.xcodeproj \
-list

# Clean up the build directory.
if [ -d "$BUILD_DIRECTORY" ] ; then
Expand Down Expand Up @@ -137,28 +126,51 @@ BUILD_NUMBER=`build-tools generate-build-number`

# Import the certificates into our dedicated keychain.
echo "$APPLE_DISTRIBUTION_CERTIFICATE_PASSWORD" | build-tools import-base64-certificate --password "$KEYCHAIN_PATH" "$APPLE_DISTRIBUTION_CERTIFICATE_BASE64"
echo "$MACOS_DEVELOPER_INSTALLER_CERTIFICATE_PASSWORD" | build-tools import-base64-certificate --password "$KEYCHAIN_PATH" "$MACOS_DEVELOPER_INSTALLER_CERTIFICATE_BASE64"

# Install the provisioning profiles.
build-tools install-provisioning-profile "$APP_DIRECTORY/profiles/OpoLua_App_Store_Profile.mobileprovision"
build-tools install-provisioning-profile "$APP_DIRECTORY/profiles/OpoLua_Mac_Catalyst_App_Store_Profile.provisionprofile"

# Build and archive the iOS project.
xcode_project \
sudo xcode-select --switch "$IOS_XCODE_PATH"
xcodebuild \
-project OpoLua.xcodeproj \
-scheme "OpoLua" \
-config Release \
-archivePath "$ARCHIVE_PATH" \
-archivePath "$IOS_ARCHIVE_PATH" \
-destination "generic/platform=iOS" \
OTHER_CODE_SIGN_FLAGS="--keychain=\"${KEYCHAIN_PATH}\"" \
CURRENT_PROJECT_VERSION=$BUILD_NUMBER \
MARKETING_VERSION=$VERSION_NUMBER \
clean archive
xcodebuild \
-archivePath "$ARCHIVE_PATH" \
-archivePath "$IOS_ARCHIVE_PATH" \
-exportArchive \
-exportPath "$BUILD_DIRECTORY" \
-exportOptionsPlist "${APP_DIRECTORY}/ExportOptions.plist"
-exportOptionsPlist "$APP_DIRECTORY/ExportOptions-iOS.plist"
IPA_PATH="$BUILD_DIRECTORY/OpoLua.ipa"

if $RELEASE ; then
# Builds the macOS project.
sudo xcode-select --switch "$MACOS_XCODE_PATH"
xcodebuild \
-project OpoLua.xcodeproj \
-scheme "OpoLua" \
-config Release \
-archivePath "$MACOS_ARCHIVE_PATH" \
-destination "generic/platform=macOS,variant=Mac Catalyst" \
OTHER_CODE_SIGN_FLAGS="--keychain=\"${KEYCHAIN_PATH}\"" \
CURRENT_PROJECT_VERSION=$BUILD_NUMBER \
MARKETING_VERSION=$VERSION_NUMBER \
clean archive
xcodebuild \
-archivePath "$MACOS_ARCHIVE_PATH" \
-exportArchive \
-exportPath "$BUILD_DIRECTORY" \
-exportOptionsPlist "$APP_DIRECTORY/ExportOptions-macCatalyst.plist"
PKG_PATH="$BUILD_DIRECTORY/OpoLua.pkg"

IPA_PATH="$BUILD_DIRECTORY/OpoLua.ipa"
if $RELEASE ; then

# Archive the build directory.
ZIP_BASENAME="build-${VERSION_NUMBER}-${BUILD_NUMBER}.zip"
Expand All @@ -176,7 +188,6 @@ if $RELEASE ; then
--pre-release \
--push \
--exec "${RELEASE_SCRIPT_PATH}" \
"${IPA_PATH}" "${ZIP_PATH}"

"$IPA_PATH" "$PKG_PATH" "$ZIP_PATH"

fi
14 changes: 14 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ xcrun altool --upload-app \
--apiIssuer "$APPLE_API_KEY_ISSUER_ID" \
--type ios

# Validate and upload the macOS build.
xcrun altool --validate-app \
-f "$2" \
--apiKey "$APPLE_API_KEY_ID" \
--apiIssuer "$APPLE_API_KEY_ISSUER_ID" \
--output-format json \
--type macos
xcrun altool --upload-app \
-f "$2" \
--primary-bundle-id "uk.co.inseven.opolua" \
--apiKey "$APPLE_API_KEY_ID" \
--apiIssuer "$APPLE_API_KEY_ISSUER_ID" \
--type macos

# Actually make the release.
FLAGS=()
if $CHANGES_INITIAL_DEVELOPMENT ; then
Expand Down
6 changes: 4 additions & 2 deletions swift/PsiLuaEnv.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public class PsiLuaEnv {
L = LuaState(libraries: [.package, .table, .io, .os, .string, .math, .utf8, .debug])
L.setDefaultStringEncoding(kDefaultEpocEncoding)

L.setRequireRoot(nil)
L.addModules(lua_sources)
let srcRoot = Bundle.main.url(forResource: "init",
withExtension: "lua",
subdirectory: "src")!.deletingLastPathComponent()
L.setRequireRoot(srcRoot.path)

// Finally, run init.lua
require("init")
Expand Down

0 comments on commit a3d496f

Please sign in to comment.