Giter VIP home page Giter VIP logo

Comments (30)

michaelgwelch avatar michaelgwelch commented on May 17, 2024

This is more of a general question so I asked at Stackoverflow as well. http://stackoverflow.com/questions/26691653/how-do-i-link-to-a-3rd-party-swift-framework (I can't even figure out how to consume my own frameworks.)

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

First, can I get you to run a clean (⌘+⇧+⌥+K). Then rebuild

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Sure. I did the following. Pulled the latest code as of just a few minutes ago. Followed your key combination to clean build folders.

I then rebuilt. I then paid closer attention to the "schemas" available. I'm referring to the list of "targets" in the menubar just to the right of the run and stop buttons. I currently see 8 listed.

Two of the entries are named "swiftz (swiftz project)". I can successfully build and test these.
Two of the entries are named "swiftz_core (swiftz_core project)". I can successfully build but not test these.
Two of the entries are named "swiftz_core_ios (swiftz_core project)". These run and test successfully.
Two of the entries are named "swiftz_ios (swiftz_project)". These build. There apparently are no tests.

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

It's weird you would say that. I've got four buildable schemes and all of them test just fine. In fact, even Travis can see them and is giving us the all clear. What happens when you add a copy files phase to the test schemes, set the path to "frameworks", and add the appropriate swiftz_core?

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Ok. Let me address your first comment first. Obviously something is wrong with my working directory.
Running git status shows no local changes but I'm going to do a git clean -fxd and/or clone a fresh copy of the repository.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Well, git clean made a change. Now I see 5 schemes. 4 of them look like yellow lunch boxes, but 1 is a white lego (swiftz_iosTests somehow is listed separate from swiftz_ios).

Ok, going to pull a fresh clone. (I'm using XCode Version 6.1 (6A1052d) by the way).

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Success! I cloned a fresh copy. Still had issues running the tests for swiftz_core. Said it couldn't load the swiftz_coreTests bundle at /Users/mgwelch/Library/Developer/Xcode/DerivedData/swiftz-dfchxmsrsusopsgocnqvrawwpzyp/Build/Products/Debug/swiftz_coreTests.xctest/Contents/MacOS/

I went to that location. Deleted the binary that was there. Rebuilt. And then the tests passed.

This doesn't make any sense to me since but I'm now building and successfully running all tests.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Now I just have the final question of which of these frameworks do I need and how do I add them to another workspace and/or project?

In a .Net language using Visual Studio, I'd just right click the project and say "Add Reference".

In C/C++ (which I've not used a ton but have used them) I'd add the library to a linker setting and make sure the library was in my link path.

I really have no clue what to do for frameworks. Apple makes it look like it's as simple as drag/drop or click a + key and add the framework. However, the linker never finds the library I've added. Perhaps I need to make sure the library is copied to the right location when I drag/drop and then make sure some link path is up to date?

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

If you want to use it in an Application, you'll need to do the following:

  • Add the appropriate Swiftz.xcodeproj as a subproject by dragging it into the file tree just below your own project.
  • Select your application's entry in the file tree
  • Select the "Build Phases" tab
  • Expand "Target Dependencies". Click the +. In the resulting dialog, select the appropriate Swiftz or Core
  • Click the small plus just above "Target Dependencies"; Select "New Copy Files Phase"
  • Change its path to point to "frameworks"
  • Expand the new phase, click the +. Select the appropriate Swiftz or Core.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Just a quick question about dragging the project into the file tree. It looks like you did this in the swiftz project as well, as swiftz_core is embedded under the swiftz project. And the whole swiftz_core project is shown embedded under swiftz.You can expand it and see all the files.

When I drag swiftz into my project, I just get an icon for the project, but none of the files under the project are there. I can't expand the project and navigate. Is this a problem? Can I ignore that?

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

Did you drag in the workspace or the xcodeproj? The workspace is where we keep both projects as a convenience, but each individual xcodeproj is what you should probably be using here.

If you did, it's because Xcode will not allow you to have the same project open in more than one window. Submodules included. sigh . Close both windows, then reopen your project.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

I dragged the xcodeproj. I tried it from Finder. I tried it from one XCode window to another.
screenshot

(This is not how you consume objective-c frameworks right? This is just a "stop-gap" solution until Apple solidifies their swift runtime and adds true support for reusing binary form of swift frameworks? Because this seems to not work too well.)

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Ok, you do not want to have swiftz open in XCode when you do the drag/drop. That was my problem. I'll move onto the next step now. (Fortunately, I eventually got an error telling me that it couldn't open up swiftz project because it was open already.)

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Finally, in the copy file phase, the default destination is Resources. Is that correct or should I select Frameworks.

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

Frameworks, please. The dyld will thank me later.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Well, thanks for all your help. I'm getting closer but I'm getting a dyld error anyway.

dyld: Library not loaded: @rpath/libswiftAppKit.dylib
  Referenced from: /Users/mgwelch/Library/Developer/Xcode/DerivedData/playwithswifts-attigdsrimbroebdxizhevdsxpls/Build/Products/Debug/swiftz_core.framework/Versions/A/swiftz_core
  Reason: image not found

Of course, when I look at that location the framework is there. I'm less than enthused with the amount of polish Apple has put into XCode to support Swift. This doesn't seem like a released version of a product, yet.

Not sure why it's looking there anyway. Shouldn't it be looking wherever we copied them to in the copy files phase?

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

Go under your project's "Build Settings" tab, search for "Embedded content contains"

You should see "Embedded content contains Swift Code" No Change it to Yes

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

I believe up above when you told me how to add to my project, you skipped a step. I need to add the appropriate framework to the Link phase correct?

I've done that. Still dyld error.

Now, I have an extra bonus problem.Now whenever I have swiftz_core framework in the copy phase I get the following build error (which wasn't happening 10 minutes ago).

Unable to run command 'PBXCp swiftz_core.framework' - this target might include its own product.

Well, I truly appreciate all of your help. I'm going to call it a night.

I sure wish Apple had more support for this stuff. This doesn't seem "ready for prime time".

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

Okay. I've come at this fresh with a sample project of my own. Here's the revised steps I'm considering submitting to a new README:

Adding Swiftz to a Project

  1. Clone swiftz into the directory of your choice.
  2. Drag and drop swiftz.xcodeproj into your application's Xcode project or workspace.
  3. Add swiftz to the "Target Dependencies" phase of your project.
  4. Under the Build Phases tab, add swiftz to the "Link Binary with Libraries" phase.
    5a. Add swiftz.framework to the "Copy Files" phase.
    • If you do not have a "Copy Files phase", select the + at the top left and add one.
    • Make sure the Destination field is set to Frameworks.
      5b. Add swiftz_core.framework to the "Copy Files" phase.
  5. Under "Other Code Signing Flags" in the Build Settings tab, make sure --deep is set.

With these instructions I can get any number of applications up and running from Xcode's default templates. If you'd like I can send you a working project of mine to see if it isn't just on your end.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Ok, maybe I need to try reinstalling XCode. Still get a linker error, but I looked more closely at it. I thought it was saying it couldn't find your framework. But it's a swift runtime framework it can't find:

dyld: Library not loaded: @rpath/libswiftAppKit.dylib

Something like this question might be related: http://stackoverflow.com/questions/24972359/unable-to-load-swift-runtime-library-image-not-found

I'm going to look into the settings mentioned there.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

I can link it to a Cocoa App (really wanted a command line app) but decided to play with that.

I ran all the default tests in the default app template. They run.

Then I add the following line to a test:

var x = List<Int>.Nil;

or

var x:List<Int> = [1,2,3]

and set a breakpoint. The tests break at that line. But if I try to step into them or step over, or just run the tests without breakpoints - the tests just hang.

This is actually the same result I got when I tried creating my own recursive enum implementation of List a few days back. It really seems like my installation of XCode is sick. I think I'll bite the bullet, uninstall, clean the best I can, and reinstall.

Thanks for all of your help.

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

You can't bundle frameworks and dylibs with command line tools. You need a static library for that, and our hands are tied on that front by the language.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

I give up. Still can't get it to work. I could try to troubleshoot by figure out where it's looking for rpath but I'm not familiar enough with the build tools to even know how to get it to spit out what it thinks @rpath is.

I reinstalled XCode, created a default projected, made all the changes you said and still dylib can't find the swift library listed above. Feel free to close this issue, I think you did about all you can on this one.

I'll just play around with swiftz in your test projects or try it from a playground.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Wait, I just re-read what you typed. You can't bundle frameworks and dylibs with command line projects?

Now that would be a useful thing for XCode to tell you upon adding a framework to your link phase when you are in a command line project.

Ok, then I guess I'm just left to figure out why whenever I write (or you write) a recursive enum list List, the runtime just hangs when trying to construct one in a test.

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

We may be spinning forever in the ArrayLiteralConvertible constructor. Gimme a sec to check.

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

Welp, that was the weirdest debugging session ever. You're absolutely right about it being the runtime that hangs. I'm filing a radar I have filed a radar for that problem (rdar://18903483), in the meantime #120 should do right by you.

from swiftz.

michaelgwelch avatar michaelgwelch commented on May 17, 2024

Cool! I just opened up a stack overflow question on this and was going to try to debug. I would have never guessed to box the first parameter of Cons. Wow!

Thanks for filing the radar.

http://stackoverflow.com/questions/26792577/why-does-this-recursive-swift-enum-hang-xcode/26792757#26792757

I assume this broke "recently" as I'm sure this code worked when it was first written?

What tool would you use to debug this? Instruments?

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

I wasn't around when it was first written, but that sounds about right. Recursive enums were always trouble, but I've never seen this before.

from swiftz.

 avatar commented on May 17, 2024

@CodaFi I think this issue can be closed now. All of my issues were resolved or explained.

  1. Can't create command line tool (yet) using a 3rd party framework.
  2. The hanging of List

Thanks

from swiftz.

CodaFi avatar CodaFi commented on May 17, 2024

Alright, then.

If you have anymore questions, don't hesitate to open another issue.

from swiftz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.