SRGSSR / srguserdata-apple

A framework to store user data and synchronize it with an account
MIT License
1 stars 0 forks source link

Building a project with SPM integration on Mac OS Ventura generates CoreData errors #5

Closed pyby closed 1 year ago

pyby commented 1 year ago

ℹ️ This issue is created after investigation on Play SRG project: https://github.com/SRGSSR/playsrg-apple/issues/299

Issue type

Incorrect behavior:

Description of the problem

Since Play SRG project is built with Xcode 14.x and running on Mac OS Ventura, a new error during the compilation appeared. This error does not return a nonzero exit code to indicate failure and in Xcode UI app, the action is done successfully, build or archive. It's annoying errors but not blocker with Xcode app. But it's block the CI, which use fastlane, and behind, xcodebuild.

MappingModelCompile /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v5_v6.cdm /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v5_v6.xcmappingmodel (in target 'SRGUserData_SRGUserData' from project 'SRGUserData')
    cd /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple
    /Applications/Xcode-14.2.0.app/Contents/Developer/usr/bin/mapc --sdkroot /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS16.1.sdk --appletvos-deployment-target 12.0 --module SRGUserData_SRGUserData /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v5_v6.xcmappingmodel /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v5_v6.cdm
CoreData: error: Executing as effective user 501
CoreData: error: Information for /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v5_v6.xcmappingmodel/xcmapping.xml
CoreData: error: ---------------------------
CoreData: error:   File Device ID:  0
CoreData: error:   Device ID:       16777233
CoreData: error:   File Size:       99995 bytes
CoreData: error:   File inode:      226048451
CoreData: error:   File user ID:        501
CoreData: error:   File group ID:       20
CoreData: error:   File Permissions:    
CoreData: error: -
CoreData: error:   444
CoreData: error:   file is not a symbolic link
CoreData: error: Information for file system
CoreData: error: ---------------------------
CoreData: error:   File system type:        0x1a
CoreData: error:   File system flags:       0x4909080
CoreData: error:   MNT_JOURNALED
CoreData: error:   Total data blocks:       242837545
CoreData: error:   Free data blocks:        40611358
CoreData: error:   Free blocks for nonsuperuser:    40611358
CoreData: error:   Total i-nodes:           1634128763
CoreData: error:   File system ID:      0x1000011, 0x1a
CoreData: error:   Free i-nodes:            1624454320
CoreData: error:   Owner UID:           0
CoreData: error:   Filesystem type name:        apfs
CoreData: error:   Mount on name:           /System/Volumes/Data
CoreData: error:   Mount from name:         /dev/disk3s5
2023-04-01 19:37:52.147 mapc[49795:5853949] Attempt to add read-only file at path file:///Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v5_v6.xcmappingmodel/xcmapping.xml read/write. Adding it read-only instead. This will be a hard error in the future; you must specify the NSReadOnlyPersistentStoreOption.
Command MappingModelCompile emitted errors but did not return a nonzero exit code to indicate failure

MappingModelCompile /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v6_v7.cdm /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v6_v7.xcmappingmodel (in target 'SRGUserData_SRGUserData' from project 'SRGUserData')
    cd /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple
    /Applications/Xcode-14.2.0.app/Contents/Developer/usr/bin/mapc --sdkroot /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS16.1.sdk --appletvos-deployment-target 12.0 --module SRGUserData_SRGUserData /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v6_v7.xcmappingmodel /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v6_v7.cdm
CoreData: error: Executing as effective user 501
CoreData: error: Information for /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v6_v7.xcmappingmodel/xcmapping.xml
CoreData: error: ---------------------------
CoreData: error:   File Device ID:  0
CoreData: error:   Device ID:       16777233
CoreData: error:   File Size:       129884 bytes
CoreData: error:   File inode:      226048453
CoreData: error:   File user ID:        501
CoreData: error:   File group ID:       20
CoreData: error:   File Permissions:    
CoreData: error: -
CoreData: error:   444
CoreData: error:   file is not a symbolic link
CoreData: error: Information for file system
CoreData: error: ---------------------------
CoreData: error:   File system type:        0x1a
CoreData: error:   File system flags:       0x4909080
CoreData: error:   MNT_JOURNALED
CoreData: error:   Total data blocks:       242837545
CoreData: error:   Free data blocks:        40611358
CoreData: error:   Free blocks for nonsuperuser:    40611358
CoreData: error:   Total i-nodes:           1634128763
CoreData: error:   File system ID:      0x1000011, 0x1a
CoreData: error:   Free i-nodes:            1624454320
CoreData: error:   Owner UID:           0
CoreData: error:   Filesystem type name:        apfs
CoreData: error:   Mount on name:           /System/Volumes/Data
CoreData: error:   Mount from name:         /dev/disk3s5
2023-04-01 19:37:52.146 mapc[49796:5853950] Attempt to add read-only file at path file:///Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v6_v7.xcmappingmodel/xcmapping.xml read/write. Adding it read-only instead. This will be a hard error in the future; you must specify the NSReadOnlyPersistentStoreOption.
Command MappingModelCompile emitted errors but did not return a nonzero exit code to indicate failure

