XCTest build errors for test target Xcode 5: - ios

I have set up an XCode 5 iOS 7 project for unit tests.
Of course, setting up the unit tests are taking me so long that I'm trying to keep the faith that it's worth it. Struggling for hours over this error:
ld: building for iOS Simulator, but linking against dylib built for MacOSX file
'/Applications/Xcode5-DP5.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest'
for architecture i386
Any ideas on how to solve?

Check your Framework Search Paths in your test target settings. These can be corrupted when adding the XCTest Framework.
Adding XCTest to one of my projects prepended a "/" to the paths causing them to not find the correct version.

None of the above answers worked for me. I did find an answer here in a comment left by Tim Macfarlane.
For linker errors looking for a class in your app...
set the “Symbols Hidden by Default” build setting to “NO” in your app
target. This makes all your app classes available to your test target
automatically...
So, that means:
Project Navigator > Select your project
Targets > Select your App (not Tests)
Build Settings > Search for "Symbols Hidden By Default"
"Symbols Hidden By Default" > Change it from "YES" to "NO"

I had the same issue; the problem (for me, at least) was that the FRAMEWORKS_SEARCH_PATHS build setting listed the SDK frameworks folder after the main developer frameworks folder.
The frameworks included with Xcode have three separate builds: one for OS X, one for iOS (device), and a third for the iOS Simulator. The OS X build is in the main developer folder, with the other two being under their respective platform folders. The rub here is that if you don't specify to search the SDK folders first (which are within the platform folders), Xcode (or more correctly, the linker) will find the OS X build first and produce the error you see.
The solution is simple, put:
FRAMEWORK_SEARCH_PATHS = $(SDKROOT)/Developer/Library/Frameworks $(inherited)
in your build settings. If you're putting build settings in the project file (I don't recommend it, but that's another question for another day), it's just named "Framework search paths."
NOTE: Sometimes Xcode's a little slow to catch on; you'll probably need to delete your build folder (better than just a clean) for this to take effect.

Have the same problem after converting tests from SenTestCase to XCTestCase. Reverting framework dirs fixed issue:
"$(SDKROOT)/Developer/Library/Frameworks" (non-recursive)
"$(DEVELOPER_LIBRARY_DIR)/Frameworks" (non-recursive)

So, for me, what I was missing after trying everything else in this post, was:
Other Linker Flags:
-framework XCTest
I'm currently using Xcode 6.0 (with the iOS 8 SDK) so I'm surprised that the "Edit > Refactor > Convert to XCTest..." option doesn't add this automatically.

I was facing problem while adding sentestingkit framework in xcode 5 . These settings worked for resolving linker problem.

I had this problem upon adding another file for tests.
If you do this with (CMD + N) be sure to only target
the Test Bundle (ie. 'AppNameTests').
I guess only these .xctest bundles have access to the
XCTest Framework.

I had the same issue after renaming my Target name and moving things around. It turned out that my tests were part of my Main Target. Make sure that you all your test files belong only to your test target.
Just select a .m file, make sure you have the right pane open.

I had the same problem when tried to build XCTTest-based unit tests with pre-7.0 SDK. When I chose 7.0 as my Base SDK then that kind of link error disappeared.

Had a the same issue but ended up with a slightly different solution.
select XCTest.framework and make sure that only your test folder is checked under Target Membership.

Make sure that the Search Framework Path (FRAMEWORK_SEARCH_PATHS) for the YourProjectTests target includes the path $(SDKROOT)/Developer/Library/Frameworks, and that this one is listed before $(inherited).
In my case, both paths were present, but $(inherited) was the first one.
Credit goes to https://stackoverflow.com/users/181947/brian-clear on Apple Mach-O linker (id) warning : building for MacOSX, but linking against dylib built for iOS

Related

Swift Compiler Error: use of undeclared type with framework

