0

I am having an issue in getting my PerfectServer module (called MCPushServer) to compile on Ubuntu when referencing an updated version of PerfectLib. As for my previous question, I have updated PerfectLib to make use of the WebRequest's lazy var param postBodyString in order to access the JSON body data. This all works fine on Mac, but when I copy the new files onto the Linux VM and I recompile the project, my RegistrationHandler in MCPushServer fails to compile as it does not recognise the parameter in WebRequest:

Output from the compiler:

  • MCPushServer/MCUnregistrationHandler.swift:33:28: error: value of type 'WebRequest' has no member 'postBodyString' let bodyData = request.postBodyString

Detailed steps below:

  • Copied PerfectLib onto my remote server
  • Remove pre-existing PerfectLib.so
  • run 'make': PerfectLib.so is re-created and it contains a reference to 'postBodyString (grep the file and it returned a match)
  • run 'sudo make install' to link to /user/local/lib/ > all good
  • Re-compiled PerfectServer
  • cd into Examples/MCPushServer and run make: the above error occurs

I have also tried to comment out existing methods in WebRequest (eg: lazy var params) and repeated the process: I would have expected my Handler to complain about the missing member in WebRequest, but it seems to cope as if nothing has happened.

It looks to me as if there is somewhere an obsolete generated interface of PerfectLib / WebRequest that my module references when trying to build. Is anyone able to point me in the right direction here?

1 Answers1

0

Posting a long response to my own question in case it may help someone else porting their XCode developed code to Linux.

My assumption that my module would not compile when referencing the above members due to some sort of cached generated interface was totally wrong.

The problem lied on me using the Swift 2.2 official release for Ubuntu: that does not contain the (work in progress) Swift Foundation library. When developing on OS X, this is not a problem as I believe that the latest XCode ships with a basic Swift Foundation library, and in any case it would compile any type defined in the Objective-C Foundation library.

Installing the current Swift 3.0 distribution and compiler solved the issue.

My best guess is that the implementation of postBodyString is referencing some Foundation API that required either the Objective-C or the Swift foundation library. I would have expected WebRequest to not compile in the first place instead of not exposing the interface for the incriminated methods, but that is a mystery that I will leave for someone with more expertise on the matter.

Similarly, this also explains why I was getting errors when using subscripts on 'JSONDictionaryType':

> type 'JSONDictionaryType' has no subscript members

JSONDictionaryType is type-aliased to Dictionary but again I was missing the Foundation library that extends the basic type by making it conform to 'SequenceType', which is a prerequisite for subscripting.