MappingModelCompile /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v3_v4.cdm /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v3_v4.xcmappingmodel (in target 'SRGUserData_SRGUserData' from project 'SRGUserData')
    cd /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple
    /Applications/Xcode-14.2.0.app/Contents/Developer/usr/bin/mapc --sdkroot /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS16.1.sdk --appletvos-deployment-target 12.0 --module SRGUserData_SRGUserData /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v3_v4.xcmappingmodel /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v3_v4.cdm
CoreData: error: Executing as effective user 501
CoreData: error: Information for /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v3_v4.xcmappingmodel/xcmapping.xml
CoreData: error: ---------------------------
CoreData: error:   File Device ID:  0
CoreData: error:   Device ID:       16777233
CoreData: error:   File Size:       91700 bytes
CoreData: error:   File inode:      226048447
CoreData: error:   File user ID:        501
CoreData: error:   File group ID:       20
CoreData: error:   File Permissions:    
CoreData: error: -
CoreData: error:   444
CoreData: error:   file is not a symbolic link
CoreData: error: Information for file system
CoreData: error: ---------------------------
CoreData: error:   File system type:        0x1a
CoreData: error:   File system flags:       0x4909080
CoreData: error:   MNT_JOURNALED
CoreData: error:   Total data blocks:       242837545
CoreData: error:   Free data blocks:        40611358
CoreData: error:   Free blocks for nonsuperuser:    40611358
CoreData: error:   Total i-nodes:           1634128763
CoreData: error:   File system ID:      0x1000011, 0x1a
CoreData: error:   Free i-nodes:            1624454320
CoreData: error:   Owner UID:           0
CoreData: error:   Filesystem type name:        apfs
CoreData: error:   Mount on name:           /System/Volumes/Data
CoreData: error:   Mount from name:         /dev/disk3s5
2023-04-01 19:37:52.146 mapc[49797:5853951] Attempt to add read-only file at path file:///Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v3_v4.xcmappingmodel/xcmapping.xml read/write. Adding it read-only instead. This will be a hard error in the future; you must specify the NSReadOnlyPersistentStoreOption.
Command MappingModelCompile emitted errors but did not return a nonzero exit code to indicate failure

MappingModelCompile /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v4_v5.cdm /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v4_v5.xcmappingmodel (in target 'SRGUserData_SRGUserData' from project 'SRGUserData')
    cd /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple
    /Applications/Xcode-14.2.0.app/Contents/Developer/usr/bin/mapc --sdkroot /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS16.1.sdk --appletvos-deployment-target 12.0 --module SRGUserData_SRGUserData /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v4_v5.xcmappingmodel /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v4_v5.cdm
CoreData: error: Executing as effective user 501
CoreData: error: Information for /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v4_v5.xcmappingmodel/xcmapping.xml
CoreData: error: ---------------------------
CoreData: error:   File Device ID:  0
CoreData: error:   Device ID:       16777233
CoreData: error:   File Size:       91268 bytes
CoreData: error:   File inode:      226048449
CoreData: error:   File user ID:        501
CoreData: error:   File group ID:       20
CoreData: error:   File Permissions:    
CoreData: error: -
CoreData: error:   444
CoreData: error:   file is not a symbolic link
CoreData: error: Information for file system
CoreData: error: ---------------------------
CoreData: error:   File system type:        0x1a
CoreData: error:   File system flags:       0x4909080
CoreData: error:   MNT_JOURNALED
CoreData: error:   Total data blocks:       242837545
CoreData: error:   Free data blocks:        40611358
CoreData: error:   Free blocks for nonsuperuser:    40611358
CoreData: error:   Total i-nodes:           1634128763
CoreData: error:   File system ID:      0x1000011, 0x1a
CoreData: error:   Free i-nodes:            1624454320
CoreData: error:   Owner UID:           0
CoreData: error:   Filesystem type name:        apfs
CoreData: error:   Mount on name:           /System/Volumes/Data
CoreData: error:   Mount from name:         /dev/disk3s5
2023-04-01 19:37:52.147 mapc[49798:5853952] Attempt to add read-only file at path file:///Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v4_v5.xcmappingmodel/xcmapping.xml read/write. Adding it read-only instead. This will be a hard error in the future; you must specify the NSReadOnlyPersistentStoreOption.
Command MappingModelCompile emitted errors but did not return a nonzero exit code to indicate failure

