Files
Lyrebird/Sources/LyrebirdCLI/ProjectScaffolder+MacOSUIXcode.swift
josh 5e6534a615 v1.6.3 release: notarization-ready macos-ui-xcode template
Scaffolded macOS app now ships audio-input entitlement + mic usage string
under Hardened Runtime (unsandboxed for performance), and compiles under
Swift 6 (NoteController/AppDelegate marked @MainActor).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 08:38:41 -07:00

302 lines
13 KiB
Swift

// ProjectScaffolder+MacOSUIXcode.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Foundation
// MARK: - macos-ui-xcode pbxproj
extension ProjectScaffolder {
/// `project.pbxproj` for the `macos-ui-xcode` template.
///
/// Single application target. Sources live under `<name>/` next to
/// `Info.plist`. Lyrebird + LyrebirdUI pulled in via SPM — remote URL
/// by default, or local `XCLocalSwiftPackageReference` when
/// `lyrebirdPath` is set (`lyrebird new --lyrebird-path ...`).
static func macOSAppPBXProj(name: String, lyrebirdPath: String? = nil) -> String {
let bundleID: String = "\(defaultBundleIdentifierPrefix).\(name)"
let packageRefLabel: String = pbxPackageReferenceLabel(lyrebirdPath: lyrebirdPath)
let packageRefSection: String = pbxPackageReferenceSection(lyrebirdPath: lyrebirdPath)
return """
// !$*UTF8*$!
{
\tarchiveVersion = 1;
\tclasses = {
\t};
\tobjectVersion = 60;
\tobjects = {
/* Begin PBXBuildFile section */
\t\t\(pbxMainSwiftBuild) /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = \(pbxMainSwiftRef) /* main.swift */; };
\t\t\(pbxAppDelegateBuild) /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = \(pbxAppDelegateRef) /* AppDelegate.swift */; };
\t\t\(pbxSynthBuild) /* \(name)Synth.swift in Sources */ = {isa = PBXBuildFile; fileRef = \(pbxSynthRef) /* \(name)Synth.swift */; };
\t\t\(pbxNoteControllerBuild) /* NoteController.swift in Sources */ = {isa = PBXBuildFile; fileRef = \(pbxNoteControllerRef) /* NoteController.swift */; };
\t\t\(pbxViewBuild) /* \(name)View.swift in Sources */ = {isa = PBXBuildFile; fileRef = \(pbxViewRef) /* \(name)View.swift */; };
\t\t\(pbxLyrebirdUIFrameworkBuild) /* LyrebirdUI in Frameworks */ = {isa = PBXBuildFile; productRef = \(pbxLyrebirdUIProductDep) /* LyrebirdUI */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
\t\t\(pbxAppProductRef) /* \(name).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = \(name).app; sourceTree = BUILT_PRODUCTS_DIR; };
\t\t\(pbxInfoPlistRef) /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
\t\t\(pbxAppEntitlementsRef) /* \(name).entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = \(name).entitlements; sourceTree = "<group>"; };
\t\t\(pbxMainSwiftRef) /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
\t\t\(pbxAppDelegateRef) /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
\t\t\(pbxSynthRef) /* \(name)Synth.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \(name)Synth.swift; sourceTree = "<group>"; };
\t\t\(pbxNoteControllerRef) /* NoteController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteController.swift; sourceTree = "<group>"; };
\t\t\(pbxViewRef) /* \(name)View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = \(name)View.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
\t\t\(pbxFrameworksPhase) /* Frameworks */ = {
\t\t\tisa = PBXFrameworksBuildPhase;
\t\t\tbuildActionMask = \(pbxBuildActionMask);
\t\t\tfiles = (
\t\t\t\t\(pbxLyrebirdUIFrameworkBuild) /* LyrebirdUI in Frameworks */,
\t\t\t);
\t\t\trunOnlyForDeploymentPostprocessing = 0;
\t\t};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
\t\t\(pbxMainGroup) = {
\t\t\tisa = PBXGroup;
\t\t\tchildren = (
\t\t\t\t\(pbxAppGroup) /* \(name) */,
\t\t\t\t\(pbxProductsGroup) /* Products */,
\t\t\t);
\t\t\tsourceTree = "<group>";
\t\t};
\t\t\(pbxProductsGroup) /* Products */ = {
\t\t\tisa = PBXGroup;
\t\t\tchildren = (
\t\t\t\t\(pbxAppProductRef) /* \(name).app */,
\t\t\t);
\t\t\tname = Products;
\t\t\tsourceTree = "<group>";
\t\t};
\t\t\(pbxAppGroup) /* \(name) */ = {
\t\t\tisa = PBXGroup;
\t\t\tchildren = (
\t\t\t\t\(pbxMainSwiftRef) /* main.swift */,
\t\t\t\t\(pbxAppDelegateRef) /* AppDelegate.swift */,
\t\t\t\t\(pbxSynthRef) /* \(name)Synth.swift */,
\t\t\t\t\(pbxNoteControllerRef) /* NoteController.swift */,
\t\t\t\t\(pbxViewRef) /* \(name)View.swift */,
\t\t\t\t\(pbxInfoPlistRef) /* Info.plist */,
\t\t\t\t\(pbxAppEntitlementsRef) /* \(name).entitlements */,
\t\t\t);
\t\t\tpath = \(name);
\t\t\tsourceTree = "<group>";
\t\t};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
\t\t\(pbxBlueprintIDApp) /* \(name) */ = {
\t\t\tisa = PBXNativeTarget;
\t\t\tbuildConfigurationList = \(pbxAppBuildConfigList) /* Build configuration list for PBXNativeTarget "\(name)" */;
\t\t\tbuildPhases = (
\t\t\t\t\(pbxSourcesPhase) /* Sources */,
\t\t\t\t\(pbxFrameworksPhase) /* Frameworks */,
\t\t\t\t\(pbxResourcesPhase) /* Resources */,
\t\t\t);
\t\t\tbuildRules = (
\t\t\t);
\t\t\tdependencies = (
\t\t\t);
\t\t\tname = \(name);
\t\t\tpackageProductDependencies = (
\t\t\t\t\(pbxLyrebirdUIProductDep) /* LyrebirdUI */,
\t\t\t);
\t\t\tproductName = \(name);
\t\t\tproductReference = \(pbxAppProductRef) /* \(name).app */;
\t\t\tproductType = "com.apple.product-type.application";
\t\t};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
\t\t\(pbxRootObject) /* Project object */ = {
\t\t\tisa = PBXProject;
\t\t\tattributes = {
\t\t\t\tBuildIndependentTargetsInParallel = 1;
\t\t\t\tLastSwiftUpdateCheck = 1600;
\t\t\t\tLastUpgradeCheck = 1600;
\t\t\t\tTargetAttributes = {
\t\t\t\t\t\(pbxBlueprintIDApp) = {
\t\t\t\t\t\tCreatedOnToolsVersion = 16.0;
\t\t\t\t\t};
\t\t\t\t};
\t\t\t};
\t\t\tbuildConfigurationList = \(pbxProjectBuildConfigList) /* Build configuration list for PBXProject "\(name)" */;
\t\t\tcompatibilityVersion = "Xcode 14.0";
\t\t\tdevelopmentRegion = en;
\t\t\thasScannedForEncodings = 0;
\t\t\tknownRegions = (
\t\t\t\ten,
\t\t\t\tBase,
\t\t\t);
\t\t\tmainGroup = \(pbxMainGroup);
\t\t\tpackageReferences = (
\t\t\t\t\(pbxRemoteSPMRef) /* \(packageRefLabel) */,
\t\t\t);
\t\t\tproductRefGroup = \(pbxProductsGroup) /* Products */;
\t\t\tprojectDirPath = "";
\t\t\tprojectRoot = "";
\t\t\ttargets = (
\t\t\t\t\(pbxBlueprintIDApp) /* \(name) */,
\t\t\t);
\t\t};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
\t\t\(pbxResourcesPhase) /* Resources */ = {
\t\t\tisa = PBXResourcesBuildPhase;
\t\t\tbuildActionMask = \(pbxBuildActionMask);
\t\t\tfiles = (
\t\t\t);
\t\t\trunOnlyForDeploymentPostprocessing = 0;
\t\t};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
\t\t\(pbxSourcesPhase) /* Sources */ = {
\t\t\tisa = PBXSourcesBuildPhase;
\t\t\tbuildActionMask = \(pbxBuildActionMask);
\t\t\tfiles = (
\t\t\t\t\(pbxMainSwiftBuild) /* main.swift in Sources */,
\t\t\t\t\(pbxAppDelegateBuild) /* AppDelegate.swift in Sources */,
\t\t\t\t\(pbxSynthBuild) /* \(name)Synth.swift in Sources */,
\t\t\t\t\(pbxNoteControllerBuild) /* NoteController.swift in Sources */,
\t\t\t\t\(pbxViewBuild) /* \(name)View.swift in Sources */,
\t\t\t);
\t\t\trunOnlyForDeploymentPostprocessing = 0;
\t\t};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
\t\t\(pbxAppDebugConfig) /* Debug */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tCODE_SIGN_ENTITLEMENTS = \(name)/\(name).entitlements;
\t\t\t\tCODE_SIGN_STYLE = Automatic;
\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;
\t\t\t\tENABLE_HARDENED_RUNTIME = YES;
\t\t\t\tINFOPLIST_FILE = \(name)/Info.plist;
\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (
\t\t\t\t\t"$(inherited)",
\t\t\t\t\t"@executable_path/../Frameworks",
\t\t\t\t);
\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 15.0;
\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \(bundleID);
\t\t\t\tPRODUCT_NAME = "$(TARGET_NAME)";
\t\t\t\tSWIFT_VERSION = 6.0;
\t\t\t};
\t\t\tname = Debug;
\t\t};
\t\t\(pbxAppReleaseConfig) /* Release */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tCODE_SIGN_ENTITLEMENTS = \(name)/\(name).entitlements;
\t\t\t\tCODE_SIGN_STYLE = Automatic;
\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
\t\t\t\tENABLE_HARDENED_RUNTIME = YES;
\t\t\t\tINFOPLIST_FILE = \(name)/Info.plist;
\t\t\t\tLD_RUNPATH_SEARCH_PATHS = (
\t\t\t\t\t"$(inherited)",
\t\t\t\t\t"@executable_path/../Frameworks",
\t\t\t\t);
\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 15.0;
\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = \(bundleID);
\t\t\t\tPRODUCT_NAME = "$(TARGET_NAME)";
\t\t\t\tSWIFT_VERSION = 6.0;
\t\t\t};
\t\t\tname = Release;
\t\t};
\t\t\(pbxProjectDebugConfig) /* Debug */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;
\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;
\t\t\t\tCOPY_PHASE_STRIP = NO;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;
\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;
\t\t\t\tENABLE_TESTABILITY = YES;
\t\t\t\tENABLE_USER_SCRIPT_SANDBOXING = YES;
\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu17;
\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;
\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;
\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (
\t\t\t\t\t"DEBUG=1",
\t\t\t\t\t"$(inherited)",
\t\t\t\t);
\t\t\t\tONLY_ACTIVE_ARCH = YES;
\t\t\t\tSDKROOT = macosx;
\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = "-Onone";
\t\t\t};
\t\t\tname = Debug;
\t\t};
\t\t\(pbxProjectReleaseConfig) /* Release */ = {
\t\t\tisa = XCBuildConfiguration;
\t\t\tbuildSettings = {
\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;
\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;
\t\t\t\tCOPY_PHASE_STRIP = NO;
\t\t\t\tDEAD_CODE_STRIPPING = YES;
\t\t\t\tDEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
\t\t\t\tENABLE_NS_ASSERTIONS = NO;
\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;
\t\t\t\tENABLE_USER_SCRIPT_SANDBOXING = YES;
\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu17;
\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;
\t\t\t\tSDKROOT = macosx;
\t\t\t\tSWIFT_COMPILATION_MODE = wholemodule;
\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = "-O";
\t\t\t};
\t\t\tname = Release;
\t\t};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
\t\t\(pbxAppBuildConfigList) /* Build configuration list for PBXNativeTarget "\(name)" */ = {
\t\t\tisa = XCConfigurationList;
\t\t\tbuildConfigurations = (
\t\t\t\t\(pbxAppDebugConfig) /* Debug */,
\t\t\t\t\(pbxAppReleaseConfig) /* Release */,
\t\t\t);
\t\t\tdefaultConfigurationIsVisible = 0;
\t\t\tdefaultConfigurationName = Release;
\t\t};
\t\t\(pbxProjectBuildConfigList) /* Build configuration list for PBXProject "\(name)" */ = {
\t\t\tisa = XCConfigurationList;
\t\t\tbuildConfigurations = (
\t\t\t\t\(pbxProjectDebugConfig) /* Debug */,
\t\t\t\t\(pbxProjectReleaseConfig) /* Release */,
\t\t\t);
\t\t\tdefaultConfigurationIsVisible = 0;
\t\t\tdefaultConfigurationName = Release;
\t\t};
/* End XCConfigurationList section */
\(packageRefSection)
/* Begin XCSwiftPackageProductDependency section */
\t\t\(pbxLyrebirdUIProductDep) /* LyrebirdUI */ = {
\t\t\tisa = XCSwiftPackageProductDependency;
\t\t\tpackage = \(pbxRemoteSPMRef) /* \(packageRefLabel) */;
\t\t\tproductName = LyrebirdUI;
\t\t};
/* End XCSwiftPackageProductDependency section */
\t};
\trootObject = \(pbxRootObject) /* Project object */;
}
"""
}
}