I started using on-demand resources for some data assets. After that, the Swift Asset Symbol Extension feature began to fail in the Xcode editor. Even though the app builds and runs fine, the Xcode editor shows errors, indicating that there is no extension variable for my color and image assets.
I submitted feedback and updated it after each new Xcode release. However, I have not received any responses, and the problem persists.
The Xcode versions I tested: 15.3, 15.4, 16.1, 16.2, 16.3
Steps to reproduce this error:
- Create a new app project (SwiftUI, Swift).
- Create a new color asset named "myBackground."
- In ContentView, add a background modifier to a view: .background(Color.myBackground). Auto-completion will work, and there are no issues.
- Create a new data asset named "myData."
- Add the "On Demand Resource" tag to "myData" with the tag "some_tag."
- Create a new color asset named "myOtherBackground" and make its color different from "myBackground."
- In ContentView, try to replace the background with Color.myOtherBackground. It will not be listed in auto-completion and will show the error "Type 'Color' has no member 'myOtherBackground.'"
- However, it will still compile and show "myOtherBackground" in the preview, simulator, or on the device.
- You will start to see the failed "Project Build Preparation" report in the Reports Navigator in Xcode.
- According to the report, the "GenerateAssetSymbols" command fails.
Error message:
GenerateAssetSymbols /Users/***/Projects/***/***/Assets.xcassets (in target '***' from project '***')
cd /Users/***/Projects/***
/Applications/Xcode_15.3.app/Contents/Developer/usr/bin/actool --output-format human-readable-text --notices --warnings --export-dependency-info /Users/***/Library/Developer/Xcode/DerivedData/***-***/Index.noindex/Build/Intermediates.noindex/***.build/Debug-iphonesimulator/***.build/assetcatalog_dependencies --output-partial-info-plist /Users/***/Library/Developer/Xcode/DerivedData/***-***/Index.noindex/Build/Intermediates.noindex/***.build/Debug-iphonesimulator/***.build/assetcatalog_generated_info.plist --app-icon AppIcon --accent-color tint --compress-pngs --enable-on-demand-resources YES --development-region en --target-device iphone --minimum-deployment-target 15.0 --platform iphonesimulator --asset-pack-output-specifications /Users/***/Library/Developer/Xcode/DerivedData/***-***/Index.noindex/Build/Intermediates.noindex/***.build/Debug-iphonesimulator/***.build/AssetPackOutputSpecifications.plist --compile /Users/***/Library/Developer/Xcode/DerivedData/***-***/Index.noindex/Build/Products/Debug-iphonesimulator/workoutai.app /Users/***/Projects/***/***/Assets.xcassets --bundle-identifier *** --generate-swift-asset-symbols /Users/***/Library/Developer/Xcode/DerivedData/***-***/Index.noindex/Build/Intermediates.noindex/***.build/Debug-iphonesimulator/***.build/DerivedSources/GeneratedAssetSymbols.swift --generate-objc-asset-symbols /Users/***/Library/Developer/Xcode/DerivedData/***-***/Index.noindex/Build/Intermediates.noindex/***.build/Debug-iphonesimulator/***.build/DerivedSources/GeneratedAssetSymbols.h --generate-asset-symbol-index /Users/***/Library/Developer/Xcode/DerivedData/***-***/Index.noindex/Build/Intermediates.noindex/***.build/Debug-iphonesimulator/***.build/DerivedSources/GeneratedAssetSymbols-Index.plist
/* com.apple.actool.errors */
: error: Could not create a NSArray from '/Users/***/Library/Developer/Xcode/DerivedData/***-***/Index.noindex/Build/Intermediates.noindex/***.build/Debug-iphonesimulator/***.build/AssetPackOutputSpecifications.plist'.
: error: Not enough arguments provided; where is the input document to operate on?
Command GenerateAssetSymbols failed with a nonzero exit code