Swift iOS module not being deployed to expected debug directory - ios

I have a module/framework written in Swift, intended to be used on iOS. When I try to include the framework in my app, I first notice some red "not found" hints in the build phases:
But, the project builds fine - the target dependency is found, so there are no compilation issues. It's just the resulting built framework - and sure enough, upon launching, I have a linker error, it can't find the image. Looking at the build log, it's looking here:
/Users/Craig/Projects/Fluffy/build/Debug-iphoneos/
Which makes sense - that's what is defined in the Build Settings for my framework:
But the copy fails, as the source framework doesn't exist:
PBXCp /Users/Craig/projects/Fluffy/build/Debug-iphoneos/Fluffy_iOS.framework /Users/Craig/Library/Developer/Xcode/DerivedData/MyApp-dcjfhcnyzkwzxiejuuxqlsgajreb/Build/Products/Debug-iphoneos/MyApp/Frameworks/Fluffy_iOS.framework
...
error: /Users/Craig/projects/Fluffy/build/Debug-iphoneos/Fluffy_iOS.framework: No such file or directory
However, looking at the build log for my framework, I see that it's actually ending up here:
/Users/Craig/Library/Developer/Xcode/DerivedData/Fluffy-fuuewsvogdkycegheyrsabkiicxc/Build/Products/Debug-iphonesimulator/Fluffy_iOS.framework
I suppose that makes sense - DerivedData has for a while now been the default location for any built products.
And when I take a look at the expected build folder, there's not much, a lot of it is old, and none of it relates to the Debug configuration:
So my questions are: Why is my framework being placed in the DerivedData folder, when it seems to be asking in the Build Settings to be placed in the build folder relative to the project? Are these parameters (per-configuration build products path, etc.) consulted at all?
And, what should I do to reconcile this? How can my application know to look in the right DerivedData folder for the framework, for the right configuration (debug vs. release) in a way that is extensible and will work without me having to manually specify the absolute path to it?

Okay, so I figured out how to work around this. This assumes you have workspace and you have included the framework as a project in the workspace and you are trying to build a product from another project in the workspace which includes the framework.
What you need to do is find out where the framework is being built. It's usually some crazy directory under the DeriveData directory. Go to the Finder and find it for the configuration you just tried to build.
In the product target's General settings, under Embedded Binaries, drag that file into it. This should now place it in the Project Navigator. You should also see it in the Linked Frameworks and Libraries which was underneath Embedded Binaries.
Go to the Project Navigator and select the file and view it under the File Inspector. There, change the Location to Relative to Build Products.
In the target's Build Settings, for Framework Search Paths, add $(BUILT_PRODUCTS_DIR) and make that recursive. Delete the entry that was automatically added when you added the framework. It will be an explicit path which has the DerivedData path in it.
Do a deep clean and delete the DerivedData directory for good measure.
Build.
You should now see the framework turn black and it should work properly.

These are slightly modified steps provided by #Mobile Ben
Assume, you have the following Xcode project structure
-YourWorkspace
--YourFramework project
--YourApp project
step 1. Clear all the targets with Cmd+Shift+K and Cmd+Option+Shift+K (by choosing each of them in the Scheme selector and pressing the hotkey combination)
step 2. Select YourFramework project.
step 3. Choose a simulator and build (Cmd+B) YourFramework framework target
step 4: Choose Generic iOS Device and build (Cmd+B) YourFramework framework target
step 5: Select YourApp project. Press + in Embedded Binaries and choose the framework under YourFramework project
step 6: now locate the just added framework in Project Navigator (on the left). In File Inspector (on the right) select location Relative to build product.
NOTE: I believe the step 6 is required b/c of some bug in Xcode. But, though, not selecting Relative to build product by default might be a deliberate act
UPD#1: Since Xcode 8.0 (8A218a), step 6 is not needed anymore - the IDE sets Relative to Build Products automatically.

In addition to the above answer which works perfectly on Simulator. On device you will get dyld library not found error and a crash.
Here is the solution for that:
In the project that depends on this framework:
Under the build settings: Add a copy files phase and add this framework to the 'Frameworks' folder in copy file phase.

Related

iOS getting stuck at multiple commands found [duplicate]

