Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API documentation not generated in Xcode 8.1 #822

Closed
dcilia opened this issue Oct 29, 2016 · 60 comments
Closed

API documentation not generated in Xcode 8.1 #822

dcilia opened this issue Oct 29, 2016 · 60 comments
Milestone

Comments

@dcilia
Copy link

dcilia commented Oct 29, 2016

Hi all,

There seems to be an issue with Kitura and Xcode 8.1. Trying to access any Kitura framework classes or functions has an Xcode act like the framework doesn't exist.

  1. Autocomplete functionality is gone
  2. Command-clicking into a Kitura class to see the header instead goes nowhere (blank screen).
  3. Copy and pasting the Getting Started code compiles fine.
  4. Running an instance of the server and putting a breakpoint - any Kitura related variables are not able to be inspected or anything.

Steps to Reproduce:

  1. Follow the Getting Started guide
  2. generate a .xcodeproj by running $ swift package generate-xcodeproj
  3. open xcode project
  4. try editing main.swift and observe Kitura not able to be autocompleted and not able to view the headers in the framework.

If someone can be so kind as to try and reproduce what I am seeing...

Cheers

@youming-lin
Copy link
Collaborator

@dcilia Are you able to build your project via Xcode? Typically from my experience I have to build the project in Xcode before autocomplete of third-party packages shows up.

@dcilia
Copy link
Author

dcilia commented Oct 30, 2016

@youming-lin yes, able to build, however, only Helium-Logger (from the Getting Started) will autocomplete and show up. Kitura doesn't. Just want to confirm that its not my specific MacBook or Xcode 8.1 app..

@siavashalipour
Copy link

@dcilia Confirmed. I am having the same issue with Kitura using Xcode8.1

@youming-lin
Copy link
Collaborator

@dcilia @siavashalipour I am able to see function documentations of Kitura API by Option + Left Click in Xcode 8.1. Are you saying that such tooltip popups do not show up on your setup?

I am also able to CMD + Left Click on, say, the Kitura.run() function to jump to its file definition.

xcode 8 1

@siavashalipour
Copy link

That is weird still getting nothing.
screen shot 2016-10-31 at 1 47 00 pm

@dcilia
Copy link
Author

dcilia commented Oct 31, 2016

@youming-lin @siavashalipour

Same for me as above. I am running macOS 10.12.1 (16B2657)

@siavashalipour
Copy link

@youming-lin @dcilia
I am running 10.12.1 (16B2555)

@collinhundley
Copy link

Same issue here. Even when pulling from the SWIFT-3.0.1 branch.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 1, 2016

Hm. Maybe there is a difference in the way the project was generated between XCode 8 and XCode 8.1?

@collinhundley
Copy link

I believe so - I've noticed that 8.1 (SPM 3.0.1) has been generating Xcode projects with all dependencies + sources under the Sources group, instead of generating a seperate Dependencies group. Might have something to do with it - I wonder if this is a known issue?

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 1, 2016

I just did a test, I took Kitura-Sample, built it fresh, ran swift package generate-xcodeproj, and built the project in XCode. I was able to use the ALT key to see the Kitura API documentation as well as Control-Space to get auto completion to work.

I then installed XCode 8.1. First renamed the KituraSample.xcodeproj to KituraSample-1.xcodeproj and then ran swift package generate-xcodeproj, and built the project in XCode 8.1. The Kitura types are unknown, there is no API documentation and no auto-completion.

Puzzling.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 1, 2016

Another thing to point out.

I added a simple statement to my code let a = "S". On A, I can neither pull up API documentation, nor does auto-completion work. This is more and more sounding like an XCOde 8.1 problem.

I seem to have somehow messed up with that test. The simple statement above works quite well.

@collinhundley
Copy link

@shmuelk did you test this in a file where Kitura is imported? I'm getting autocompletion in most places, but I lose it in files where I talk to Kitura. Especially in RouterHandler blocks.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 1, 2016

This is getting stranger. Auto-completion and API documentation works for LoggerAPI, HeliumLogger, Socket (BlueSocket), SwiftyJSON, and KituraTemplateEngine. It seems to fail for Kitura and KituraNet.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 1, 2016

@collinhundley The problem inside RouterHandler blocks is that XCode somehow doesn't know what Kitura.Router is. This is kind of strange, because if one command clicks on Kitura, XCoe shows the correct source file.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 1, 2016

This is getting weirder by the minute. If I go inside Kitura.swift, suddenly auto-completion and displaying API documentation start working. The same is true, if I edit a file of KituraNet.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 1, 2016

