Cannot load underlying module for XCTest - swift

I'm working in swift on Xcode and by default it creates a test file that references XCTest.
When I set the target membership to my main project it causes this error
Cannot load underlying module for XCTest
If this target membership is not set the tests runs properly and everything works fine.

Double check that the file in question is not in the main target but instead only the test target. Only the test target will have that framework to import.

The main project does not link with the XCUnit framework. You should create a separate testing target for your project, if one does not already exist, and add your test source files to that target.
Select your project in the Project Navigator. This will open the project's settings in the editor.
Click the "+" button at the bottom of the column listing your Targets.
If you are working on an iOS project template, select iOS > Test > iOS Unit Testing Bundle.
If you are working on an OS X project template, select OS X > Test > OS X Unit Testing Bundle.

You've just added your tests file/class into main target and not into test target by mistake. Simple as that.
Solution:
1) Remove test file from "Compile Sources" list on "Build Phases" tab for main target
2) Add same file into "Compile Sources" on "Build Phases" tab for test target
It must resolve the issue

I get this error if I create a macOS dynamic framework target, which links to XCTest.framework (the target is a framework target, not a testing target!).
In this case the problem is solved by adding
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks
to project's "Build Settings / Framework Search Paths".

After lots of troubleshooting and bouncing around Stack Overflow pages such as this one, I managed to find one detail that was not mentioned on the other iOS Unit Test troubleshooting pages.
If your project uses CocoaPods, make sure to include your test target nested inside your main application's target. Your podfile might not include it if you created your test target after running pod init. Your podfile should look something like this:
target 'YourApp' do
target 'YourAppTests' do
inherit! :search_paths
# Pods for testing
end
end
Remember to save your podfile and run pod install after doing so.
Hope it helps!

This maybe a little late but what you have to do is:
Click on File > New > Target > iOS Unit Testing Bundle.
And then add your tests in there. This worked for me. The problem was that I didn't select create unit tests when I created my project.
Hope this helps someone.

While the accepted answer solves this problem for majority of times, there is one more way you can come across this error.
If you have already ensured that:
As pointed out by #pwc #nick-n and others
The ClassTest.swift file for target membership by ensuring that it is only attached to the Testing target.
The ClassTest.swift is not visible under you main app target > Build Sources > Compile Sources
Here is what else you can check:
in your .podspecs file
Ensure that your source_files does not directly or indirectly includes the testing directory.
for example :
s.source_files = ["Classes/**/*.{swift}", "Classes/**/*.{xib}"]
s.exclude_files = ["Classes/Exclude", "Classes/MyPodProjTests/"]
Note that Classes/**/*.{swift} includes everything overriding the fact that the directory MyPodProjTests must be excluded.
Solution:
s.source_files = ["Classes/MyPodProj/**/*.{swift}", "Classes/**/*.{xib}"]
Note:
This is extremely edge case and completely human error but I thought it will be worth point out.

This problem occur two times in your project.
When you Don't Add UnitTestingBundle in your project when create a New Project.
When you install CocoaPods in Your Project sometime not every time.
1:Answer:
Go to the File Click on File.
Then You see First option New Click on it.
After Clicking on it you see Some Option Click on Target.
And then in the Searchbar Search IOS Unit Testing Bundle and Add Problem is solved.
if Compiler can't give you a permission to add this then try Second Method when is given Below.
2. Answer CocoaPod Problem:
Go to the Product Click on the Product.
Click on clean or press cmd+k.
Problem is solved.

Make sure the Target Membership is checked off for all the modules when the test framework is selected. You can view the Target Membership option by selecting View->Utilities->Show File Inspector

In my case, I was making the tests for a private pod, so in the podspec was like:
s.test_spec 'Tests' do |test_spec|
test_spec.source_files = 'Tests/*.swift' end
But in the Podfile I forgot to bring the test specification, as such:
target 'MyApp' do
use_frameworks!
pod 'CoconutLib', '~> 1.0', :testspecs => ['Tests'] end

I did all the above, but still I was not allowed to access the methods I wanted to test. But before I wrote any test case built the project once and then the methods were accessible to test. So do try it and let me know if it solved any ones problem.

