@arashgood It did well for me. Another helping instruction is to download the whole project and run it in the simulator or iphone which always runs well.
@XDYB Sorry to copy your answer here.
This error is appeared by a type and type(of:)
Solution 1:
Follow these instructions below and modification
-------------in the file of Metadata.swift :-------------
init?(anyType: Any.Type) {
self.init(pointer: unsafeBitCast(anyType, to: UnsafePointer.self))
if let kind = type(of: self).kind, kind != self.kind {
return nil
}
}
-------------in the file of Properties.swift-------------
func getProperties(forType type: Any.Type) -> [Property.Description]? {
if let nominalType = Metadata.Struct(anyType: type) {
return fetchProperties(nominalType: nominalType)
} else if let nominalType = Metadata.Class(anyType: type) {
return nominalType.properties()
} else if let nominalType = Metadata.ObjcClassWrapper(anyType: type),
let targetType = nominalType.targetType {
return getProperties(forType: targetType)
} else {
return nil
}
}
-------------in the file of Metadata.swift-------------
7条答案
按热度按时间3hvapo4f1#
这是由于type 和 type(of:) 重名!
方式一:按照下面👇方式修改
-------------Metadata.swift 中:-------------
init?(anyType: Any.Type) {
self.init(pointer: unsafeBitCast(anyType, to: UnsafePointer.self))
if let kind = type(of: self).kind, kind != self.kind {
return nil
}
}
-------------Properties.swift 中-------------
func getProperties(forType type: Any.Type) -> [Property.Description]? {
if let nominalType = Metadata.Struct(anyType: type) {
return fetchProperties(nominalType: nominalType)
} else if let nominalType = Metadata.Class(anyType: type) {
return nominalType.properties()
} else if let nominalType = Metadata.ObjcClassWrapper(anyType: type),
let targetType = nominalType.targetType {
return getProperties(forType: targetType)
} else {
return nil
}
}
-------------Metadata.swift中-------------
guard let metaclass = Metadata.Class(anyType: superclass), metaclass.isSwiftClass else {
return nil
}
方式二:按照下面👇方式修改
-------------Metadata.swift 中:-------------
init?(type anyType: Any.Type) {
self.init(pointer: unsafeBitCast(anyType, to: UnsafePointer.self))
if let kind = type(of: self).kind, kind != self.kind {
return nil
}
}
-------------Properties.swift 中-------------
func getProperties(forType anyType: Any.Type) -> [Property.Description]? {
if let nominalType = Metadata.Struct(type: anyType) {
return fetchProperties(nominalType: nominalType)
} else if let nominalType = Metadata.Class(type: anyType) {
return nominalType.properties()
} else if let nominalType = Metadata.ObjcClassWrapper(type: anyType),
let targetType = nominalType.targetType {
return getProperties(forType: targetType)
} else {
return nil
}
}
1szpjjfi2#
太感谢了,就是和type(of:)重名了,按照上面的修改,运行很顺畅
xytpbqjk3#
@XDYB 这上面的代码会被加入到下一个的Pod版本的库吗?
ctehm74n4#
please use english language
mutmk8jj5#
@arashgood just following the instruction as @XDYB commented above, it did work.
qco9c6ql6#
@VictorZhang2014 it's not clear instruction!
5w9g7ksd7#
@arashgood It did well for me. Another helping instruction is to download the whole project and run it in the simulator or iphone which always runs well.
@XDYB Sorry to copy your answer here.
This error is appeared by a
type
andtype(of:)
Solution 1:
-------------in the file of Metadata.swift :-------------
-------------in the file of Properties.swift-------------
-------------in the file of Metadata.swift-------------
Solution 2
-------------in the file of Metadata.swift :-------------
-------------in the file of Properties.swift -------------