Xcode mach-o linker error when archiving project with test targets - xcode

I'm getting mach-o linker errors pointing to missing files in my test targets when I try to create an archive, I can build and run my app on both on the simulator and device without any problems though. I've tried looking at the bundle loader and test host configurations for the test targets, and both look fine. What else could cause this?

In my statution, i solve this issue to change Bit Code Enabled from Build Settings. if you use 3.party framework in your project and these framework is not supported bit code for compression in release time. You must change Bit Code Enabled flag from YES to NO.
i hope this will help someone.

Not the exact solution, but I realized that I don't want or need my unit tests to run during archived builds. If anyone else is having this problem try checking your scheme's build settings to make sure your test targets are not being built when you build for archiving.
Select your scheme -> Edit Scheme -> Build and uncheck Archive for your test targets.

Related

failed to emit precompiled header

Good Afternoon
I am trying to implement googles heatmaps into my map based project.
In this particular project, I get the following errors when trying to build.
failed to emit precompiled header '/Users/zachwilcox/Library/Developer/Xcode/DerivedData/OddJobs-gbnkfettubuccoheinzfovrqefub/Build/Intermediates.noindex/PrecompiledHeaders/OddJobs-Bridging-Header-swift_3WGH9SNI96Z2-clang_16JN3VASQHE4C.pch' for bridging header '/Users/zachwilcox/Desktop/OddJobs/OddJobs-Bridging-Header.h'
and a follow up that says
'Google-Maps-iOS-Utils/GMUHeatmapTileLayer.h' file not found
I'm not sure why this is happening because I created an entirely new project and did the same implementation and it worked perfectly. But when I run it on my existing project I get these two errors.
I have been researching this problem for a while now and I can't figure out what the problem is. I have the Bridging header set to the .h file.
I have tried most steps that individuals have tried to give with their answers but for some reason, it's not working for my project. Thank you in advance. When reading googles installation guide, it said that all I needed to add was one bridging header file which is the code you see in the image below. When researching it, I have seen that I needed to add a .m file as well however I still get the same error when I do. again, in my dummy project, I don't have the .m file just everything you see below and everything compiles.
There are chances you have 'Find Implicit Dependencies" turned off for the selected Scheme. If you have updated/installed pods and try to build the project, it will more likely fail if this option is unchecked for the selected Scheme.
From Apple's Document:
Parallelize Build – This option allows Xcode to speed up total build time by building targets that do not depend on each other at the same time. This is a time-saver on projects with many smaller dependencies that can easily be run in parallel.
Find Implicit Dependencies – This is a very powerful option that allows Xcode to resolve what targets need to be built for the primary target of the scheme to be built successfully. However, this does come with some sharp edges that you have to be aware of.
Situation: You link a library against your application target and create an implicit dependency to that library’s target.
Scenario 1: “Find Implicit Dependencies” is enabled.
Result: The library will get built prior to building the application target. The application target will then link against the library and build successfully.
Scenario 2: “Find Implicit Dependencies” is disabled.
Result: The library will not get built prior to building the application target. The application target fail to build.
Fix: To ensure that the second scenario does not happen, you must add the necessary targets into the targets list and order them correctly.
If your project includes pod then you've to set the pod configuration for the test project too..
Select Root Project in File inspector -> Project Name -> Info -> Configurations
Set configuration for your test project same like your main project

Xcode cannot run using the selected device after upgrade to Xcode 5.0

I upgraded to xcode 5.0 today. I then pressed play to run my project in the iOS simulator. This initially worked. Then I decided that I wanted to run the profiler. When I did that, I got the message:
Xcode cannot run using the selected device.
Choose a destination with a supported architecture in order to run on this device.
I looked at a couple past posts on this problem and decided to do a Clean and Build. Now I can no longer run in the profiler or the simulator. I consistently get the message:
Xcode cannot run using the selected device.
Choose a destination with a supported architecture in order to run on this device.
How can I resolve this?
Here are various settings:
My Deployment Target is 6.1
I have also tried changing the deployment target to 7.0, but that did not work either
It appears that the problem is not related to the architecture in the build settings as the error might suggest. Rather, I found that the problem seems to be related to the Build Options Compiler for C/C++/Objective C. I was using a gcc compiler (com.apple.compilers.llvmgcc42) and Xcode 5 has marked this as unsupported.
If I change the compiler to apple's default Apple LLVM 5.0, the project builds and it can now run in the simulator. The downside is that I have a lot of compiler warnings from code related to cocos2D v1.0 source code. But, at least I have a way forward.
Please follow below step
1>Go to Project Build setting
2>Change compiler for c/c++/objective c as Default compiler(Apple LLVM 5.0) (see in below image)
I had to change compiler for Default compiler (Apple LLVM 5.0) at two places:
Build Settings > Build Options > Compiler for C/C++/Objective-C (change to LLVM)
Build Rules > Files *.mc using GCC (change to LLVM)
Hard to find because code compiles even if Build Rules point to an undefined compiler.
After inspecting all the build settings for 15 minutes, this worked for me (Xcode 5.0.2):
Quit and restart Xcode
Check that the Executable File (also known as CFBundleExecutable) in the Info.plist file is set to ${EXECUTABLE_NAME} as opposed to any hardcoded value. This will ensure that even if you change your project name or target name or scheme name, that it still works.
This issue often occurs after duplicating targets on older projects.
Set the following in your Info.plist for the target:
Bundle Name = ${PRODUCT_NAME}
Bundle Display Name = ${PRODUCT_NAME}
Executable file = ${EXECUTABLE_NAME}
Build and run with these settings, after a successful build they can be changed to anything you want.
This works for me: "Quit and restart Xcode". I recently updated something and the testing device on Xcode said: 'iDevice' not iPhone or iPod. So I restarted then my iPhone came back to the target list.
I had this error when I changed the value of the "Bundle name"-key in the Target Properties. Changing it back to "%{PRODUCT_NAME}" solved the problem for me.