I had the same problem and the solution for me was to:
Select my scheme
Edit Scheme...
Then when Scheme configuration window is opened select left tab named "Test" to be redirected here:
Like you can see my UITests are not added here but exist in my project so I had just to tap plus button and select my UITests target like this:
Then tap "Add" button and close configuration view
Finish with a clean of project and try again it should work
And don't forget to verify that too: https://developer.apple.com/library/archive/qa/qa1954/_index.html
Hope this answer will help.
PS: one last think in my Test target in build settings I had to check these property that was not configured correctly:
DEBUG_INFORMATION_FORMAT = dwarf;
ONLY_ACTIVE_ARCH = YES;
VALIDATE_PRODUCT = NO;

Just as #Alfishe mentioned above:
You have to remove the test files from Compiler Sources under Build Phases
As shown below

Check Target Membership of your Test class.

The problem is that Unit Testing Bundle as a target should be created beforehand
[How to add it]

Related

No such module 'IQKeyboardManagerSwift'

New to Xcode (dabble a little). I paid a developer to build an iOS app for me. He sent me the source code and I have opened it in Xcode 13.2.1. I needed to edit the info.plist to include a description why location was required (got this done). When I try to run the build, I get the error 'no such module 'IQKeyboardManagerSwift'. In AppDelegate, I see 'import IQKeyboardManagerSwift --- No such module 'IQKeyboardManagerSwift'. I went to the Podfile directory and ran 'pod install'. Output says:
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 7 dependencies from the Podfile and 8 total pods installed.
I'm still getting the error when trying to run the build. I tried cleaning the build folder and running the build again but still, same error. What am I missing?
I'm not sure why this happens, but one way to solve your issue is to go into your build settings and define the Framework Search Paths to a folder that contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT) and set it to recursive.
Is the codebase completely in Swift?, else you will have to include import in the Bridging header file
If in swift you can try:
Select project name -> Select Build Settings(tab) and search Framework Search Paths double click and set the desired path($(SRCROOT)) to recursive
The missing module handles a number of keyboard behaviors so you don't have to reinvent that wheel. Check out the developer's website and get it for yourself. I've been using it for years. The developer has helped me more than once get past some obstacles.

Library not loaded: #rpath/libswiftMetalKit.dylib in UITests in Xcode10

