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

Kitura 0.13.6 doesn't build in Xcode #472

Closed
michalkalinowski- opened this issue May 16, 2016 · 17 comments
Closed

Kitura 0.13.6 doesn't build in Xcode #472

michalkalinowski- opened this issue May 16, 2016 · 17 comments

Comments

@michalkalinowski-
Copy link
Contributor

Hello,

Bringing this issue to a wider audience. Originally reported in Kitura-net:
Issue #28

Building Kitura 0.13.6 using swift build works ok. However when building from Xcode following error is returned when linking Kitura-net:
ld: library not found for -lCHttpParser for architecture x86_64

Xcode: 7.3.1 (7D1014)
Toolchain: Swift Development Snapshot 2016-05-03 (a)
I have previously installed and force-linked curl with
brew install curl && brew link curl --force

@aquarchitect
Copy link

aquarchitect commented May 16, 2016

I had the similar issue: #463; and followed this to get it resolved: #459.

@shmuelk
Copy link
Collaborator

shmuelk commented May 16, 2016

@michalkalinowski- There is no need to force link curl. Usually the problem is solved by deleting .build and Packages, rebuilding the application, and then doing a swift build -X to create the XCode project. There may have been some stuff remaining from older builds of the application.

In general when one wants to upgrade versions of dependencies with Swift Package Manager, one must delete the Packages directory.

@michalkalinowski-
Copy link
Contributor Author

michalkalinowski- commented May 16, 2016

I did one more test:

  1. brew remove curl to use curl shipped with osx
  2. I cloned a fresh copy of Kitura
  3. swift build -X
  4. opened project in Xcode
  5. Built

I get the same linker error.
I don't see how configuration of my machine can have any effect on this error. Could anyone test the same steps?
If other people reproduce the same error it would mean Kitura-net needs to be fixed to work with Xcode with Development Snapshot 2016-05-03

in #463 adding ${SRCROOT}/.build/debug to library search patchs seemed to solve the problem. Any ideas why suddenly this needs to be added while it was not necessary when using previous versions of toolchain?

@shmuelk
Copy link
Collaborator

shmuelk commented May 16, 2016

@michalkalinowski- I appear to have been mistaken above. I can build KituraSample using XCode. I can't build Kitura using XCode.

I'm trying to understand what if any differences exist between the generated XCode projects.

@shmuelk
Copy link
Collaborator

shmuelk commented May 16, 2016

What's funny with error, is that if one looks at the log, one sees that CHttpParser.dylib was built correctly and placed into the XCode build directory, which is not BTW ${SRCROOT}/.build/debug.

Having said that the link of Kitura-net fails, even though the link seems to include the CHttpParser.dynlib file.

@michalkalinowski-
Copy link
Contributor Author

Kitura-Sample depends on Kitura-0.12 -> Kitura-net-0.12
When I build the latest Kitura it resolves Kitura-net-0.13.5

@aquarchitect
Copy link

@michalkalinowski- I believe it had something to do with SPM bug: https://bugs.swift.org/browse/SR-1444 (still being unresolved), particularly w/ the 05-03 snapshot. I got a weird error when using the Snapshot 05-03 for an iOS experiment (which wasn't happened in the 04-25).

@shmuelk
Copy link
Collaborator

shmuelk commented May 16, 2016

@michalkalinowski- Which Kitura-Sample did you take? The one in the develop branch prereqs 0.13.X of Kitura.... In fact the Kitura-Sample in master shouldn't even run of 05/03 drop of Swift.

@shmuelk
Copy link
Collaborator

shmuelk commented May 16, 2016

@aquarchitect The issue with Kitura-TemplateEngine was solved in Kitura issue #459. If one is using the develop branch of Kitura et. al (i.e. 0.13.x) then the fix should be there.

@michalkalinowski-
Copy link
Contributor Author

michalkalinowski- commented May 18, 2016

I spent a little while yesterday trying to build different tags of Kitura-net with no luck. They all fail with the linking problem that makes me think it may be an issue with Xcode 7.3.1

I'll try to install 7.3 and try to build again this evening

@shmuelk I just had a look at Kitura-Sample Package.swift to understand your results, didn't try to build myself.

@michalkalinowski-
Copy link
Contributor Author

I did some more testing. The issue doesn't lie within Xcode, it's the DEVELOPMENT-SNAPSHOT-2016-05-03-a toolchain:

I'm able to build Kitura-net in Xcode 7.3.1 using DEVELOPMENT-SNAPSHOT-2016-05-03-a if I generate Kitura-net.xcodeproj file using DEVELOPMENT-SNAPSHOT-2016-04-25-a toolchain. It means DEVELOPMENT-SNAPSHOT-2016-05-03-a changes the way xcodeproj file is generated. I will run a diff between the two to understand what has changed.

For now steps to reproduce my findings:

  • git clone https://github.com/IBM-Swift/Kitura-net.git
  • swiftenv local DEVELOPMENT-SNAPSHOT-2016-04-25-a
  • swift build -X
  • open Kitura-net.xcodeproj
  • change toolchain in Xcode to DEVELOPMENT-SNAPSHOT-2016-05-03-a
  • build -> success

Repeat the same steps but generate Kitura-net.xcodeproj with DEVELOPMENT-SNAPSHOT-2016-05-03-a and the build will fail

@michalkalinowski-
Copy link
Contributor Author

Ok, I've narrowed the problem down to CHttpParser package

  • create a new test project
  • add whatever dependency (Kitura-sys) for example
  • swift build -X with DEVELOPMENT-SNAPSHOT-2016-05-03-a
  • open in XCode and build --> success
  • add CHttpParser to Package.swift
  • swift build -X
  • try to build in Xcode --> linker error

@kweinmeister
Copy link
Contributor

This is a known issue we started seeing in 5/3. I don't believe there is a linker issue via CLI, only in Xcode. Please try the workaround in Step 2 in my recent blog post about contributing to Kitura.

@michalkalinowski-
Copy link
Contributor Author

you're right, issue is only in Xcode. I'm aware of the workaround, but I'm trying to find a root cause of this error.

@michalkalinowski-
Copy link
Contributor Author

michalkalinowski- commented May 20, 2016

Found it!

New Kitura fix:

  • clone Kitura, swift build -X, open in Xcode, build and you get well known linker error
  • cd ~/Library/Developer/Xcode/DerivedData/Kitura<something>/Build/Products/Debug
  • cp CHttpParser.dylib libCHttpParser.dylib
    Voila, it builds!

It looks like they changed structure of project.pbxproj file, one of the changes is naming of frameworks (used to be lib[nameOfFramework] and now they removed lib)

Now for some strange reason, in case of CHttpParser which is just a modulemap and c files Xcode still looks under an old name. I can not explain that any further, but I'd say it's a bug with Xcode.

Image of Yaktocat

@kweinmeister
Copy link
Contributor

Great work figuring that out @michalkalinowski!! Has any bug been filed yet for this issue?

@dfirsht
Copy link
Contributor

dfirsht commented Jun 1, 2016

Closing this issue since a workaround for CHttpParser has been documented on the wiki. If you have a fix for the Xcode project generation, you should open a bug at bugs.swift.org or submit a PR against the Swift Package Manger.

@dfirsht dfirsht closed this as completed Jun 1, 2016
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

5 participants