error: Multiple commands produce '/Users/uesr/Library/Developer/Xcode/DerivedData/OptimalLive-fxatvygbofczeyhjsawtebkimvwx/Build/Products/Debug-iphoneos/OptimalLive.app/Info.plist':
1) Target 'OptimalLive' has copy command from '/Users/uesr/Desktop/workSpace/SEALIVE/SeaLive1.1/OptimalLive/Info.plist' to '/Users/uesr/Library/Developer/Xcode/DerivedData/OptimalLive-fxatvygbofczeyhjsawtebkimvwx/Build/Products/Debug-iphoneos/OptimalLive.app/Info.plist'
2) Target 'OptimalLive' has copy command from '/Users/uesr/Desktop/workSpace/SEALIVE/SeaLive1.1/OptimalLive/Server/Masonry/Info.plist' to '/Users/uesr/Library/Developer/Xcode/DerivedData/OptimalLive-fxatvygbofczeyhjsawtebkimvwx/Build/Products/Debug-iphoneos/OptimalLive.app/Info.plist'
3) Target 'OptimalLive' has process command with input '/Users/uesr/Desktop/workSpace/SEALIVE/SeaLive1.1/OptimalLive/Info.plist'
Running the code in Xcode 9 works, but there is an error in Xcode 10.
The issue might be occurring because of multiple Plist or other files within App-
Solution -> Open target -> Build phases > Copy Bundle Resources and remove info.plist from there.
Note: If you have developed a watch app too then you will have to remove the plist from the watch and watch-extension too.
This answer is deprecated - Xcode 12 has deprecated the Legacy Build System, it will be removed in a further release
I found the solution for this build error, for anybody else having the same issue with Xcode 10 build system, follow the following steps to fix it:
In Xcode, go to File->Project/Workspace settings.
Change the build system to Legacy Build system.
It will resolve the build issue with the new Xcode 10.
If you want to work with the new build system, then you can find the troubleshooting help from this apple Xcode help page.
Go to Xcode -> File ->Workspace Settings.
You will find one pop up like.
Select "Legacy Build System" from Build System tag.
Press on "Done"
Note:- Make sure clear your project with "cmd+shift+alt+k" and "Derived Data"
Build your project it will work charm :)
I was experimenting with Core Data. I built a data model for a simple checklist program and generated the NSManagedObjects. When I compiled the project I got the following error:
error: Multiple commands produce '/Users/myUSerName/Library/Developer/Xcode/DerivedData/myCoreDateExperiment-gzbslaqdwglkzxemijpdqmizgyzc/Build/Intermediates.noindex/ myCoreDateExperiment /Debug-iphonesimulator/ myCoreDateExperiment.build/Objects-normal/x86_64/CheckListItem+CoreDataProperties.o':
1) Target ' myCoreDateExperiment ' (project ' myCoreDateExperiment ') has compile command for Swift source files
2) Target ' myCoreDateExperiment ' (project ' myCoreDateExperiment ') has compile command for Swift source files
The problem was the data model (CheckList.xcdatamodeld in my case) was in the "Compile Sources" list. The project compiled cleanly when I removed it from the list.
Open the project navigator and select the project (very first entry at the top)
Select your build target under Targets in the "Projects and Targets" pane
Select Build Phases option near the top
Expand the "Compile Sources" entry and look for your data model name. Search for "xcdatamodeld" if you have trouble finding it.
Delete the model from the compile list
Make sure the data model is included in the "Copy Bundle Resources" list. Add it if it is missing.
EDIT
As #WilliamT. explains in the comments, you need the xcdatamodeld in the compile list. Instead, go to your entities within the xcdatamodeld file. Select the models that are erroring, expand the left panel, and change the field of "Codegen" to "Manual/None".
This answer is deprecated - XCode 12 has deprecated the Legacy Build System, it will be removed in a further release
Try this as well.
Xcode->File->Project Settings-> Build System -> Legacy Build System.
If you are getting this from the Ditto command creating multiple instances of the same name (NOT the 'copy files' build phase), you may have to change the Product Module Name.
Click on your Target(s) Xcode is complaining about
Click on Build Settings
Search for Product Module Name
Change the name to something unique
We have a watch target and a few notification targets in our app, so I just put things like Extension on the end of the module name.
I found this solution originally here: https://forums.developer.apple.com/thread/103913
If you use CocoaPods you may want to try deintegrate the pods and install again. It works for me.
pod deintegrate
pod install
While checking the build log, I noticed a warning:
note: Using new build system
note: Planning build
note: Constructing build description
Build system information
warning: The Copy Bundle Resources build phase contains this target's Info.plist file '/Users/<redacted>/Repositories/Whitesmith/optimize-ios/Carthage/Checkouts/WSStatusBarNotification/Miscellaneous/Info.plist'. (in target 'JDStatusBarNotification')
So, if that's your case then just go to your target:
Build Phases
Copy Bundle Resource
Remove info.plist.
Read this answer if error message references Core Data files
Synopsis: You may have both automatically-generated and manually-generated Core Data managed object class files.
This answer applies if the first line of the error refers to a Foo+CoreDataProperties.o or Foo+CoreDataClass.o file. Example:
error: Multiple commands produce '/Users/me/Library/Developer/Xcode/DerivedData/MyApp-uebslaqdwgldkjemijpdqmizgyzc/Build/Intermediates.noindex/ MyApp /Debug-iphonesimulator/ MyApp.build/Objects-normal/x86_64/Foo+CoreDataProperties.o':
1) Target ' MyApp ' (project ' MyApp ') has compile command for Swift source files
2) Target ' MyApp ' (project ' MyApp ') has compile command for Swift source files
The root cause can be seen by expanding the Compile Swift Source Files section of the Build Transcript. For example:
<unknown>:0: error: filename "Address+CoreDataClass.swift" used twice: '/Users/myUserName/Projects/Jnky/Foo+CoreDataProperties' and '/Users/jk/myUserName/Developer/Xcode/DerivedData/MyApp-uebslaqdwgldkjemijpdqmizgyzc/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/DerivedSources/CoreDataGenerated/Jnky/Foo+CoreDataProperties.swift'
The first file mentioned there is a source file in your project directory, which someone generated by selecting your data model in the Project Navigator and clicking in the menu Editor > Create Managed Object Subclass. This feature was added in Xcode 7 or so.
The second file is a file of the same name but which is buried in Xcode's DerivedData. This file is generated automatically by Xcode during every build if the data model (.xcdatamodeld) file is included in the target's Compile Sources build phase. This feature was added in Xcode 9 or so. Zero, one or two files are generated for each entity/class, depending on the setting of the Codegen popup. That popup is in the Data Model Inspector when you select an entity while editing your data model…
The settings are:
Manual/None No files are generated
Category/Extension One file, Foo+CoreDataProperties.m or .swift is generated, containing an Objective-C category or Swift extension.
Class Definition That same Category/Extension file is generated, and in addition a Foo+CoreDataClass.m or .swift is generated, containing class declaration and definition.
So you see the problem occurs when a developer (like me) who is accustomed to the older Xcode begins a project in a newer Xcode. We think that we need to use the Create Managed Object Subclass menu item, which we do, to create the files we can see in the Project Navigator while not realizing that our settings in the Codegen popup are causing Xcode to create duplicate files, which Apple "cleverly" does not show in the Project Navigator, because they don't trust developers to read and heed the comment in the header // This file was automatically generated and should not be edited.
Solution 1 - Use the Older Way
You can disable all automatic Codegen for a data model with just one setting:
Open the problem Target's Build Phases (In Project Navigator, select project, then in list of TARGETS which appears, select the problem target, then tab Build Phases).
Expand the Compile Sources entry and find the problem data model (.xcdatamodeld file).
Delete it from the compile list
Ensure the data model is included in the Copy Bundle Resources list.
Solution 2 - Core Data Magic For Beginners
Here, you go all in on the newer way.
Leave your data model as is in that Compile Sources.
In each Entity Inspector in your data model, set Codegen to Class Definition.
In the Project Navigator, delete and trash any Foo+CoreDataClass files, and rename any Foo+CoreDataProperties.m or .swift files to something like Foo+MyProperties.
In each Foo+MyProperties.m or .swift file, if there are properties generated by Xcode, delete these properties because they will be in the hidden files created by Codegen.
With this solution, your class definitions are generated automatically from the data model on each build. You can't even see them. It is Core Data Magic, nice and simple for beginners.
Solution 3 - For Most Real-World Apps
But Solution 2 is no good if you really want to add non-managed properties. (Objective-C does not allow properties to be added in categories, and Swift does not allow stored properties to be added in extensions.) So in most real-world apps, you probably want to go halfway between Solutions 1 and 2…
Leave your data model in the list of Compile Sources
In each Entity Inspector in your data model, set Codegen to Category/Extension.
In the Project Navigator, delete and trash any Foo+CoreDataClass.m or .swift files, and, to reduce future confusion, rename any Foo+CoreDataProperties.m or .swift files to maybe just Foo.m or .swift.
Ensure that each Foo.m or .swift file contains the class definition, to which you can add your own non-managed properties.
(Acknowledgments to the answer by Positron. My answer here explains why Positron's answer (my Solution 1) works, and adds Solution 2 and Solution 3.)
Solution 1 :
Open target ➼ Build phases ➼ Copy Bundle Resources ➼ remove info.plist from there. ➼ you will have to remove the plist from the Extensions too (if any).
Solution 2:
If you use CocoaPods you may want to try deintegrate the pods and install again.
Commands:
1) pod deintegrate
2) pod install
Solution 3:
In Xcode, go to File ➼ Project/Workspace settings.
➼ Change the build system to Legacy Build system.
I had the same problem, I had a one more helper app in main App and copy this in resource. In my case solved as :-
1) Target -> 2)Build Phases 2) Copy File (n items) 3) Remove Copy File.
The Helper app automatically copied in Xcode 10.0.
Try this Its Working :
In Xcode, go to File->Project/Workspace settings.
Change the build system to Legacy Build system.
None of the solutions proposed here worked for me. This was particularly due to CocoaPods. I was previously using Cocoapods 1.3.1. Simply upgrading to 1.5.3 didn't resolve the issue right away.
The steps I followed were:
Delete Podfile.lock
Delete Pods directory
Delete Derived Data & Clean
Exit Xcode
Update CocoaPods to 1.5.3
Run pod install
Open workspace and build
One option which solved my issue is to changing build system to legacy build system. Please follow the following steps in Xcode 10+.
Here I have written a detailed article on the problem & its solution. Xcode Error: Multiple commands produce
In my case PDFGenerator was producing an info.plist file, I just deleted it.
This answer is deprecated - Xcode 12 has deprecated the Legacy Build System, it will be removed in a further release
I'm using Xcode 11.4
Can't build old project
Xcode => File => Project Settings => Build System => Legacy Build System
Before I begin note that my project utilizes Carthage as a dependency manager.
None of the existing answers here resolved my issue. What did resolve the issue for me was the following.
First, I noticed that the build error pointed out one framework in particular. Next I filtered App Target > Build Phases for that framework. I noticed that that framework was present in both "Link Binary With Libraries" and "Embed Frameworks". Noting that none of the frameworks listed under "Embed Frameworks" were ones managed by Carthage I removed the framework in question from "Embed Frameworks". I then re-built my project and everything works fine including the functionality enabled by the framework in question.
This issue arose for me after adding a second part of the Fabric suite of SDKs to the app.
What actually happened was that the GoogleUtilies Framework was added twice to the Pods project
This would have been fine prior to Xcode 10 but Xcode 10 will complain if a file has two actions against it (in this case a copy action).
It's safe to remove the second framework.
there are some reasons that cause this error to be shown.
1- the project name is the same as a dependency that is used on the project
this error may happen when you choose a name for your project that is the same as one of the dependencies that you use on the project for example you cannot choose FirebaseAuth or GoogleSignIn as the project's name if you use them via pod or SPM.
to solve this problem you should change the project name with the following way:
choose the project from project navigator on the left sidebar, change the project name from the file inspector -> Identity and Type -> name from the right sidebar.
after you change it, XCode asks you to change all relative targets and just press rename.
2 - duplicated info.plist on the Copy Bundle resources portion
you may face this error when info.plist is added to Copy Bundle resources unwanted, choose project form project navigator -> choose target -> goto Build Phases tab -> Copy Bundle Resources and if you see info.plist there, remove it by choose info.plist like the following image
3 - pod files do not work well
sometimes you got this error because the dependencies that you use break for unexpected reasons.
1 - Delete Podfile.lock
2 - Delete Pods directory
3 - Delete Derived Data & Clean (you can find this directory from XCode menu -> Preferences... -> Locations -> Derived Data and go to the directory by clicking the arrow icon at the right of the address)
4 - Exit Xcode
5 - Update CocoaPods with [sudo] gem install cocoapods on mac terminal
6 - goto the project directory on the terminal and run pod install
7 - Open workspace and build
5- duplicated Core data
you may face this problem when you use Core data on the project
first I explain coreData codegen types:
**Class Definition: ** Choose Class Definition when you don’t need to edit the properties or functionality of the managed object subclass and properties files that Core Data generates for you.
Category/Extension: Choose Category/Extension to add additional convenience methods or business logic inside your managed object subclass.
Manual/None: Choose Manual/None to edit the properties in your managed object subclass, for example, to alter access modifiers, and to add additional convenience methods or business logic.
Choose the Manual/None and check if a copy of xcmodeldata is exist on CopyBundleRecources, remove it.
Well, in my case:
If you create two file with same name, will trigger this error.
Remove the one you recently added, will solve this problem.
Hope this helps.
I had this problem when I had a file with the same name in two different targets. For some reason one of those files I had part of both targets. So basically I had two files. And both of those files belonged to one target.
It makes sense that a target can only have one file name per target, so just unchecking the target member box for the file that wasn't related to the main target fixed the issue.
So the problem I was having is that I had accidentally included the Info.plist in the project settings -> Build Phases -> Copy Bundle Resources for my target.
Steps:
Go to Xcode File
Click to WorkSpace Settings
Build System Select as Legacy Build System
Here is another working solution : (If you are using custom Pods)
Select "Pods" from sidebar as highlights in screenshot.
Click on Build Phase. Expand "Headers" section. There are 3 options Public, Private, Project
Expand Public and check there are duplicate files. Remove it. DONE!!
Unfortunately none of these answers worked for me... here was the error I was seeing:
"Multiple commands produce '/Users/.../.../.../Frameworks/abcdef.framework"
That command depends on command ...: script phase ""
That command depends on command ...: script phase ""
Adding this line to the Podfile and doing a " Pod Install " was the ONLY thing that worked.
install! 'cocoapods', :disable_input_output_paths => true
I really hope this helps someone. I spent hours trying to fix this and finally got it.
Sometimes I just wish Xcode was as efficient as IntelliJ / Android Studio :(
Goodluck!
My error was:
duplicate output file
'/Users/home/Library/Developer/Xcode/DerivedData/myAppName-fawptgabysjowicvpeqydjniuovo/Build/Products/Debug-iphoneos/myAppName.app/GoogleMaps.bundle'
on task: PhaseScriptExecution [CP] Copy Pods Resources
/Users/home/Library/Developer/Xcode/DerivedData/myAppName-fawptgabysjowicvpeqydjniuovo/Build/Intermediates.noindex/myAppName.build/Debug-iphoneos/myAppName.build/Script-32CCC25BF727B592A1784900.sh
I focused on the problem file being GoogleMaps.bundle and the location of that file being in [CP] Copy Pods Resources, and the fact that it specified it’s a duplicate output file (I highlighted them in black above), it's the 4th step below
First create a copy of your project and make sure you first do the following steps on that copy
1- In the project navigator I went to the blue project icon
2- I choose Build phases
3- Under Build Phases I choose [CP] Copy Pods Resources
4- Under [CP] Copy Pods Resources I went to Output Files and underneath there I found the file that ended with GoogleMaps.bundle. I selected it and pressed the minus sign to delete it. Make sure you go to Output Files and NOT Input Files
5- I did a clean shift+cmmd+k and afterwards when I built the project the error was gone
The odd thing was even though the red error went away the yellow warning was still there but it worked :)
I had bunch of Multiple commands produce warnings - not limited to info.plist duplication in one target. Including localized resources and string files, headers etc.
Solution: remove all duplications in target membership.
Try all this option anyone of this 3 option will work for you, for sure
Option 1: Remove all files from
Target >> Build Phases >> Compile Sources
Target >> Build Phases >> Copy Bundle Resources
Option 2: Change the build system
Xcode->File->Project Settings-> Build System -> Legacy Build System
Option 3: remove and update existing pod
pod cache clean PromisesObjC
pod cache clean PromisesSwift
cd [your_project_dir]
rm -rf Pods/
rm Podfile.lock
pod update
I hope this will help you, Happy coding :-)
Go in Project Build Phase and Remove info.plist from the Compile Sources. It will remove that issue and project will be active again.
It's worth noting that this error can be produced after auto generation of CoreData models where the Codegen is not set to Manual/None.
To correct this in Xcode 10 double click on your xcdatamodeId file and select each of your entities and set Codegen to Manual/None under Class in your Data Model Inspector.