When running my UITests Target in Xcode10, I now get:
Library not loaded: #rpath/libswiftMetalKit.dylib . <--- (Library varies)
Referenced from: ../MyApp.app/PlugIns/MyAppUITests.xctest/Frameworks/Hero.framework/Hero <-- (Framework varies, all installed with Cocoapods 1.6.0beta1)
Reason: image not found)
My regular target works fine. My Regular target and UITests targets both have "Always Embed Swift Standard Libraries" set to Yes, though I noticed the Pods Project and frameworks have this set to No.
Things I've tried:
Cleaning project, deleting derived data, and rebuilding project
Verifying my code signing is working
Setting "Always Embed Swift Standard Libraries" to Yes on the Pods Project and frameworks.
adding #rpath to the Runpath Search paths for the UI Tests Target
So far nothing has worked. Anyone else encountering this issue or have insight into what might help?
EDIT:
Thanks #matt for pointing me in the direction of the related isue.
I tried importing UIKit and recreating target, both to no avail.
Importing the specific frameworks (i.e. Hero) or the libraries (i.e. MetalKit) in one of my UITest targets allows it to build, but mysteriously my other UITest target will still not build due to libswiftSwiftOnoneSupport (referenced by Alamofire) not building.
Still not sure if this is due to my Cocoapods setup (All my targets including UITest targets import all pods, which I think should be unnecessary but I get missing frameworks for my pods if I don't), but the exact same setup worked fine prior to XCode 10.
What worked for me was the followings:
Copy from your TARGETS from your basic project let say 'sample_app' > Build Phases the section [CP] Embed Pods Frameworks.
Now In the UITest TARGETS, let say 'sample_app_UITests' create a new Run Script and copy everything.
Clean/Build
Setting the workspace setting to Legacy build fixed it for me: File > Workspace Settings > Build System: Legacy Build System

Xcode 8.1 No such module 'Foo' from unit tests [duplicate]

I recently updated to Xcode 7 beta 5. I tried adding a unit test to an earlier project, but I am getting the error message "No such module [myModuleName]" on the #testable import myModuleName line.
I tried
cleaning the project with Option Clean Build Folder
checking that "Enable Testability" (debug) was set to Yes in the Build Options
deleting the tests target and then re-adding the iOS Unit testing bundle
None of this worked for this project (but I have gotten testing to work in another project). Has anyone else had this problem and solved it?
Please check your Module Name that you try to import with #testable import "ModuleName". The module name should be the same on Target->Build Settings-> Product Module Name
The answer that worked for me
The answer was that I had some errors in my project that was making the build fail. (It was just your standard every day bug in the code.) After I fixed the errors and did another clean and build, it worked.
Note that these errors didn't show up at first. To get them to show up:
Comment out your entire Test file that is giving you the "No such module" error.
Try to run your project again.
If there are other errors, they should show up now. Fix them and then uncomment your Test file code. The "No such module" error was gone for me.
In case this doesn't solve the problem for other people, you can also try the following:
Clean the build folder
Open the Product menu, hold down Option, and click "Clean Build Folder..."
Make sure that Enable Testability is set to Yes
In the Project Navigator click your project name. Select Build Settings and scroll down to Build Options. Make sure that Enable Testability is Yes (for debug).
Delete and re-add your Tests target
If you have done the other things my guess is that you probably don't need to do this. But if you do, remember to save any Unit Tests that you have already written.
Click your project name in the Project Navigator. Then select your Tests target. Click the minus (-) button at the bottom to delete it.
Then click the plus (+) button and choose iOS Unit Testing Bundle to add it back again. As you can see, you can also add a UI Testing Bundle in the same way.
A few other ideas
Make sure that all required classes are members of your test target.
Make sure that you have added all the required libraries.
Make sure that the module name is written correctly (see this answer).
Or...
Leave a comment or answer below if you found something else that worked.
Related
How to do a Unit Test in Xcode
Xcode UI Test example
The problem for me was the iOS deployment target of the tests was not set to be the same as the main target. So be sure to check this.
In your test target:
Build Settings -> iOS Deployment Target -> iOS<same as the target you are testing>
So this is how I went about getting my code to work after trying all suggested solutions from prior suggestions.
I set 'Enable testability' to 'YES' in project's Build Settings
I also set 'Defines Module' to 'YES' in my project's Build Settings.
For the regular .swift file(s) within my project, say MyApp, I was going to write test cases for, I have both the main "MyApp" and the
"MyAppUnitTests" Targets checked under Target Membership.
I then selected my unit test file(s), declared the '#testable import
MyApp' at the top, beneath the 'import XCTest', and only checked the
"MyAppUnitTests" under Target membership
And everything worked like charm. Hope this helps.
One gotcha to watch for is that if your module name has a dash character in it - then you will have to refer to it with an underbar instead _. For some reason I suspected this might be an issue and it was indeed my issue.
eg. #testable import Ocean-Swift becomes #testable import Ocean_Swift
Just one other thing, if you do use the #testable syntax be sure to not include your production code in your test target. I've found this will cause inexplicable weirdness.
This sounds to be an error with the build settings of both targets.
You need to ensure that:
ENABLE_TESTABILITY equals Yes for both targets.
The PRODUCT_MODULE_NAME value of the test target should differ from the one of the application.
For those who have scrolled until the last answer and still nothing worked, here is what did it for me after following all other answers advices. I am using Xcode 11:
What caused the issue in my case was that I changed my Product Name
I changed my Product Name in the Build Settings of my main target to "New Name"
I had to re-select the Host Application for my test target
I didn't know that changing the product name would also change the Product Module Name, that is the one used for the module import in my test files. I changed my import as follows:
#testable import New_Name
It worked
I hope it helps
After spending couple of days on this issues finally I make it to work with my project. Problem was in Bridging Header - path in Tests target can't be empty if you are using Bridging Header in your main target
Hope it will save some time for someone.
One other thing to check: If you have an Objective-C project, but are writing unit tests in Swift, make sure the main target uses at least one Swift file!
More info:
I was working on an Objective-C project, but wanted to write unit tests in Swift.
I added a Swift file to the main target to generate the necessary ProjectName-Bridging-Header.h file, wrote my tests and everything was working properly.
Later on I deleted the Swift file because I thought I didn't need it (all of the main target's code is in Objective-C... I was only writing tests in Swift).
I didn't notice a problem until later, after I did a "clean/clean build folder" and the "No Such Module" problem showed up. After some head scratching I added a new blank Swift file and the problem went away.
I've tested it multiple times with/without the Swift file, and it only works with it... so, I'll either need to leave the blank file in the project, convert some Objective-C into Swift, or add some new code to the project written in Swift.
In my case , I had 3 issues.
The first was that I had to specify the import path in :
Target -> Build Settings -> Swift Compiler - Search Paths -> Import Paths
The second was that I was using Pods and I had to import these pods to my tests as well using :
target 'MyAppTests' do
inherit! :complete
end
The third one as that I was using a bridging header in my target , thus I had to specify the bridging header to be the same for the test.
Make sure under the test scheme's build setting, the test target is in the list.
Beside the play button, select the test scheme, then Edit scheme..., go to the Build section, click plus + and select the target you want to test against.
In my case, we have an internal target that we develop with (a few minor differences) and after a merge, it was removed from the test config.
Here is yet another thing to check that is not listed. For me, it had something to do with my team, perhaps because our Team's Agent had not yet agreed to the latest License Agreement! Once I selected a different Team in my Target's General settings, AND then I specified a specific Deployment Target like 12.1 or 11.0, suddenly the "No Such Module" warning went away.
If you have some targets in your project -
check your TARGETS in Module Name that you try to import with #testable import "TARGETSModuleName".
The module name should be the same on:
Target -> Build Settings -> Product Module Name
For example:
I followed the steps above, which worked. However, my project had some more issues. I got this warning and I could not access classes from my main project to test in my test target.
I found that your Test target Product Module Name (YourTestTarget -> Build Settings -> search for product module) cannot be the same name as your project name.
Once I changed the Product Module Name for my test target everything worked.
I tried all the answers here but the red flag would not go away. But I got it to work by just "running" an empty test regardless and it cleared up.
Things I would like make sure are done:
Host Application
#testable import "Module_name" (make sure the module name is correct)
Make sure you deployment target for the test is the same as the project
XCTest does not need to have Target membership
XCode 12.6 beta
I'm not sure what caused this issue for me but cleaning my build folder didn't sort it. Restarting XCode didn't sort out the issue either.
What worked for me was deleting this line: import XCTest, and then retyping it again.
My issue was that the class i wanted to test was supposed to be in a separate module (API Client), but the class was actually a member of the app target and not the framework target. Changing the target membership of the class made the import error go away!
Environment: Xcode Version 9.0 (9A235)
Scenario: Testing an open-source framework.
I had the same problem: 'No such module'.
Solution:
Select the Test target.
Select Build Phases
Add the framework to be
tested via Link Binary...
Here's the test file:
I had this same issue. Cleaning the build folder and restarting Xcode did not work.
What did work for me was ensuring that the setting for "Build Active Architecture Only" of your test target and scheme matches the setting of your app's target and scheme.
XCode 12 Development Beta 3
The error fixed itself after I've built the project for the first time.
This is what worked for me with Xcode 13.1:
In the Locations tab in Xcode Preferences > Locations I had defined a Custom location:
This caused not only unit tests to fail with the dreaded "No such module" error, but also also "Command CodeSign failed with a nonzero exit code" and other warnings and errors.
Changing the setting to Unique:
fixed all problems.
It could also be:
Not set the hosting application for your test target (in the general tab or TEST_HOST build setting)
Missing the app dependency in your Build Phase for your test target.
For me the solution was to rename
#testable import myproject_ios
to
#testable import myproject
after I had updated product name of target myproject-ios in Build Settings/Packaging/Product Name/ from ${TARGET_NAME} to myproject.
This was fixed for me when I changed the Deployment Target from 9.3 to 11.0.
General > Deployment Target > "11.0"
If you are using xcodebuild and find this problem, consider adding in a workspace flag to the build command.
Changed This
$ xcodebuild -scheme PowToonsTests -destination 'name=iPhone X' test
To This
$ xcodebuild -workspace PowToons.xcworkspace -scheme PowToonsTests -destination 'name=iPhone X' test
In build settings test target, check the host testing, it takes the name set in PRODUCT_NAME.
It is that name that you should use in test classes.
I recommand to not change PRODUCT_NAME (match name of the main target)
I think this may have happened because I deleted the example tests.
I removed the Unit test bundle then re-added it as shown in the pictures below and all was well again.
CocoaPods recommends adding inherit! :search_paths to your test target like so:
target 'App' do
target 'AppTests' do
inherit! :search_paths
end
end
Source: https://github.com/CocoaPods/CocoaPods/pull/8423#issue-244992565
Tried all the solutions. Nothing worked. The Xcode build cli failed on a swift package module not found error.
error: no such module 'Apollo'
import Apollo
Removing the Test targets and re-adding them worked for me.
I changed the name of my project as I didn't want my original name for the app to show in the app store. This necessitated a change in my app host, which necessitated a change in the import I made.
Old name: QRCodeTarot
New name: Pointy Hat Tarot
This is the change I made for my host in my version control client.
This meant that in my tests, I needed to change the name of the import to the display name of my app. So even though my project was named QRCodeTarot, I needed to change the import to the display name.
So I went from import QRCodeReader to import Pointy_Hat_Tarot.
The recommendation to make your project name match your test import name is wrong.
The import name should match your project's display name, not your project name