I'm importing a newer version of a custom framework LCCommLibrary that creates the LCConnection class and I'm absolutely perplexed why this will build but not archive after trying multiple things.
Making sure the targets are added (4 apps, 1 Test)
Cleaning and Restarting the Project
This does builds and runs to my iOS devices, but none of the targets will Archive.
Archive usually uses the Release build configuration while building/running on the device uses the Debug build configuration, this is the hint that you have an issue there.
I would say in your case you can to go into the target's build settings, then look at Other Linker Flags, Runpath Search Paths and Library Search Paths, expand them to show the Debug and Release configurations and then ensure you have the same settings for both of them, you'll most probably find something missing in release in one of those.
Finally found the issue. The culprit was framework that was included was a debug version of the framework. This causes Archive Schemes to throw this error since the archive uses the Release as the default.
The resolution was to open the LCCommLibrary Project separately, change the Framework Target's Run Scheme to Release, Run and Build, Locate the target framework, import and embed that back into main project file, and archive as usual.

Why do I get this warning when building an iOS application (Swift)?

This is the warning:
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks'
How can I fix the problem (if any)?
This is a common error when converting a older project to Swift 2.x in Xcode 7 (though you might see it in other conversions, too). Specifically, I frequently see this error in the tests target when opening old projects:
This is often a result of incorrect value in the "Framework Search Paths" of the tests target:
If you remove the string in that "Framework Search Paths" for the appropriate target, that error will go away. For some reason, Xcode doesn't generally introduce this error in the main target, but only the tests target.
--
As an aside, when opening up an old project, it's good practice to select the target and then choosing "Validate Settings..." from the "Editor" menu. A lot of cryptic error messages will be resolved when you do that.
Go to Project Target->build Phase Check is there any red mark in file.
Check The copy Bundle Resource ,compile Source everything ,if you are upgraded to xcode 7 ,then check the path if there is no red mark .
if you are using any third party library please give the path for that.
That search path is available in build setting in project target..
Hope this will helps you :)

Warning message in existing project after upgrade to Xcode7

I have just recently upgraded to Xcode 7 and now I get this warning:
ld: warning: directory not found for option '-F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks'
I researched different forums and everybody with similar issue recommends to remove paths from build settings but I can't find any paths there resembling iPhone simulators....
I had the same issue, here are the steps that worked for me
open your project
got to TARGETS
select youAppNameTests
select Build Settings
Framework Search Paths
Delete every thing from Debug and Release fields
clean project
Hope it will work for you too
The problem has to do with the test target. Delete your test target. (Copy the code out to some other program if there is any.) Quit Xcode and clean out the Derived Data folder. Now open your project again, and the problem will be gone. If necessary, now make a new test target.

Apple LLVM 6.0 Error: clang failed with exit code -1