This problem occurs in XCode 8.2 beta as well.

@collinhundley
Copy link

I had assumed it was an incompatibility with the Kitura master branch (Swift 3.0) so I tried pulling down from SWIFT-3.0.1. Still nothing.

Not sure about you guys, but I've been getting a lot of hangs in Xcode between 8.0 and 8.1.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 1, 2016

That's hangs in XCode while editing or while running Kitura based stuff?

@collinhundley
Copy link

While editing. I get beach balls every few mins and have to force quit the Xcode. I don't know if Kitura is source of the problem or if it's something else entirely.

@dcilia
Copy link
Author

dcilia commented Nov 1, 2016

Thanks for all the feedback everyone - I still haven't gotten around the issue.

@youming-lin
Copy link
Collaborator

youming-lin commented Nov 1, 2016

I'm seeing the issue now, albeit inconsistently. Encountered this issue (unable to autocomplete KituraNet APIs) when working in KituraNet tests. In other places I'm still able to get autocomplete for Kitura APIs, however.

@collinhundley
Copy link

@youming-lin it's possible that you've got old indexes of Kitura still floating around. I bet running a Clean and deleting DerivedData would give you the same problem.

@nick3389
Copy link

nick3389 commented Nov 6, 2016

Same problem here for XCode 8.1. No autocompletion in Kitura framework...

@jacobvanorder
Copy link
Contributor

Just to throw my hat in, I'm seeing the same thing. Did the normal clean build folders, delete derived data followed by Xcode & computer restart dance. Nothing.

Tried Xcode 8, 8.1, 8.2b. Swift 3.0, 3.1 toolchain. All of these on Sierra fail to complete or see linked documentation on Router Handlers and much of the Kitura code base.

@ianpartridge
Copy link
Collaborator

We are stuck on this one... Does anyone have any idea how we can investigate further?

@dcilia
Copy link
Author

dcilia commented Nov 7, 2016

@ianpartridge I don't have the full context of how the project is structured, but I would recreate a new a project with Xcode 8.1 and slowly add the classes in until you get the issue to reproduce? I think if that is successful, we would have a precise rdar to file with Apple (assuming its a bug with Xcode).

@collinhundley
Copy link

collinhundley commented Nov 8, 2016

@ianpartridge I'm fairly certain that the autocomplete issues are a result of SPM changes, not necessarily Swift or Xcode changes.

You might have noticed that swift package generate-xcodeproj now generates a single Sources bin containing all source files, including the current package and all dependencies. The Dependencies bin that used to be generated is now gone. Is this a feature or a bug? I don't know.

I just pulled up a Kitura project that was generated pre-3.0.1, and the autocompletion works fine. Note that I'm opening it in Xcode 8.1, but the .xcodeproj was generated with SPM 3.0. The exact same code opened in a SPM 3.0.1-generated project loses autocompletion. So, something must be up with SPM 3.0.1

@dcilia
Copy link
Author

dcilia commented Nov 9, 2016

Confirmed that it might be an issue with Swift Package Manager. I installed Xcode 8.0 and ran $ xcrun swift package generate-xcodeproj , opened with Xcode 8.0 and everything works.

Make sure you $ sudo xcode-select --switch {path to Xcode} first.

@jacobvanorder
Copy link
Contributor

@dcilia using an existing project, I deleted the .xcodeproj and .build folder. Regenerated using Xcode 8 version of SPM. Did the normal derived data/clean build folders dance. Indexing is finished and it still chokes.

Did I miss anything in my purge?

@collinhundley
Copy link

collinhundley commented Nov 16, 2016

@tomandersen it looks like they merged a fix - have you been able to test it with the latest snapshot/preview?

@tomandersen
Copy link

I tried with a toolchain swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a.xctoolchain

Instructions from
https://github.com/apple/swift-package-manager