Xcode won't add "Embedded binary" after deleting "DerivedData"

Alternative titles to aid search:
Adding Embedded Binaries fails in Xcode
Xcode won't link framework from separate project
App crashes on device because of missing framework, works in simulator
Overview
After deleting the "DerivedData" folder (or performing a "Product > Clean") in xcode6, I cannot add CocoaTouch frameworks from another project to the "Embedded Binary" section (under General tab).
Or, Xcode hits a linker error because it cannot find a framework that if previously could.
Other symptoms
Clicking on the + under "Embedded Binaries" shows the Framework selector but selecting a framework in different project in the workspace does nothing.
When you add the framework to the Embedded Binaries, there will be a reference added to your project for it. If you select that reference after your steps above, you will probably find that it has an Absolute Path reference to the framework rather than a relative one, which we'd like. Change the location to Relative to Build Products and the reference should always be discoverable if do a "hard" clean or use another computer etc.
I have made a video which describes how best to add a built framework from one project to an app target in another sibling project.
This it the only way i have discovered to restore the embedded binaries, please leave comments if you find some steps are not required.
Prerequisites: Read Daniel Tull's answer.
Remove all framework projects from the workspace
Perform a "clean build" and/or remove the "DerivedData"
Add project back into the workspace
Build the project (possibly optional)
In the General tab of the app target click the + under "Linked Frameworks and Libraries", select the framework.
Build and run in the Simulator (there should be no issues building or running)
Build and run for device (this might cause a crash due to the framework not being correctly linked, ignore this crash)
Click the + under "Embedded Binaries", select the framework. This should add it to the project (possible duplicate under "Linked Frameworks and Libraries")
Repeat for all required frameworks
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
Just to add to #Daniel's answer, if your Location dropdown is greyed out you may have selected the wrong file. Make sure to select the framework that's in your app project (not framework project).

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

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 me to run the iOS app on both iPhone and simulators: The 2 library projects were added as Embedded Binaries (see picture) of the app.
Now, I have XCode 6.1. Recently, I deleted DerivedData folder in ~/Library/Developer/Xcode folder while XCode was running. After that my workspace did not work - the iOS app would fail to compile and I got linker error saying it cannot find the library projects.
I tried to solve it by removing my the 2 libraries from Embedded Binaries of the app project - and I cannot add them back. Clicking + button under Embedded Binaries in project settings displays workspace projects correctly but selecting and adding my library project does not add them to the list of Embedded Binaries. I have solved the linker error by creating new workspace. The app compiles but how it links the libraries is a mystery to me: They are not in listed Embedded Binaries or Linked Frameworks and Libraries not in the Frameworks search path. There appears to be no link between the app and the libraries it needs (and obviously have as it compiles) except that libraries projects are in the same workspace.
Why I cannot add library projects to Embedded Binaries? Is it normal in XCode 6.1 that dependency projects just compile and gets embedded into an app without being listed or linked anywhere?
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:
Remove all framework projects from the workspace
Perform a "clean build" and/or remove the "DerivedData"
Add project back into the workspace
Build the project (possibly optional)
In the General tab of the app target click the + under "Linked Frameworks and Libraries", select the framework.
Build and run in the Simulator (there should be no issues building or running)
Build and run for device (this might cause a crash due to the framework not being correctly linked, ignore this crash)
Click the + under "Embedded Binaries", select the framework. This should add it to the project (possible duplicate under "Linked Frameworks and Libraries")
Repeat for all required frameworks
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
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!
Clean your projects & build your framework first. Thereafter you can embed it.
Here is how I solved the problem:
Build the framwork.
Open the build folder and drag built framework into the app project (so it uses the path to DerivedData).
Add the framework to the list of embedded frameworks.
In the Finder, do a Show Contents on the app's xcodeproj file, then open project.pbxproj in your favorite text editor.
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.
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.
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