How can I get Xcode to Compile my code instead of doing Build AST?

I just converted a Framework project from Xcode 3 to Xcode 4. I've been building this project for years under every version of Xcode and Project Builder.
For some reason, Xcode 4 runs Build AST on all of my classes rather than Compile, which doesn't actually build the framework executable. On digging into it I found that this passes the -fsyntax-only flag to clang which tells it to stop after producing an Abstract Syntax Tree for each class. I have another Framework that builds fine in Xcode 4, and I've compared the build settings without uncovering anything that looks like it would cause this.
Does anyone have an idea what would make Xcode want to perform the Build AST action rather than Compile? And more to the point, how to turn that behavior off?
Thanks for any ideas...
Okay, I found that in my case I had a custom Build Rule for '*.i' files in my project. The clang build process apparently produces .i files (along with several others) as an intermediate product, so this rule was interfering and stopping it from completing all stages of the build. Removing the custom Build Rule allowed everything to build normally.

cocoa:Make sure your targets all specify SDKs that are supported by this version of Xcode

The scheme 'PrintingWebView' contains no buildables that can be built for the SDKs supported by the run destination My Mac 64-bit. Make sure your targets all specify SDKs that are supported by this version of Xcode.
I've met with this problem.
In my case, the following steps can solve it:
your project -> target -> Build Setting
Modify following items: 1.Base SDK ; 2.Architectures ; 3.iOS Deployment Target.
And then clean and build the application.
Try this simple one:
Target
'---> General
'---> Deployment Info
'---> Deployment Target
'---> Choose Version (Better lower version)
Above answer is right. I was doing one silly mistake, my application was specifically for iPad, and i was mistakenly trying to build on iPhone simulator, and got this error. Make sure, to deploy on relevant device as well.

Do I have to do something to get OCunit tests to compile out of box with XCode 4?

I just installed XCode 4 today (using Apple mac app store), and I created a new Mac OS application, and tried to switch to test mode,and build the test skeleton code it generated for me. It failed here:
In mytests.h:
#import <SenTestingKit/SenTestingKit.h>
The error is:
file://..mytests.h: error: Lexical or Preprocessor Issue: 'SenTestingKit/SenTestingKit.h' file not found
Now, when I use locate from the terminal to find SenTestingKit.h, I notice it exists under the /Developer-old/Library/Frameworks folder (which is what XCode 4 installer renamed my /Developer folder to). There is no new /Developer/Library/Frameworks. And I can't seem to find SenTestingKit.framework on my disk, other than the developer-old one.
What's up? It seems SenTestingKit.framework is not shipped with XCode 4.
Update:
Furthermore, When I copy my old SenTestingKit framework from XCode 3 into /Developer/Library/Frameworks, it sort of builds, but it doesn't work the way I would expect. The dummy test is designed to just fail, but when I "run test", I just get the normal cocoa app document window opening, and no indication that my test has failed (as I intend it to do).
This is pretty bad. I can't get a Unit test to FAIL. That's not the usual situation for me, you understand.
You may find that the reason for this is because you've installed Xcode 4 into a directory such as /Xcode 4.x/ or similar. The space is causing the problem because the -I paths are "Xcode" and "4.x/Library/Frameworks".
To fix this, what you need to do is select your test target, and under its build settings go and find the Framework Search Path, and put quotes around the two arguments, so you have:
"$(SDKROOT)/Developer/Library/Frameworks" and "$(DEVELOPER_LIBRARY_DIR)/Frameworks"
Then you default tests will compile, link and fail.
You will maybe need to import the framework into your project. Otherwise, the header file won't be recognize.
If you can't see the framework you're looking for, you can adjust the framework look paths in your project's build settings.
When you're building unit tests in the same project as you main code, make sure that XCode 4 didn't automatically connect you mytests.m file into the "Compile Sources" section of your main code.
For example, if you have two targets in our project:
MyProject
MyProjectTests
Check the Build Phases for MyProject to see if XCode added mytests.m into the "Compile Sources" accordion. This will cause your builds to fail because SenTest isn't included in the main project.

Resources