So turns out that attempting to compile/build SwiftyJSON after installing Swift 3.0.1 on Ubuntu is a messy deal. Here's the result after issuing 'swift build'
Compile Swift Module 'SwiftyJSON' (1 sources)
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:67:100: error: use of undeclared type 'NSErrorPointer'
public init(data:Data, options opt: JSONSerialization.ReadingOptions = .allowFragments, error: NSErrorPointer = nil) {
^~~~~~~~~~~~~~
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:87:23: error: argument labels '(data:)' do not match any available overloads
.flatMap{ JSON(data: $0) } ?? JSON(NSNull())
^ ~~~~~~~~~~
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:87:23: note: overloads for 'JSON' exist with these partially matching parameter lists: (Any), ([JSON]), ([String : JSON]), (stringLiteral: StringLiteralType), (extendedGraphemeClusterLiteral: StringLiteralType), (unicodeScalarLiteral: StringLiteralType), (integerLiteral: IntegerLiteralType), (booleanLiteral: BooleanLiteralType), (floatLiteral: FloatLiteralType), (dictionaryLiteral: (String, Any)...), (dictionaryLiteral: [(String, Any)]), (arrayLiteral: Any...), (nilLiteral: ()), (rawValue: Any)
.flatMap{ JSON(data: $0) } ?? JSON(NSNull())
^
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:109:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(jsonArray.map { $0.object })
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:124:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(dictionary)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:199:49: error: cannot invoke initializer for type 'JSON' with an argument list of type '(NSNull)'
public static var null: JSON { get { return JSON(NSNull()) } }
^
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:199:49: note: overloads for 'JSON' exist with these partially matching parameter lists: (Any), ([JSON]), ([String : JSON])
public static var null: JSON { get { return JSON(NSNull()) } }
^
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:484:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(value as Any)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:488:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(value as Any)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:492:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(value as Any)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:499:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(value as Any)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:506:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(value as Any)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:513:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(value as Any)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:520:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(dictionaryLiteral: array)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:553:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(dict)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:560:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(elements as Any)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:568:9: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(NSNull() as Any)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:580:13: error: 'init' is a member of the type; use 'type(of: ...)' to initialize a new object of the same dynamic type
self.init(rawValue)
^
type(of: )
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:1278:20: error: cannot convert value of type '[Any]' to type 'NSArray' in coercion
return lhs.rawArray as NSArray == rhs.rawArray as NSArray
~~~~^~~~~~~~
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:1280:20: error: cannot convert value of type '[String : Any]' to type 'NSDictionary' in coercion
return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
~~~~^~~~~~~~~~~~~
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:1298:20: error: cannot convert value of type '[Any]' to type 'NSArray' in coercion
return lhs.rawArray as NSArray == rhs.rawArray as NSArray
~~~~^~~~~~~~
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:1300:20: error: cannot convert value of type '[String : Any]' to type 'NSDictionary' in coercion
return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
~~~~^~~~~~~~~~~~~
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:1318:20: error: cannot convert value of type '[Any]' to type 'NSArray' in coercion
return lhs.rawArray as NSArray == rhs.rawArray as NSArray
~~~~^~~~~~~~
/root/proj/Packages/SwiftyJSON-3.1.3/Source/SwiftyJSON.swift:1320:20: error: cannot convert value of type '[String : Any]' to type 'NSDictionary' in coercion
return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
~~~~^~~~~~~~~~~~~
<unknown>:0: error: build had 1 command failures`
I know from experience that the Linux Swift variant is a lot more type restrictive, but with that being said, is it possible to get this going? My intention is to use it alongside Perfect Swift for a server.
@FridaySG Yes, I believe this is an existing issue on Ubuntu, I am currently working on this. Thanks for filling this. We are going to support this ASAP.
Any idea what the timeline for this fix will be?
@elk941 Sorry for the late response, I have maintained a fork here to start Linux bridging progress. SwiftyJSON is already buildable on Linux, however, there are still some testcases which need more investigation.
Hello All , I got the same error trying to build on ubuntu 16.04 on Raspberry Pi 3 Swift 3 & Package Manger 3. @wongzigii thanks for taking the time to investigate the problem and looking forward for the fix :)
Just adding my experience. I'm unable to build SwiftyJSON within a docker container 4.9.60-linuxkit-aufs using Swift version 4.0.3 (swift-4.0.3-RELEASE).
I'm also unable to build SwiftyJSON for Linux specifically due to the conversions from [Any] or [String: Any] to NSArray and NSDictionary.
SwiftyJSON.swift:1317:20: error: cannot convert value of type '[Any]' to type 'NSArray' in coercion
return lhs.rawArray as NSArray == rhs.rawArray as NSArray
@Takanu @rlubke Hey, can you try the this swift-test-macos branch https://github.com/SwiftyJSON/SwiftyJSON/tree/swift-test-macos to see if this work for you?
@wongzigii
I ran into the same problem on Linux,
using the branch 'swift-test-macos' got rid of the errors.
Getting the same error on Linux with 4.1.0.
@drewmccormack Try this branch if you are playing with Linux platform.
Most helpful comment
@FridaySG Yes, I believe this is an existing issue on Ubuntu, I am currently working on this. Thanks for filling this. We are going to support this ASAP.