Xcode 15 archive failed - file name too long

Hello all, Working on Xcode 15 GA. I'd like to archive my new iOS 17 project, which works properly on iOS and macOS (includes SwiftData library, new WidgetKit extension and StoreKit). However, when I'm trying to archive the project (either for iOS or macOS) I get an error as follows - "Error opening <VERY VERY LONG PATH>_.stringsdata for output: File name too long.

I tried everything - still happens. When I'm looking inside the build folder, I see that this error probably related to new @__swiftmacro files. Have no idea how to proceed from here. Blocked from distributing my new app. Any idea?

Thanks a lot! Dudi

Answered by xinthesize in 766994022

Just an update: If you are using the #Predicate macro in any part of your SwiftUI's body, move it out to its own function and call the function from within your body. That seems to have fixed it for me.

e.g. Instead of:

var body: some View {
    HStack {
        ...
        let predicate = #Predicate<Item> { ... }
        ...
    }
}

Do:

var body: some View {
    HStack {
        ...
        findItems()
        ...
    }
}

func findItems() {
    let predicate = #Predicate<Item> { ... }
    ...
}

Were you able to find a solution to this? I am also seeing this bug

Seeing this too for a project that uses SwiftData (unsure if related).

It might be worth noting that it does not affect building for running, only archiving.

Running in the iOS Simulator and a real device works, but archiving will throw the 'file name too long' error.

Accepted Answer

Just an update: If you are using the #Predicate macro in any part of your SwiftUI's body, move it out to its own function and call the function from within your body. That seems to have fixed it for me.

e.g. Instead of:

var body: some View {
    HStack {
        ...
        let predicate = #Predicate<Item> { ... }
        ...
    }
}

Do:

var body: some View {
    HStack {
        ...
        findItems()
        ...
    }
}

func findItems() {
    let predicate = #Predicate<Item> { ... }
    ...
}

Thanks. Apple approved it is a bug and eventually this approach actually resolved it.

Xcode 15 archive failed - file name too long
 
 
Q