Xcode 4 hangs at "Attaching to (app name)"

I just upgraded to Xcode 4 and for some reason my app won't run in the simulator or iOS device. It was working perfectly in Xcode 3, but all of a sudden now when I press run the program stops at "Attaching to...". There doesn't seem to be any other info to help with this problem either.
For summary you can try following things to tackle the issue:
Restart the simulator.
Make sure that you haven't included the Info.plist file in your Building Phases -> Copy Bundle Resources.
Resources folder added to the project as a folder reference (the blue folder icon). That caused the trouble, after adding the folder as a group the problem went away.
Fixed it!! Hopefully this helps some people avoid a very frustrating couple hours. I solved this by:
Clicking on the project name in the left pane (at the very top). This will bring up a new menu to the right, something like the project/ target editors in XCode 3.
Click on Build Settings up at the top.
Under Packaging make sure your product name is the same for every build, and equal to whatever it says it's attaching to. Eg if XCode is Hanging at "Attaching to myLCBO" but your product name is "LCBO Finder" then it won't build. That was exactly my problem because I renamed my app half way through development.
Here was our fix:
In Project > Edit Schemes > Run.
Change the Debugger from GDB to None (directly above the green circle in the image above).
A tip I found at the Apple Developer Forums:
Go into your ProjectName.xcodeproj/
directory and delete anything named
with your userid. Re-open the
project in xcode and all that will get
recreated and it should work. At least
it did for me.
Another tip is to manually delete the build directory.
Yet another tip is to navigate to the Organizer (Shift ⇧ Command ⌘ 2 in xcode 4), select Projects, select you application in the left hand side and then the Delete...-button to the right of Derived Data.
And never forget the universally useful tip: restart your computer and try again.
Good luck!
Solution provided didn't fix the problem in my case.
In order to solve it (XCode 4 only), I had to go to Product -> Edit Scheme. Then select the "Run " scheme, and marked "Automatically" which wasn't enabled.
Hope it helps someone.
For everyone still trying to resolve this after everything you tried from above, try reseting the iPhone Simulator.
Simulator > Device > Erase All Content and Settings...
This will erase all apps from simulator, but now you can finally use simulator!
Also: make sure that you haven't included the Info.plst file in your Building Phases -> Copy Bundle Resources. If so, remove it from that list! I small mistake which could happen, but something that messes things up quite nasty :S
Restarting simulator works for me :)
One more possible solution: I had my Resources folder added to the project as a folder reference (the blue folder icon). That caused the trouble, after adding the folder as a group the problem went away.
I really find the answer for me :)
for me,
project setting -> your target -> build phases -> validate setting -> perform
and now the problem is gone.
:)
I hope someone it help
I solved this problem how:
1) iOS Simulator->Reset Contents and Settings...
2) Sure project name, scheme name and target name is identical. "AppName" and "Appname" is not true. Must be "AppName" and "AppName", or "Appname" and "Appname".
3) Restart XCode and Quit Simulator.
Project name at Build Settings->Product Name.
Scheme name at Product->Manage Schemes. Click on current scheme once for rename.
Target name at Column of Project with Targets. Click once on current target for rename.
Good luck =)
Like Rob said, but also check the "identifier" should read by default "com.yourcompany.YourAppName" I had changed the "yourcompany" by mistake and this caused the same issue noted above.
This also seemed to happen to me when the info.plist file was in the copy build phase. It appears that sometimes Xcode will warn you about this, and other times it won't. Very strange. But if you are experiencing this issue, make sure that info.plist is NOT in your copy build phase.
My problem was also a folder named "resources" on the root source folder. Looks like it conflicts with some internal build naming.
Renaming the folder to "res" solved the problem for me.
I tried everything in this page, and the "new" solution that worked for me was to go into the simulator, and "Reset Content and Settings" in the iOS simulator main menu.
This solution is not technical but it worked for me.
When Attaching to Process shows up in xcode and it hangs for a while, just quite the iOS simulator and re-launch the app by pressing Command + R.
It will launch the app without any issues :)
I tried everything and nothing worked. I have an old project from XCode 3. I simply renamed info.plist in the project to another name, restarted the simulator and everything is working fine since.
I frequently encountered this problem after renaming a project in Xcode 4.
I was able to fix it by editing the Bundle Identifier in the .plist file.
After I renamed the project, the Bundle Identifier would change to something like this:
com.yourcompany.${PRODUCT_NAME:rfc1034identifier}
changing it back to this:
com.yourcompany.${PRODUCT_NAME}
will stop Xcode from hanging and allow the App to run.
For me, none of these has worked. I realized that my project had 2 info.plist files (with two different names, like info.plist and Project-info.plist), so XCode got confused. I just removed the incorrect plist file, and it worked!
Under Product > Edit Scheme > Run > Info, changed the Debugger from LLDB to GDB worked perfect for me!
I had the same problem. The issue was there was one more user who was logged in and had the simulator running. Think there can be only one instance of iphone simulator running on a machine even for different users. Hope this info would be useful for somebody :)
What worked for me is the following:
In XCode:
Click on project name
Click on target name
Click on "Build Settings"
Reveal "Product Name" contents (click on triangle)
Make sure the name of all items matches that of project name
Example
Product Name myapp
Debug myapp
Release myapp
Reveal "Deployment" contents (click on triangle)
Make sure there is a "IOS Deployment Target" item
Example
IOS Deployment Target IOS 3.0
Debug IOS 3.0
Release IOS 3.0
Then clean and run.
This is what worked for me:
In Xcode navigate to the Product menu and choose EDIT SCHEMES.
In the list on the left choose Run YourAppName.app. From the Executable menu choose OTHER.
Navigate and choose your .app file in your project directory.
Now run and it works :)
I noticed it happened to me when I edited the scheme from Build Release to Build Debug.
I changed back, and it worked :)
What worked for me:
Launch "Monitor" and kill gdb-i386-apple-darwin which was supposedly hung
Restart iOS simulator
My solution is correcting the nib name. (I changed my nib name before for an iPad version but then I deleted the iPad nib file). Then it works well again.
All of the above suggestion didn't resolve my problem.
After I added the Resources folder and and compile, it hangs on attaching to app-name.
I removed Resources folder, still hang.
I removed the project and recreate a new one ( with the same name ) but still having problem.
If it was different name then it's ok. I restarted the OS but still doesn't help.
To solve the issue, I did the following:
1. ps -ef | grep Xcode, and kill all the "Xcode" processes.
2. Reset the content of Simulator, and quit the Simulator.
3. Product > Clean to clean up the build.
4. Compile and run the product. It should work at this point.
Hope it helps some else having this similar issue.
I encountered this error after incorporating another project inside my new one. Make sure you delete the project that you have added's info.plist and .app
Just came across the same problem: restarting the simulator and Xcode didn't work for me, while restarting my mac worked out pretty well!
After all said and done. I had to stop the simulator. Then the message change to downloading Mac OS X 10.6 core library.
Create a new user account, switch to account, open XCode and try running the project. After trying all of the other suggestions with no success, not only was I again able to run on sim, but the original account now works.