.framework product is red no matter what

I'm trying to add this framework to a project. I have followed these instructions to the letter:
Add SocketRocket.xcodeproj as either a subproject of your app or in your workspace.
Add SocketRocket.framework to the link libraries
If you don't have a "copy files" step for Framework, create one
Add SocketRocket.framework to the "copy files" step.
I made sure I had only one instance of xcode open, then dragged the SocketRocket.xcodeproj file into my project. I added the .framework file to the link libraries, created a copy files build phase, then added the .framework to the copy files build phase.
This is the error I get when I try to build:
clang: error: no such file or directory: '/Users/adamhickey/Library/Developer/Xcode/DerivedData/websockettest-fcuhfltporfkitgubwcjukxogzas/Build/Products/Debug-iphonesimulator/SocketRocket/SocketRocket'
It's quite right: that directory does not exist.
In build phases, the SocketRocket.framework is red under Link Binary With Libraries. It's also red in the products folder of the SocketRocket subproject.
I've been googling this error for hours and the majority of the things I've tried have pointed me towards changing the build location in Xcode->preferences-locations. I've tried:
setting it to relative, picking my own, and going to advanced and choosing legacy.
building for a device
build for->archiving
building for release
If I open the SocketRocket.xcodeproj in a separate instance of xcode and try to build it, 3 of the four products are red. The products are: libSocketRocket.a, SRWebSocketTests.octest, TestChat.app, and SocketRocket.framework. The first is white, while the last three are red.
I'm assuming that if I can get the .framework file to build in a separate project, this will solve my overall problem. However, nothing I do seems to have any effect.
Please please please help! I'm using xcode 4.6.
I had a similar problem configuring for libSocketRocket.a.
My workspace contains two projects as siblings: SocketRocket and myProject.
I added SocketRocket as a git submodule.
Christoph's answer works for me so far:
What's the correct way to configure XCode 4 workspaces to build dependencies when needed?
Change libSocketRocket.a location from Relative to Group to Relative to Build Products.
Search for path containing built static library, e.g.:
/Users/myName/xcode-build/myProject-eegkidwlennrekbsinvncwxqybol/Build/Products/Debug-iphoneos/libSocketRocket.a
Then fix path.
In your primary project, in the build phases, create a dependency on that SocketRocket project. You should be seeing the .a show up there as well as in the link phase. If you still cannot get it to work create a small demo project that tries to link it and zip that up and put on DropBox then edit question with location.