I created my app on my MacBook Air and kept working with it there which was fine. Then I started working with a colleague who used another Mac (of course). Anyway, we share our Xcode project via Dropbox (we are just switching to BitBucket, don't worry ;) ), when he tried to open the project on his Mac there was a Apple LLVM 6.0 Error with the following error while on my computer the same project runs perfectly:
clang: error: no such file or directory: '/Users/linus/Dropbox/Apps/My App/Projekt/My App/SlideMenu/SlideMenu-Prefix.pch'
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
The last lines of the error seem most important to me which is why I listed them here.
I do know this question was asked several times now but there was never a useful answer which worked for me. I tried to disable the Foundation Assertions as it said in another answer on this topic but that did not work. Also I restarted & even reinstalled Xcode and all files are existing, none should be missing.
I am running Xcode 6.0.1 and Mac OS X 10.10. I hope someone can answer this, I'm kind of desperate now...
Hey I just ran into the same problem. Basically I deleted my tests target. I found this:
Errors When Compiling iOS 8, Xcode 6.0.1
Which basically says that:
Click on the name of your project on the list of files/folders on the
left in Xcode (at the very top of the list). Look at the "Targets"
section on the left-hand side of the window to the right. Likely,
there's two listed with the second being a "test" item. Right-click on
that item and select "delete". Then try to run the project again. See
screenshot below for a visual cue.
And a picture to help you out:
Hope this helps!
EDIT: Also in the tests target, I actually found that I didn't necessarily need to delete it, there was a broken path, just fixing it makes it all work again.
Make new file: ⌘cmd+N
iOS/Mac > Other > PCH File > YourProject-Prefix.pch.
Project > Build Settings > Search: "Prefix Header".
Under "Apple LLVM 6.0" you will get the Prefix Header key
Type in: "YourProjectName/YourProject-Prefix.pch"
Clean project: ⌘cmd+⇧shift+K
Build project: ⌘cmd+B
Solved this by going to my project settings and changing the deployment target. The deployment target was originally at 7.0. When i changed it from iOS 8.0 -> 9.1 it works fine and there is no error.
Hope that helps :)
You do not need to delete the overall build settings. Just change the Library Search Paths, here are the steps:
Click on your project name (very top of the navigator)
Click on your project target
Click the tab Build Settings
Search for LIBRARY_SEARCH_PATHS
Change its value to $(inherited) flag.
Here you go!
Or else you can always remove the build setting at all! Cheers!
One of the simple things I did I went into "Build Options" and changed the property for Enable Bitcode from yes to no
This fixed my issue.
Screenshot of Settings
clang can't locate your precompiled header file. Have you checked whether there is a file named SlideMenu-Prefix.pch in /Users/linus/Dropbox/Apps/My App/Projekt/My App/ ? The path to the precompiled header file is specified by the "Prefix Header" build setting for your target.
Try,
In Xcode project settings,
Targets-> Tests section-> Build Settings->Linking remove all linkig
OR Remove Tests Section as a whole.
Build again and Its done!!

iOS framework project breakpoints not working

I've created an iOS framework project using the famous (and excellent) iOS Universal Framework Xcode template.
But now I've encountered an annoying problem that I can't seem to fix which is that I have an iOS application project that references the framework project and when I run that and have breakpoints set in the framework they don't get it. It seems GDB doesn't have the debug symbols for the framework.
I've made sure that debug symbols are not stripped from the framework and the type is set to "DWARF with dSYM file".
Anyone have any ideas what might be wrong and how to fix it?
My setup:
Xcode 4.2.1
iOS SDK 5.0
I ran into this issue while linking a dynamic framework to a test application in Xcode 7. I was able to avoid the error by ensuring the following in the build settings of my dynamic framework:
"Generate Debug Symbol" - 'Yes'
"Strip Debug Symbols During Copy" - 'No'
Several things comes to my mind regarding your problem. Give them a try and see which ones work for you:
Make sure to have the "Other Linker Flags" on the "Linking" section of the framework's "Build" Info.
Make sure that you have the framework's built in the correct configuration (ie, if you compiled the framework's in Release and are using it with your project set to Debug you might get issues)
Make sure you added the correct framework .a file to your project (actually two issues here: you can have added the Release version - so no debug symbols in there - AND you have to make sure that your projec is not pointing to some old build version)
Check that both the framework's and your project have the "Level of Debug Symbols" on the "Code Generation" section of the "Build" Info set to "All Symbols [full, -gstabs+ -fno-eliminate-unused-debug-symbols]"
If all alse fails try to empty the XCode caches and remove the framework reference from your project. Then clean and rebuild the framework (all configs: device-debug, device-release, simulator-debug, simulator-release, ...) and add it again to you project. Clean and rebuild your project and cross your fingers... :-)
I have also experienced this issue. One way that I have been able to work around this by merging both projects into a single workspace.
Instructions on how to do this can be found at http://developer.apple.com/library/ios/#recipes/xcode_help-structure_navigator/articles/adding_a_project_to_a_workspace.html.
NOTE: I have also experienced a bug adding projects to workspaces where there appears to be no files in the recently added project to the workspace. I have found this is easily remedied by restarting Xcode after all of the projects have been added to the workspace.

Resources