But got this error. Looks like
Apple Swift version 3.0-dev (LLVM 2c114f612d, Clang cbfd5fe3ec, Swift 80febcb973)
Target: x86_64-apple-macosx10.9
iMac:Kitura-Credentials-Sample tandersen$ swift package generate-xcodeproj
Can't parse Package.swift manifest file because it contains invalid format. Fix Package.swift file format and try again (error: system(arguments: ["/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a.xctoolchain/usr/bin/swiftc", "--driver-mode=swift", "-I", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a.xctoolchain/usr/lib/swift/pm", "-L", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a.xctoolchain/usr/lib/swift/pm", "-lPackageDescription", "-target", "x86_64-apple-macosx10.10", "/Users/tandersen/Desktop/Kitura-Credentials-Sample/Package.swift", "-fileno", "3"], posix_spawn error: No such file or directory (2), ["/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a.xctoolchain/usr/bin/swiftc", "--driver-mode=swift", "-I", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a.xctoolchain/usr/lib/swift/pm", "-L", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-11-12-a.xctoolchain/usr/lib/swift/pm", "-lPackageDescription", "-target", "x86_64-apple-macosx10.10", "/Users/tandersen/Desktop/Kitura-Credentials-Sample/Package.swift", "-fileno", "3"])).

@collinhundley
Copy link

collinhundley commented Nov 16, 2016

I installed swift-DEVELOPMENT-SNAPSHOT-2016-11-15-a and tested it out.

The project structure is fixed (Dependencies bin is back), but still no autocompletion, documentation or debugging...

@collinhundley
Copy link

collinhundley commented Nov 16, 2016

Continuing to dig deeper...

I think I've determined that the root of the problem lies somewhere in Kitura-netpackage. After running some tests, it looks like Kitura-net and all packages depending on it are losing SourceKit/debugging support. This includes Kitura, Kitura-CORS, Kitura-Request, etc - but not independent modules like Kitura-TemplateEngine and BlueCryptor.

I'm inclined to point fingers at the C libs, because I'm having a very similar issue with a personal project that uses libxml2. I'll update with more info if I find any.

@collinhundley
Copy link

Ok guys, I think I've figured it out.

My hunch about the C libs was right, and the problem appears to be CHTTPParser, which is used in Kitura-net (and cascades down to Kitura and several other packages).

If you open up an Xcode project that imports Kitura-net and navigate to HTTPParser.swift inside the Kitura-net package, you'll likely see an error at the top of the file: Could not build Objective-C module 'CHTTPParser'. This tells us that Xcode is having trouble reading the C lib.

To test it out, I removed the CHTTPParser dependency from Kitura-net and commented out all code that was using it. And voila - all documentation, autocompletion and debugging came back to my project.

So, now we know what the problem is - but how do we fix it? I don't know why Xcode can't read the C lib but I've been having the same problem with libxml2 in another project.

@ianpartridge you recently made changes to CHTTPParser - any ideas?

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 16, 2016

We haven't touched CHTTPParser in quite a while.

However, I'm in the process of making CHTTPParser a separate target within Kitura-net. I'm testing now what that does to the issues here.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 16, 2016

Doesn't seem to help any.

@collinhundley
Copy link

@shmuelk what's different about CHTTPParser vs the other C libs? Like I mentioned before, I've found the same problem with LibXML2.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 16, 2016

I don't know. I also don't see the error about CHTTPParser once I click Build in XCode. I double checked XCode is taking the HTTPParser source from the correct place (from with KituraNet in my case).

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 16, 2016

CHTTPParser isn't a "System Library" project as CCurl is for instance.

@tomandersen
Copy link

I have a solution that works as a hack on the module.modulemap file in CHTTPParser

I comment out the umbrella line, and add in hard wired header paths for the two headers...

`
module CHTTPParser {
/*umbrella "/Users/tandersen/Desktop/Kitura-Credentials-Sample/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include" */

header "/Users/tandersen/Desktop/Kitura-Credentials-Sample/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include/http_parser.h"

header "/Users/tandersen/Desktop/Kitura-Credentials-Sample/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include/utils.h"

link "CHTTPParser"
export *

}
`

This is done straight in Xcode 8.1, just change that file and hit run. Looks like it will need changing when you move the project, use github, or have lunch. So its a workaround, but it made us happy as we can now debug

@collinhundley
Copy link

@shmuelk Oh yeah, I just realized CHTTPParser isn't using a module map. Since it isn't a compiled C lib and we're providing the source files directly, how is Swift handling it? I was under the impression that Swift couldn't compile C yet.

@tomandersen are you using an older version of CHTTPParser? Ian Partridge removed the module map back in August.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 16, 2016

This is interesting. We don't have a modulemap file in CHTTPParser. Someone is generating it poorly.

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 16, 2016

@tomandersen You are a genius. I have added a module.modulemap file and all is fixed. This will get fixed tomorrow morning Israel/European time as part of #843

@collinhundley
Copy link

@shmuelk so why did @ianpartridge take it out in the first place? Either way, glad it's finally figured out!

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 16, 2016