MappingModelCompile /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v2_v3.cdm /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v2_v3.xcmappingmodel (in target 'SRGUserData_SRGUserData' from project 'SRGUserData')
    cd /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple
    /Applications/Xcode-14.2.0.app/Contents/Developer/usr/bin/mapc --sdkroot /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS16.1.sdk --appletvos-deployment-target 12.0 --module SRGUserData_SRGUserData /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v2_v3.xcmappingmodel /Users/pyby/Developer/playsrg-apple/build/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Play\ RTS\ TV/IntermediateBuildFilesPath/UninstalledProducts/appletvos/SRGUserData_SRGUserData.bundle/SRGUserData_v2_v3.cdm
CoreData: error: Executing as effective user 501
CoreData: error: Information for /Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v2_v3.xcmappingmodel/xcmapping.xml
CoreData: error: ---------------------------
CoreData: error:   File Device ID:  0
CoreData: error:   Device ID:       16777233
CoreData: error:   File Size:       99043 bytes
CoreData: error:   File inode:      226048445
CoreData: error:   File user ID:        501
CoreData: error:   File group ID:       20
CoreData: error:   File Permissions:    
CoreData: error: -
CoreData: error:   444
CoreData: error:   file is not a symbolic link
CoreData: error: Information for file system
CoreData: error: ---------------------------
CoreData: error:   File system type:        0x1a
CoreData: error:   File system flags:       0x4909080
CoreData: error:   MNT_JOURNALED
CoreData: error:   Total data blocks:       242837545
CoreData: error:   Free data blocks:        40611358
CoreData: error:   Free blocks for nonsuperuser:    40611358
CoreData: error:   Total i-nodes:           1634128763
CoreData: error:   File system ID:      0x1000011, 0x1a
CoreData: error:   Free i-nodes:            1624454320
CoreData: error:   Owner UID:           0
CoreData: error:   Filesystem type name:        apfs
CoreData: error:   Mount on name:           /System/Volumes/Data
CoreData: error:   Mount from name:         /dev/disk3s5
2023-04-01 19:37:52.147 mapc[49799:5853953] Attempt to add read-only file at path file:///Users/pyby/Developer/playsrg-apple/build/DerivedData/SourcePackages/checkouts/srguserdata-apple/Sources/SRGUserData/Data/SRGUserData_v2_v3.xcmappingmodel/xcmapping.xml read/write. Adding it read-only instead. This will be a hard error in the future; you must specify the NSReadOnlyPersistentStoreOption.
Command MappingModelCompile emitted errors but did not return a nonzero exit code to indicate failure

Environment information

Reproducibility

Always reproducible

Steps to reproduce

  1. Create a new Xcode project on Mac OS Ventura with Xcode 14.
  2. Add SRGUSerData library in the iOS target.
  3. Archive the iOS target.
  4. Archive works, even if "CoreData" errors are displayed.
  5. Open the Terminal app.
  6. Archive the same iOS target. Example Play RTS TV Nighty: xcodebuild -scheme MyApp -configuration Debug -destination generic/platform\=iOS archive
  7. Archive is done, but last log returns ** ARCHIVE FAILED ** and a nonzero is returned.
pyby commented 1 year ago

Few threads on the web could help…

Using CoreData in a SPM executable https://adrian.schoenig.me/blog/2021/08/18/core-data-and-spm/

Adding Core Data to a Swift Package https://ishabazz.dev/blog/2020/7/5/using-core-data-with-swift-package-manager

iOS Shared CoreData Storage for App Groups https://github.com/maximbilan/iOS-Shared-CoreData-Storage-for-App-Groups

How to solve Core Data error: Attempt to add read-only file at path when trying to access Core Data container in the app extension today widget? https://stackoverflow.com/questions/43897795/how-to-solve-core-data-error-attempt-to-add-read-only-file-at-path-when-trying

NSPersistentContainer / Core Data / ReadOnly store https://stackoverflow.com/questions/46022820/nspersistentcontainer-core-data-readonly-store

I tried the last only, but not convinced: unit tests for migrations failed.

pyby commented 1 year ago

From Apple Swift Package Manager documentation:

/// By default, Swift Package Manager handles common resources types for Apple platforms
/// automatically. For example, you don't need to declare XIB files,
/// storyboards, Core Data file types, and asset catalogs as resources in your
/// package manifest. However, you must explicitly declare other file types — for
/// example, image files — as resources using the
/// ``Resource/process(_:localization:)`` or ``Resource/copy(_:)`` rules.
/// Alternatively, exclude resource files from a target by passing them to the
/// target initializer's ``Target/exclude`` parameter.

The resource "Data" with CoreData files seems to not be included on SPM declared resources.

Removed from the Package.swift file, no impact on Play SRG product: Xcode "Build and Run" works, but the xcodebuild archive still failed for same reason.