The project is compiling BOTH iOS and macOS files together, causing:
- Duplicate class definitions
- Platform-specific code conflicts
- Invalid redeclarations
- Select the Project → Click "Pets Therapy" in navigator
- Select Target → Choose "Pets Therapy" (macOS, not Mobile)
- Go to Build Settings tab
- Search for: "Excluded Source File Names"
- Double-click the setting for Debug and Release
- Add these exclusion patterns:
**/iOS/** **/NoStatusBar.swift **/MobileSettings.swift
In Build Phases → Compile Sources, remove these if present:
StatusBar/NoStatusBar.swift(iOS-only file)Settings/iOS/MobileSettings.swift(iOS-only)- Any file with
/iOS/in its path
For files that MUST be in both targets but have platform differences:
- Go to Build Settings
- Search: "Active Compilation Conditions"
- Ensure these are set:
- Debug:
DEBUG MACOS - Release:
MACOS
- Debug:
The error "Reference to member 'shared' cannot be resolved" at line 32 needs context.
- Open
Sources/Models/AppConfig.swift - Line 32 likely has something like
.sharedwithout specifying the type - Add the full type, e.g., change:
- From:
.shared - To:
AppConfig.sharedorSomeClass.shared
- From:
- Product → Clean Build Folder (⌘+⇧+K)
- Close Xcode
- Delete DerivedData:
rm -rf ~/Library/Developer/Xcode/DerivedData/Pets_Therapy-*
- Reopen Xcode
- Product → Build (⌘+B)
- Keep:
StatusBar/StatusBar.swift(macOS) - Exclude:
StatusBar/NoStatusBar.swift(iOS stub)
-
macOS Settings (keep in macOS target):
Settings/macOS/DesktopInteractionsSettings.swiftSettings/macOS/LaunchAtLoginSettings.swiftSettings/macOS/MenuBarSwitch.swiftSettings/macOS/ScreensSettings.swiftSettings/macOS/AISettings.swift
-
iOS Settings (exclude from macOS target):
Settings/iOS/MobileSettings.swift
If some files MUST be shared, use conditional compilation:
#if os(macOS)
// macOS-specific code
import AppKit
#elseif os(iOS)
// iOS-specific code
import UIKit
#endifAfter fixing, you should see:
- ✅ No "Invalid redeclaration" errors
- ✅ No "Ambiguous use" errors
- ✅ Clean build succeeds
- ✅ Only platform-appropriate files compile for each target
Run this to see which files are problematic:
# Find all iOS-specific files
find Sources/swift/Sources -path "*/iOS/*" -name "*.swift" -type f
# Find duplicate class definitions
grep -r "class StatusBarCoordinator" Sources/swift/Sources/The key is ensuring iOS files are NOT compiled in the macOS target!