Trying to add alamofire to swift project using unstruction from here
Did all these steps, clean project a lot of timer and restarted XCode, nothing helps. Error does not dissappear
http://i.stack.imgur.com/kNU3R.png
"Cannot load underlying module for 'Alamofire'" and nothing to do
Changes I did:
1) added project file to my project
i.stack.imgur.com/eUe8E.png
2) added to build phases panel
i.stack.imgur.com/1wanl.png
3) added to general tab
i.stack.imgur.com/L3TTR.png
What`s wrong with that?
I had the same problem. I was able to fix it by doing the following.
Download the Alamofire "Source" folder.
https://github.com/Alamofire/Alamofire/tree/master/Source
Drag it into your xCode Project, and click "Copy Items if Needed". If you view the project in Finder, the Alamofire Source folder should be in the project itself. (Ex: I have 3 items. Example App, Example App.xcodeproj, Example App Tests. The folder should be in Example App.)
Finally, you should be done! However, now, you do not need to import Alamofire, since you are not actually loading a framework.
For example, instead of doing Alamofire.upload, you will now only do upload.
Related
Here's what I've done so far:
Create a Single View App project called MyApp
Create a Cocoa Touch Framework project called MyFramework
Created a Swift file with a class as public class FrameworkClass
Dragged MyFramework.xcodeproj into MyApp's Project Navigator - This caused Xcode to create a workspace.
I added the framework to MyApp.General.EmbeddedBinaries
Now it looks like this so far but I can't seem to import my framework still:
Please follow the steps to resolve your problem:
Choose your project, rather than a specific target, and open the
Build Settings tab.
In the Other Linker Flags section, add -ObjC.
If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
Right before alt-tabbing Xcode to submit this response, I built on reflex and it turns out that it won't detect the references until you build once. After that, it should start to be detected by the text editor.
I was going to delete this question however, I already typed it up anyway so might as well. Hope this helps someone!
I created the most simple custom class in a separate Swift file in my project:
class Foo
{
init()
{
println("I made a foo.")
}
}
Then, in a playground within the same project, I tried
var x = Foo()
Xcode didn't seem to like this, and told me that 'Foo' is an unresolved identifier. I'm somewhat confused about how playgrounds fit into the rest of the project structure, since any other Swift file in my project can resolve 'Foo' without issue.
How can I make my playground able to use custom classes I define in other Swift files in my project? I have tried naming the product module for the build target and importing that into the playground, with no success: the playground doesn't recognize the name of the product module.
Thanks in advance for the assistance. I know it is something simple.
There's two ways to use your project's code in a Playground
Playground's Sources Folder
Yes, in Xcode 6.3 Beta 3 (and hopefully, into the future):
Playgrounds are now represented within Xcode as a bundle with a disclosure triangle that reveals Resources and Sources folders when clicked. These folders contain additional content that is easily accessible from your playground’s main Swift code. To see these folders, choose View > Navigators > Show Project Navigator (or just hit Command-1).
Open up a new playground and hit cmd + 1 to see the left pane, then drag files into the source folder to use within the playground.
Note:
The files in the source folder are compiled to a framework which means if you want classes, functions, etc. to be accessible in the playground, they must be explicitly marked as public.
public class VisibleClass {
}
class InvisibleClass {
}
Source: release blog
Compile Project Into Framework
Move project to workspace if it isn't already. (File -> Save as Workspace) will do the trick
Add framework target to your project
Build framework
Make sure files you want to access are added to your framework target
Add Playground to workspace (NOT the project)
Use #testable import YourFrameworkName
Access code in playground
I made a write up here that goes into a bit more detail if you want to check it out.
They cannot. Playgrounds are self-contained. This will hopefully change in the future.
Edit: As of Xcode 6.3, Playgrounds can now contain supporting code. They still cannot see other code in the same project, but code can be added to the support folder of a Playground that can be used from within the playground. See the Swift blog for more info.
Yes.
I started by just adding a class file in the Sources directory.
I made everything public:
class
init
members
After much trying, nothing worked. The XCode crashed and after reopening it all worked like a charm.
In Xcode 10's Project Navigator:
Add the source code file to the playground's Sources folder.
Drag the file from the playground's Sources folder to the desired location in the project (you should see the little "plus in a circle" icon appear.
End the drag and then in the Add File dialog uncheck "copy if needed"
The source file now "lives" in the playground package; the Project refers to it (you can verify that with the File Inspector).
I tried it the other way around: file lives in project folder with reference in playground's Sources folder but it didn't work; I ended up with two copies of the source code file.
I Integrated SDWebImage in my project , its work like a charm in my mac system but while i am sending my project to other mac system its showing error like SDWebImage/UIImageView+WebCache.h File Not Found but the same project working in my system .some time i i am also getting the same error in my mac system after running the project continuously for 2 to 3 days
i tried all the ways like changing path to project>target>Build Settings>'header search paths>$(SOURCE_ROOT)/SDWebImage
also tried $(BUILT_PRODUCTS_DIR) - In header search paths,
please give me the some suggestions to solve my problem
Thanks in Advance
its only because the added SDWebimaege in your project its only reference so add folder of SDWebimages demo project in your project folder
and i am configure SDwebimage like this way:-
you need to first right click on your project name:->add files to yourProject-> selected SDWebImageproject and add them
NOTE:- please do not check copy option
now click on project name in Your xcode going to build phases:->target dependencies:-> click on + button and add SDWebimage ARC
now select link binary with library click + button add libSDWebimageARC.a and again click + and add imageIO.framework and also add libxml2.dylib thats it
going to Build setting:->other link flag:-> add -ObjC
and header search path add this three item
1 /usr/include/libxml2
2 "$(OBJROOT)/UninstalledProducts/include"
3 "$(TARGET_BUILD_DIR)/usr/local/lib/include"
now build and run its working like smoothly cheers.... :)
just try heading this in your frameworks path as well:
$(SDKROOT)/Developer/Library/Frameworks
When you create an XCode 4 project, it asks you if you want to include unit testing. But how do you add it to a project that's been created without them?
I started a project with Unit Tests to try to figure it out, and it looks like the only difference between it and my existing project are the Test.h and Test.m files in the new project.
But when I move them into my old project and try to build, it says no such file or directory: SenTestingKit/SenTestingKit.h. That looks like a framework to me, but if I go to build phases and try to add the framework, there isn't one available called SenTestingKit :( And the new project only links the usual suspects: UIKit, CoreGraphics, and Foundation, but no SenTestingKit.
Answer updated for Xcode 10.2.
Glad you asked this question — it's never too late to add tests to a project!
Open your targets panel by selecting your project in the navigator,
Click the + button that's at the bottom of the target list,
Select iOS Unit Testing Bundle under Test section in iOS tab,
Provide the required information and click Done.
It's that simple. Xcode will generate a target, some boilerplate files such as Info.plist and an initial test case file for you. Happy testing!
Also, if you want to be able to do cmd-U to run your tests then delete the scheme that was created for the test bundle and instead edit your main application scheme and add the test bundle in the Test configuration. See this screenshot:
Xcode 7 update
Method one
File > New > Target...
Choose iOS Unit Testing Bundle. (If you want to add UI Testing then choose the UI Testing Bundle.)
Method two
Click your project name in the Project Navigator. You will see TARGETS listed. At the bottom of the screen press the plus (+) button and add the iOS Unit Testing Bundle.
The test targets in this image have already been added, but you can see where the add button is.
Related
How to do a Unit Test in Xcode
Xcode UI Test example
One more variant using Test navigator
Xcode version 10.2.1
Open Test navigator(⌘ Command + 6)
+ at the bottom
New Unit Test Target...
Choose options
Do not forget add next import to test internal[About] elements
#import "myClass.h" for Objective-C
#testable import module_name for Swift
This is pretty descriptive how-to guide:
Adding Unit Tests to an existing iOS project with Xcode 4
Some more tips to the correct answer:
In XCode 6 it is much easier now since you don't need to fix any build settings.
Change the bundle id on a test target to the correct one, if needed, by clicking the target -> Info -> Bundle Identifier.
Press CMD + U and your tests will run.
If you use CocoaPods (which is likely), you should also add Pods to the Configurations of your Project.
[Updated for Xcode 10.2]:
Open your Xcode project
Open targets
Click "Add Target" button
Go to "Test" section
Select "iOS Unit Testing Bundle"
I went back to an old project and recompiled it for OS 4.1 succesfully and ran it. I was asked to add a fourth tab to the Tab Bar, but I could not set its class to the newly added ModelsVC.h/.m. [edit: because it did not appear in the class dropdown, but the other viewcontrollers were there.]
I moved the project folder to a backup folder and unzipped a months old backup of the same project. It compiles and runs until the end of viewWillAppear for the first (default) view connected to the first tab, and then does nothing more. It is still running, but nothing is shown and nothing happens.
In the console, it says "Unknown class ModelsVC in Interface Builder file."
The problem is, that class didn't exist two months ago, so why should this way old project complain about it or even know about it?
I'd like to know where to look / tell XCode to use the .xib that is inside the project folder it is currently compiling.
And if it's path-related, how do I check what paths XCode looks in when a project is loaded/compiled?
For Xcode to run a .xib file inside the project folder, You can just open your xcode, add existing file and it is there.
I think the problem why the old project still runs is that it builds incrementally. That means when it builds the first time, the .xib file was there, and when it build the second time, it doesn't need to add and build the .xib file any more. So, in the second build, even if you delete and move out the .xib file, I think it still can build
Seems a 'sloppy copy' for whatever reason (such as a quick backup to try something experimental) of a project folder causes confusion. See this.