Build and run Disabled in xcode

There are some applications which shows Build and run icon disabled which stops me from running the application.It does not happen to all applications but on a few . It mainly occurs to me in facebook applications and a few more applications.Can anybody have an idea what could be the problem ? I have tried everything from changing the build settings etc. but it does not work.
Need to fix the executable, it happens after renaming project.
Product > Scheme > Edit scheme..
Select
Run > Info
Set Executable is your app name, if selected None.
Try this, It's work for me.
Follow below steps to unable Build and Run in xcode
1) Go to
Product => Scheme => Edit scheme.
2) Select Run option and select info
3) In Executable if option is selected to None then change it to your app name
Hope this is help for some one.
That project appears to be the Sparrow audio project. It's not a stand-alone project you can run; it's a library, you need to be using it in another project to have anything to actually run.
The sparrow project includes a sample app called Scaffold which demonstrates the use of Sparrow. More info:
http://www.sparrow-framework.org/help/gettingstarted/
Also see:
http://www.sparrow-framework.org/help/documentation/
Note that you can still 'build'; it's just 'build and run' that can't be clicked.
I think those may be frameworks,static libraries. So the build and run option is disabled.
I think you might be creating plugin or frameworks or libraries (not an Application).
So the "Build & Run" icon is DISABLED.(as answered by Chandan Shetty SP)
In order to enable the icon you need to specify the Application which use this plugin or framework or library whatever you are building.
To specify such application:
Rt. Click on "Executables" (in Xcode's Groups and Files panel)
Select Add > New Custom Executable
Then specify the name of application (just for display purpose) and specify the path of the application.
Go to the Project menu in the menubar and change the Active Target to the target of the actual app.