xcode4: Linker error: Directory not found for option - macos

I'm getting this error for my profile build (debug build was OK).
{Directory not found for option '-L../../../Mac/Profile/lib [full path of that directory]
Library not found for -lMyLib}
When I check the path, the directory exists and the lib file libMyLib.a exists as well.
My library search path for the Profile build includes that directory $(SRCROOT)/../../../Mac/Profile/lib. I also made sure that the library was built under profile setting.
This only happens with profile build.
I'd really love to have some help although it may well be a no-brainer question.
Thank you!
EDIT: Found the solution myself
Solved the problem: In my linker path, there were two directory entries. The second one was surrounded by double quotes while the first one wasn't. Xcode4 seems to have concatenated them into a single directory entry and apparently that was garbage. After I removed the quotation marks, the linker error was gone.

Go to "Get Info" on the target. Click the "Build Settings" tab (i'm using Xcode4), and scroll down to "Search Paths", Where You delete all the values in "Library Search Paths".

There are two errors that people seem to have confused
If it is a "directory not found for option '-L/..."
That means it's a Library Error, and you might want to try:
Click on your project (targets)
Click on Build Settings
Under Library Search Paths, delete the paths
If it is a "directory not found for option '-F/..."
That means it's a Framework Error, and you might want to try:
Click on your project (targets)
Click on Build Settings
Under Framework Search Paths, delete the paths
This might happen when you move referenced files around or change the project folder name.

It was similar as above in the Library Search Paths. I found that one of my paths was missing quotes around it...
// Old path
$(PROJECT_DIR)/Google Analytics
// New path
"$(PROJECT_DIR)/Google Analytics"

I came across this error in seemingly a completely different scenario from those answers above. Hopefully some people will do what I did and find this useful even if it is a rare occurence.
I managed to get this error after having just added a new viewController to my project. As normal I added a tableview and constrained it then added and linked the delegate and datasource. I also created a property.
The weird thing that I then noticed was that as soon as I finished creating the property it was immediately linked, as if I had linked it, but before I linked it. When I clicked on the xib file and checked the links it wasn't in fact linked to the table view.
(This link appeared automatically without me needing to create it myself)
I don't know why this happened. I deleted the file and remade it with the same name but it just happened again. Giving me this error above.
The way I solved it was to create a new file, different name, and added and created the links in a different order checking at each step that this hadn't occurred. After doing this no linked created themselves and it worked.
TL DR: If you are getting this error and have recently added new view controller then check if deleting it works and if so they remake it being careful about any automatic links.

Related

Swift - `.framework` file is not generated

So I just followed this very short tutorial on how to create a framework with Swift.
At one point, the author of the article does this:
This leads him to this:
When I try to do the same, nothing happens though (Finder is never opened). So I thought I could just manually navigate to the project's folder to find the .framework file. But it seems, that such a file is simply never generated:
And even after searching for SortedList.framework in Spotlight, nothing is found.
A noteworthy detail is also, that in Xcode, the 'Products' are shown in red:
Why is the .framework file not generating?
The framework is being generated, but it is located within Xcode's DerivedData directory where your project is built, not the directory where your framework's source files are located.
Your target's path is likely not correct, which is why the product's name appears in red, and Finder can't open a window to that directory.
The location for the framework should be ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework, which (for the Debug configuration) would expand to:
~/Library/Developer/Xcode/DerivedData/SortedList-<random suffix>/Build/Products/Debug-iphoneos/SortedList.framework`
Update:
If you select the framework product, then look in the Utilities -> File Inspector pane, you should see that its name is SortedList.framework, its type is Framework, and its location is Relative to Build Products.
The full path shown below that should automatically correspond to the DerivedData location for the framework.
Here's an example of what a framework's File Location pane would look like.
I can't comment so I'm writing this here to build upon PetahChristian's excellent answer.
I had the same issue, my folder was listed in Xcode as:
/Users/jack/Library/Developer/Xcode/DerivedData/PDFManipulator-ggvfnlbpcgwblwdnvsnxweqnuvgc/Build/Products/Debug-iphoneos/PDFManipulatorTests.xctest
But in reality, it exists in:
/Users/jack/Library/Developer/Xcode/DerivedData/PDFManipulator-ggvfnlbpcgwblwdnvsnxweqnuvgc/Build/Products/Debug-iphonesimulator/PDFManipulatorTests.xctest
Notice that the last folder each is slightly different. I can rename reality to make it the same as the Xcode one which fixes the problem.
However, if I rebuild the project again the files are recreated in Debug-iphonesimulator. Not sure how to fix that.

Xcode "Cannot parse contents of Info.plist"

I just hit a brick wall with xCode not wanting to parse my Info.plist file. I've replaced the file several times with older (identical) versions of the file that I had previously backed up, and I'm still getting the same error.
Here is the complete error message:
couldn't parse contents of '/Users/...Info.plist': The data couldn’t be read because it isn’t in the correct format.
I'm clueless on this one. I'm using xCode 5.0.1, Mavericks
This is one of the best way to detect on which line the error is occurring.
Just go the directory where the plist file is present then write this command on terminal->
plutil filename.plist
Another cause of this issue can be from attempting to put URLs (really just slashes etc.) in your app-Info.plist.
Get around it by simply raising the -traditional flag inside of the Info.plist Other Preprocessor Flags option in your project build settings.
I think you have used source-control tools, you can use basic text-edit tool without Xcode to open this plist, command + F to find "<<<<<" or ">>>>>", then you will probably find error string such as:
<<<<<<< .mine
>>>>>>> .r605
select the correct string, and delete the other one, error is resolve!
Looks like replacing the file with a backup, then deleting the derived data for the project in Organizer was the cure. Hope this helps someone else later on.
I personally ruined the file when git merge raised conflicts. .plist is an XML file and git conflict added <<<< and >>>> in there to tag the differences.
Find the .plist file in Finder (in one of your project's folders). Open it in a text editor, find the lines that don't look like proper XML, remove them and be sure to remove the duplicate XML line/node (due to pre and post git recorded changes).
This may also simply happen because you have moved the Info.plist file into a new folder, or removed it from a folder (basically, if its path changed).
Go to Build Settings and search for "Info.plist file". Edit the value. For instance, if you have moved your plist file from the main folder to a subfolder called Resources, you will have to do the following change:
Before:
TargetName/Info.plist
After:
TargetName/Resources/Info.plist
When building for iOS, the Info.plist may be corrupted whenever Default Orientation is set to Auto Rotation. The Info.plist file is created properly on the first build, but subsequent builds results in...
<key>UIInterfaceOrientation</key>
<string></string>
</string>
... at this point Xcode fails to build the project.
I was having the same error, and realized the issue was that I had a URL (e.g. http://example.com/something) as a value in my Info.plist, and I just switched on pre-processing for it (without the -traditional flag). Apparently Xcode will treat the // as a comment marker, and omit the rest of the line.
A work-around I found is to embrace the pre-processor, like so:
http:/${}/example.com/something, which breaks up the // by putting an empty string substation in the middle so it doesn't look like a comment to Xcode, but after pre-processing it's back to a normal URL.
This error comes whenever Xcode preprocessor is not able to parse the info.plist file.
So to find out the error in the specific line do the following steps :
Open your project.xcworkspace in Xcode
Go to the project's navigator
Inside your project click on the info file, if an error exists then it will popup the dialog with the line number where the error exists
You can see the below image of the popup dialog for reference, which is in my case was showing the error on line 35
Hope this will help you or somebody else. Thanks!
Happy Coding :-)

Multiple errors ocurred while copying files - but, can I see what they are?

There were around 200 files I had to delete in my Xcode project (and yeah, they were deleted properly), and now I have to copy 200+ files are supposedly replace the ones I just deleted.
I keep getting "Multiple errors occurred while copying files". The Xcode window doesn't show the newly-added files, but if I explore the project folder using the Finder, I can see that the files were indeed added - well, there most likely was a certain file that could not be copied and thus caused the error. Problem is, I have no idea which one nor why.
Now then, is it possible to get Xcode to tell me what the problem is rather than telling me there is one?
Edit: Okay, I did discover that some of the new files shared the same name as some files that were not listed in Xcode, which explains the error. However, I am still interested in knowing whether there is a way to know that the "Multiple errors" actually are whenever Xcode says t his.
When Xcode finds a duplicate file, it generates this error, and then it fails to add references for the files that it did manage to copy.
Rather than deleting files from the finder and starting over, you can do this:
Open the Finder for your project, where your source files are located
Command-click the ones for which your references are missing (and if you click others, it won't really matter)
Drag them into Xcode. When the confirmation dialog comes up, unset the "Copy items into destination group's folder (if needed)" checkbox. This will tell Xcode to make references only.
I deleted the files from finder and then added again the files via Xcode, that worked for me.
This error sometimes occurs when the code is not merged properly. The missing files will not be available in Xcode but once you open the finder containing this project, you will be able to spot the missing file.
The simplest way to add these missing files back to the project is:
1) In your Xcode, navigate to Build Phases Tab.
2) Under Compile Sources, tap on '+' to add back the missing file.
Sometimes the missing files will be greyed out in the build phases, just tap on '-' and add them back.
For me this is worked. I tried to add files which are already in my bundle. So make sure you are not adding files which are already added. I hope it helps someone.

ios file corruption

Ok so some how 2 of my classes had ended up in a weird directory
projectname>projectname.xcodeproj>
In my infinite wisdom I tried to transfer these to the proper directory were the rest of my classes are (projectname directory)
However now I cant compile due to it not being able to find certain files
what file can I edit to check to see where it's looking for these files?
UPDATE 1
in response to the first answer I have tried readding the files. which has netted me some different errors. Specifically that Cameleon-Prefix.pch, no matter how many times I re add it always shows red.
A quick fix for this is to delete the files from Xcode, but in the confirmation dialog, choose to just release the references. Then add the files again (from the File menu Add Files… item).
If you want to see where Xcode expects to find the files, choose the file in the navigator pane on the left, and set up the right hand pane with this configuration.
And from there you can click on the detail disclosure buttons to see even more.
Edited to add
Make sure this is the same file pointed to in your build settings:
Do a similar search for pch to make sure the same thing goes with the pch file

Change XCode default from relative to XCode folder?

I'm really really tired of other users having project errors because XCode's default class reference type is "relative to XCode folder." I know you can change it to "Relative to Enclosing Group," which is what our project is, but anytime someone creates a new classfile and forgets to change the reference type afterwards (frequently) or adds and file and forgets to change the reference type (also frequently), users who update from SVN see red file errors, even though it exists in the correct folder - just because the xcodeproj file links to it stupidly.
Is there any way to change the default? I've been looking through the preferences and can't find anything. It seems there must be ways to make XCode work better for situations other than single-user projects. I am incredibly unimpressed with its source control management, and I'm hoping maybe that's because I haven't been able to find some options. Thanks for the help.
My approach to this is to map my groups to the source file hierarchy and make sure that everything is initially set up as "Relative to Enclosing Group". In this case Xcode seems to do the right thing when you add more files or folders to the hierarchy, i.e. it maintains the "Relative to Enclosing Group" setting wherever it can.
For more info try asking on the xcode-users mailing list.
I struggled with this some time as well, yet the answer is simple:
Don't store your projects in the developer folder. Inside the developer folder everything defaults to relative to XCode Folder, while outside it's to enclosing group.
Hope it helps

Resources