Add project dependencies in Xcode

I am working with the AR Drone to develop new application.
I want to establish a dependency between two projects. So when I compile one, I hope Xcode will help compile the another one automatically. I had searched with Google for this question. The solutions found are quite old and not applicable for Xcode 4.
Right now, I have two project, namely, ARDroneEngine.xcodeproj and FreeFlight.xcodeproj.
ARDroneEngine is a library for FreeFlight. Here comes the screenshot.
If I compile FreeFlight with iPhone / iPad simulator, it is fine since the ARDroneEngine is last compiled with the same setting. This is where the question lies. To test my application, I want to compile and run FreeFlight in my iPhone. So when I change the setting to "FreeFlight > xxx's iPhone" and compile, the error occurs: "Apple Mach-O Linker Error".
I think the problem is rooted from the Target Dependencies between two projects.
A quick workaround will be: Compile the ARDroneEngine again with the new Scheme "ARDroneEngine > xxx's iPhone" and launch FreeFlight in Xcode for my iPhone.
But I want a more complete solution with the dependencies between projects. If more information is required to solve the problem, I can always provide new info.
Thanks,
Steven
Xcode's solution to cases like this is to use a Workspace that encompasses both projects: then, when one project has a target that references the build product of another, it automagically works out the dependencies and builds them in order.
Create a new Workspace (File > New > Workspace); name it and save it anywhere you like (though putting it in a parent folder to both project directories might be a good idea).
Add both projects (drag the xcodeproj files from the Finder into the navigator pane, or use File > Add Files).
Expand the Products group of your library project so you can see the (placeholder for the) built library (libARDroneEngine.a).
Select the app project (FreeFlight) in the navigator and its app target in the editor -- you should be looking at the Summary pane for the target (the one with bundle identifier, deployment info, entitlements, and most importantly, the "Linked Frameworks & Libraries" list).
Drag the library (libARDroneEngine.a) from the navigator (where you made it visible in step 3) into the Linked Frameworks & Libraries list.
That's it! Now you can choose the FreeFlight > xxx scheme and it'll automatically build the library project before building the app.
You can probably get a more complete summary of these instructions (with screenshots and all) in the Xcode help for Workspaces.

Resources