Closed CEDENOGLOBANT closed 8 months ago
Can you go into the Factory code and make the FactoryKey initializer public and see if that helps matters?
Hello, that didn't work, after many intends , the only thing that work was remove or inline, usableFromInline, also was necessary to add this settings to the package
let settings: [SwiftSetting] settings = [.unsafeFlags(["-no-verify-emitted-module-interface"], .when(configuration: .release))]
How can I push a new branch?
I figure it out a way to keep the inline and has a successful build, just change it to a class and create a convenience init
public class FactoryKey: Hashable {
@usableFromInline let type: ObjectIdentifier
@usableFromInline let key: StaticString
@inlinable
@inline(__always)
public convenience init(type: Any.Type, key: StaticString = #function) {
self.init(type: ObjectIdentifier(type),key: key)
}
public init(type: ObjectIdentifier, key: StaticString) {
self.type = type
self.key = key
}
@inlinable
@inline(__always)
public func hash(into hasher: inout Hasher) {
hasher.combine(self.type)
if key.hasPointerRepresentation {
hasher.combine(bytes: UnsafeRawBufferPointer(start: key.utf8Start, count: key.utf8CodeUnitCount))
} else {
hasher.combine(key.unicodeScalar.value)
}
}
@inlinable
public static func == (lhs: FactoryKey, rhs: FactoryKey) -> Bool {
guard lhs.type == rhs.type && lhs.key.hasPointerRepresentation == rhs.key.hasPointerRepresentation else {
return false
}
if lhs.key.hasPointerRepresentation {
return lhs.key.utf8Start == rhs.key.utf8Start || strcmp(lhs.key.utf8Start, rhs.key.utf8Start) == 0
} else {
return lhs.key.unicodeScalar.value == rhs.key.unicodeScalar.value
}
}
}
It may be that the inlines need to be removed. FactoryKey is created and recreated quite a bit and it most certainly doesn't want to become a class with allocation overhead.
Still work as struct without the convenience , as long we have a init is not inline
// // Key.swift // // // Created by Michael Long on 8/17/23. //
import Foundation
public struct FactoryKey: Hashable {
@usableFromInline let type: ObjectIdentifier
@usableFromInline let key: StaticString
@inlinable
@inline(__always)
public init(type: Any.Type, key: StaticString = #function) {
self.init(type: ObjectIdentifier(type),key: key)
}
public init(type: ObjectIdentifier, key: StaticString) {
self.type = type
self.key = key
}
@inlinable
@inline(__always)
public func hash(into hasher: inout Hasher) {
hasher.combine(self.type)
if key.hasPointerRepresentation {
hasher.combine(bytes: UnsafeRawBufferPointer(start: key.utf8Start, count: key.utf8CodeUnitCount))
} else {
hasher.combine(key.unicodeScalar.value)
}
}
@inlinable
public static func == (lhs: Self, rhs: Self) -> Bool {
guard lhs.type == rhs.type && lhs.key.hasPointerRepresentation == rhs.key.hasPointerRepresentation else {
return false
}
if lhs.key.hasPointerRepresentation {
return lhs.key.utf8Start == rhs.key.utf8Start || strcmp(lhs.key.utf8Start, rhs.key.utf8Start) == 0
} else {
return lhs.key.unicodeScalar.value == rhs.key.unicodeScalar.value
}
}
}
Probably need to just do a plain initializer. Makes no sense to make it inlineable only to call a second initializer.
There's a new branch, "key", which has a change which may fix this. Can you pull it and check?
Still not working with key branch same error
Updated converting key to an internal type. Please try branch again.
Still not working with key branch same error
@hmlongco I am facing the same issue trying to create a .xcframework
Tried to do so using key
branch you mentioned, but it didn't work out. However, @CEDENOGLOBANT 's solution in xcode_15_1_build_xcframework
branch works fine
@CEDENOGLOBANT @hmlongco hi guys, any news regarding this issue?
Key branch changes makes key internal and not inlinable. If you pull the branch make sure you clean the pod cache.
Key no longer inlined and internal in 2.3.2
Hello I have an issue while building xcframework when BUILD_LIBRARY_FOR_DISTRIBUTION=YES when is set to NO, builds perfectly
Factory is added to the project by SPM
let' property 'type' may not be initialized directly; use "self.init(...)" or "self = ..." instead
'let' property 'key' may not be initialized directly; use "self.init(...)" or "self = ..." instead self.key = key