I think the modulemap was incorrect it caused problems in XCode, if I remember correctly. Things were ok on XCode 8.0. It would seem that someone changed the way the generated modulemap was built.

@shmuelk shmuelk modified the milestones: 1.2.0, 1.2.1 Nov 16, 2016
@tomandersen
Copy link

I'm an end user kind of coder, we are getting started on a new web app, have Xcode 8.1 installed and then git clone on Kitura-CredentialsSample and or the Kitura-Sample , then run, put break point at some route handler, and its broken until I do that hack above.

@ianpartridge
Copy link
Collaborator

We took it out because when it was there, users had to add $SRCROOT/.build/debug to the Library Search Paths for the KituraNet and Kitura targets in Xcode, otherwise they couldn't run Kitura inside Xcode. When we switched to allowing SPM to supply the modulemap, that requirement went away, which was a nice simplification.

@shmuelk with your latest fix, are we still able to run Kitura inside Xcode OK?

@shmuelk
Copy link
Collaborator

shmuelk commented Nov 17, 2016

Fixed in Kitura 1.2.0. Just released.

@HelloFillip
Copy link
Contributor

Unsure if this is related, but it seems like the only related change I can see. I moved from 1.1.2 to 1.2.0 and the result is:

Wildcat:Naamio siilime$ swift build
Cloning https://github.com/IBM-Swift/Kitura.git
HEAD is now at 072b853 Regenerated the API documentation
Resolved version: 1.2.0
Cloning https://github.com/IBM-Swift/Kitura-net.git
HEAD is now at 01cfbc0 Merge pull request #145 from IBM-Swift/issue_877
Resolved version: 1.2.1
Cloning https://github.com/IBM-Swift/LoggerAPI.git
HEAD is now at c64ce64 Merge pull request #16 from IBM-Swift/issue_832
Resolved version: 1.1.0
Cloning https://github.com/IBM-Swift/BlueSocket.git
HEAD is now at d97739b Update Travis build badge.  Was using the wrong one.
Resolved version: 0.12.2
Cloning https://github.com/IBM-Swift/CCurl.git
HEAD is now at 3cfb752 Add header callback helper function (#9)
Resolved version: 0.2.3
Cloning https://github.com/IBM-Swift/BlueSSLService.git
HEAD is now at 5a3c1e8 Update Travis build badge.  Was using the wrong one.
Resolved version: 0.12.4
Cloning https://github.com/IBM-Swift/SwiftyJSON.git
HEAD is now at 64b0910 Merge pull request #27 from IBM-Swift/issue_846
Resolved version: 15.0.1
Cloning https://github.com/IBM-Swift/Kitura-TemplateEngine.git
HEAD is now at 4fe7829 Support Swift 3.0.1 (#9)
Resolved version: 1.1.0
Cloning https://github.com/IBM-Swift/HeliumLogger.git
HEAD is now at c974057 Update to Swift 3.0.1 (#35)
Resolved version: 1.1.0
Cloning https://github.com/IBM-Swift/Kitura-MustacheTemplateEngine.git
HEAD is now at 98988c3 Update to Swift 3.0 (#14)
Resolved version: 1.1.0
Cloning https://github.com/IBM-Swift/GRMustache.swift.git
HEAD is now at 56a5d86 Merge pull request #3 from IBM-Swift/issue_832
Resolved version: 1.4.0
Cloning https://github.com/IBM-Swift/Bridging.git
HEAD is now at 79ef2a7 Merge pull request #7 from IBM-Swift/issue_832
Resolved version: 1.1.0
Compile Swift Module 'Socket' (3 sources)
Compile Swift Module 'LoggerAPI' (1 sources)
Compile Swift Module 'SwiftyJSON' (2 sources)
Compile Swift Module 'Bridging' (4 sources)
Compile Swift Module 'KituraTemplateEngine' (1 sources)
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"
             ^
~/workspace/.build/debug/CHTTPParser.build/module.modulemap:2:14: error: umbrella directory '~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include' not found
    umbrella "~/workspace/Packages/CHTTPParser-0.3.0/Sources/CHTTPParser/include"

@youming-lin
Copy link
Collaborator

@siilime Can you share some details about your project setup? Have you tried clearing the .build folder, or, one step further, deleting Packages folder and reloading all dependencies?

@HelloFillip
Copy link
Contributor

@youming-lin Deleted the Packages folder, but I missed the .build folder. Good reminder; thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests