Skip to content

NSCFString fatalError("Constant strings cannot be deallocated") #4804

Open
@compnerd

Description

@compnerd

When trying to do the following:

print(Bundle.module.url(forResource: "Info", withExtension: "plist", subdirectory: "Resources"))

the fatalError at https://github.com/apple/swift-corelibs-foundation/blob/main/Sources/Foundation/NSCFString.swift#L118-L120 is triggered.

This is due to Bundle.url(forResource:withException:subdirectory:) invoking CFBundleCopyResourceURL, which in turn invokes _CFBundleCopyFindResources, which will run the following:

if (realSubdirectory) CFRelease(realSubdirectory);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions