Cannot add embedded binaries (other projects) to project dependencies in XCode

后端 未结 6 1318
天命终不由人
天命终不由人 2021-02-05 10:06

I have an XCode workspace created with XCode 6.0.1. It constains 2 (Swift) libraries and one iOS app (Swift) that depends on those 2 libraries. I had stable setup that allowed m

相关标签:
6条回答
  • 2021-02-05 10:46

    Clean your projects & build your framework first. Thereafter you can embed it.

    0 讨论(0)
  • 2021-02-05 10:49

    It's probably because your framework is a separate project and not a separate target. Try watching carefully Session 416: Building a Modern Framework at around minutes 34-36. It will show you how to set it up correctly.

    This makes it a bit confusing if you wanted to share a framework across multiple projects by the way

    0 讨论(0)
  • 2021-02-05 10:52

    This is a summary of my answer to the question Xcode won't add “Embedded binary” after deleting “DerivedData”, see the original question and answer for more context and information:

    1. Remove all framework projects from the workspace
    2. Perform a "clean build" and/or remove the "DerivedData"
    3. Add project back into the workspace
    4. Build the project (possibly optional)
    5. In the General tab of the app target click the + under "Linked Frameworks and Libraries", select the framework.
    6. Build and run in the Simulator (there should be no issues building or running)
    7. Build and run for device (this might cause a crash due to the framework not being correctly linked, ignore this crash)
    8. Click the + under "Embedded Binaries", select the framework. This should add it to the project (possible duplicate under "Linked Frameworks and Libraries")
    9. Repeat for all required frameworks
    10. Once building and running (on device) is confirmed you can remove any duplicate (and/or red) frameworks in the Project Navigator or target General tab
    0 讨论(0)
  • 2021-02-05 10:58

    I have a very similar issue and fixed it just last night. Decided to come back to this thread and offer my workaround, as rjstelling's solution above did not help my case.

    I have a workspace that contains two frameworks and one application. The App was making use of both frameworks happily for a while until I got hit by a mysterious compile eror where it decided that adding a property access to an instance variable called "cube" of a class type found in one of the framework, made access to "_cube" impossible (complaining it was not declared, while it had actually worked previously in a setter method).

    Long story short, after a clean, somehow the workspace/app project lost track of the embedded framework of my iOS 8+ project. Removing the embedded framework was the last straw in that line of failure, causing my project to no longer allow be to select any frameworks for embedding.

    Reverting the project & workspace to an earlier version did not get rid of the voodoo.

    I ended up adding the to-be-embeded framework projects in the main app project (as files) and introduced target dependencies on the frameworks.

    I was then able to re-embed the frameworks and link.

    As for the _cube thing, I had to specify a getter for the property and @synthesize the property to a different name. I dont have an explanation for this one.

    0 讨论(0)
  • 2021-02-05 11:01

    Ok, I ran into the same problem as you. After deleting the derived data, I could not re-link my binaries again. I think the reason is because the derived data is where the binaries are written to and linked against in your project.

    What I did to solve was to select my Framework as my build target. After building it, the Framework target turned from red to black. I can see in your screenshot it is red, meaning it has not been compiled into a binary and written on disk.

    Once I did this, I was able to re-link the Framework to my Project because there was a reference to it on disk. Hope this helps!

    0 讨论(0)
  • 2021-02-05 11:02

    Here is how I solved the problem:

    1. Build the framwork.

    2. Open the build folder and drag built framework into the app project (so it uses the path to DerivedData).

    3. Add the framework to the list of embedded frameworks.

    4. In the Finder, do a Show Contents on the app's xcodeproj file, then open project.pbxproj in your favorite text editor.

    5. Find the line with the long DerivedData path. Change it so there is no name, the path is the framework name, and source tree is BUILT_PRODUCTS_DIR

    Xcode should notice the change and the library in the app project will be black instead of red and will now build and run properly.

    0 讨论(0)
提交回复
热议问题