Skip to content

xcodebuild fails to build swift-asn1 with 'self' used before 'self.init' errors #106

@adamkornafeld

Description

@adamkornafeld

Trying to use swift-asn1 as a SPM dependency in an iOS project.

  • Using Xcode’s GUI: The project builds successfully.

  • Using xcodebuild: The build fails with the following errors:

    .build/SourcePackages/checkouts/swift-asn1/Sources/SwiftASN1/ASN1.swift:95:29: error: 'self' used before 'self.init' call or assignment to 'self'
                self.identifier = identifier
                                ^
    .build/SourcePackages/checkouts/swift-asn1/Sources/SwiftASN1/ASN1.swift:96:24: error: 'self' used before 'self.init' call or assignment to 'self'
                self.depth = depth
                           ^
    .build/SourcePackages/checkouts/swift-asn1/Sources/SwiftASN1/ASN1.swift:97:32: error: 'self' used before 'self.init' call or assignment to 'self'
                self.isConstructed = isConstructed
                                   ^
    .build/SourcePackages/checkouts/swift-asn1/Sources/SwiftASN1/ASN1.swift:98:31: error: 'self' used before 'self.init' call or assignment to 'self'
                self.encodedBytes = encodedBytes
                                  ^
    .build/SourcePackages/checkouts/swift-asn1/Sources/SwiftASN1/ASN1.swift:99:28: error: 'self' used before 'self.init' call or assignment to 'self'
                self.dataBytes = dataBytes
                               ^
    .build/SourcePackages/checkouts/swift-asn1/Sources/SwiftASN1/ASN1.swift:100:9: error: 'self.init' isn't called on all paths before returning from initializer
            }
            ^
    .build/SourcePackages/checkouts/swift-asn1/Sources/SwiftASN1/ASN1.swift:139:24: error: 'self' used before 'self.init' call or assignment to 'self'
                self.nodes = nodes
                           ^
    

What I’ve found so far:
From what I can tell, the issue seems related to the use of @inline on initializer functions. I’ve tried comparing build settings between the GUI and command line but couldn’t find any differences that explain the behavior.

Environment:

  • Swift 6.0
  • Xcode version: 16.2
  • macOS version: 15.5

Command used:

xcodebuild build \
	-configuration Release \
	-scheme 'MyApp' \
	-sdk iphoneos \
	-destination 'generic/platform=iOS' \
	-derivedDataPath "$(PWD)/.build" \
	SKIP_INSTALL=NO \
	BUILD_LIBRARY_FOR_DISTRIBUTION=YES

Question:
Do you have any insights into why this happens with xcodebuild but not when building through Xcode’s GUI?

Thanks for maintaining this repo, it's great!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions