Using Facebook Async Display Kit in Swift - ios

I want to use facebook async display kit in my project for smooth loading in tableview. I read them GitHub page but it's not clear for me. Can anyone help me to understand it?
(ASDK can also be used as a regular static library: Copy the project to your codebase manually, adding AsyncDisplayKit.xcodeproj to your workspace. Add libAsyncDisplayKit.a, AssetsLibrary, and Photos to the "Link Binary With Libraries" build phase. Include -lc++ -ObjC in your project linker flags.)
I did copy xcodeproj file into my own project and add -ObjC. But I do not know what they means by Add libAsyncDisplayKit.a, AssetsLibrary, and Photos to the "Link Binary With Libraries" build phase.. I did not find such files.
Please, do not minus my question, I'm new in Swift. Just show me the road. Thank you!

What it means is that you have to add the libraries you mention in the "link binary with libraries" row of the Build Phases section.
You can arrive to that section by:
- clicking in the project file in the project navigator view
- clicking in the target of the project where you want to use the library in the targets column
- clicking in the Build Phases section you will see the Link Binary With Libraries row.
Just click on the + button and add libAsyncDisplayKit.a, Photos.framework and the AssetsLibrary.framework.

A convenient way of adding external libs is to use cocoa pods as employeed here. (A collectionsview implementation a tableView should be somewhat similar)
(I am not the writer of that article)

Related

Google API integration into xcode project

Add Files to "Quickstart"..., add the following projects to the workspace from the libraries you cloned in the previous step: google-api-objectivec-client/Source/GTL.xcodeproj
--> There isn't any GTL.codeproj, there is GTLCore.xcodeproj instead.
This makes it impossible to reproduce the following steps in the tutorial:
d- Select the "GTL" project's "GTLTouchStaticLib" target and make the following changes:
Add the library GTMSessionFetcher/libGTMSessionFetcherLib.a to Build Phases > Link Binary with Libraries.
e- Delete the "GTL" project's "GTLFramework" target.
f- In the Project navigator, delete GTL project's GTL Source > Common > HTTPFetcher group.
Check out the code. To do this, you can just run svn checkout
http://google-api-objectivec-client.googlecode.com/svn/trunk/
google-api-objectivec-client-read-only from your terminal. I will
refer to this code as "Google's code".
Go to your project's Build Phases. Expand "Link Binary With
Libraries" and add Security.framework and
SystemConfiguration.framework. These two are required by Google's
code.
Go to your project's Build Settings. Using the search box there,
look for Other Linker Flags (make sure "All" is selected to the left
of the search box). Add -ObjC -all_load.
Now search for User headers search path and add the full path to
Google's /Source directory. Make sure you select recursively.
Using Finder, go to Google's /Source/OAuth2/Touch directory. Drag
and drop GTMOAuth2ViewTouch.xib into your project.
Go back to Finder and go to Google's /Source directory. Drag and
drop GTLCommon_Sources.m and GTLCommon_Networking.m into your
project.
Now, you need to import the files for the services you want to use.
In my case, I need to use Google Drive, so I'll add those. In
finder, go to Google's /Source/Services/Drive/Generated directory.
Drag and drop GTLDrive.h and GTLDrive_Sources.m into your project.
If you want to use other services, go to their directory and import
the appropriate .h and .m file.
For some reason, Google's code doesn't use ARC, so if you try to
build right now, you will get ARC compile errors. So we need to
disable ARC for Google's code only. To do this, go back to your
project's Build Phases, but this time expand "Compile Sources". Make
sure that GTLCommon_Sources.m and GTLCommon_Networking.m are there.
Select them, press enter and type in -fno-objc-arc. This will
disable ARC for both of them. Make sure you don't add this option
for any other file (unless you know what you're doing).
You are done! Now, whenever you want to use Google's API, just
import GTMOAuth2ViewControllerTouch.h and your service header. In my
case, since I'm using Google Drive, I will also import GTLDrive.h.

Problems when adding an external framework in iOS

I want to add the PLCrashFramework in my app. This frameworks deals with crash reporting for iOS/MAC applications. What I did
Downloaded and unzipped the .zip file from the URL I have already provided.
In Xcode "Build Phases" -> Link Binary With Libraries
From the pop up "Choose frameworks and libraries to add"
Select "Add Other"... and select "CrashReporter.framework" and Open
After those steps I successfully built the project without problems.
I closed the Xcode, opened it again and tried to build. The build failed with
"header file not found", referring to a header file that belongs to the framework.
Why the xcode 6 does not find the header after closing and reopening the project?
Check your Framework Search Paths and Library Search Paths in your project's Build Settings. Check if you have a space in your directory structure. It's probably looking for 2 folders, one with the first part of the folder structure and one with the second. To fix this, simply add quotes around the whole folder structure.
You should add the framework though add file in project navigator by right click and select add file in your project and than browse to framework location and add framework. Remember to check copy file in your project it is must do. In this way Xcode will manage library header search path. You can see the framework will be added in Xcode "Build Phases" -> Link Binary With Libraries. If it is somehow not there you can add it by dragging framework from project navigator. The error will be gone.

Xcode won't add "Embedded binary" after deleting "DerivedData"

Alternative titles to aid search:
Adding Embedded Binaries fails in Xcode
Xcode won't link framework from separate project
App crashes on device because of missing framework, works in simulator
Overview
After deleting the "DerivedData" folder (or performing a "Product > Clean") in xcode6, I cannot add CocoaTouch frameworks from another project to the "Embedded Binary" section (under General tab).
Or, Xcode hits a linker error because it cannot find a framework that if previously could.
Other symptoms
Clicking on the + under "Embedded Binaries" shows the Framework selector but selecting a framework in different project in the workspace does nothing.
When you add the framework to the Embedded Binaries, there will be a reference added to your project for it. If you select that reference after your steps above, you will probably find that it has an Absolute Path reference to the framework rather than a relative one, which we'd like. Change the location to Relative to Build Products and the reference should always be discoverable if do a "hard" clean or use another computer etc.
I have made a video which describes how best to add a built framework from one project to an app target in another sibling project.
This it the only way i have discovered to restore the embedded binaries, please leave comments if you find some steps are not required.
Prerequisites: Read Daniel Tull's answer.
Remove all framework projects from the workspace
Perform a "clean build" and/or remove the "DerivedData"
Add project back into the workspace
Build the project (possibly optional)
In the General tab of the app target click the + under "Linked Frameworks and Libraries", select the framework.
Build and run in the Simulator (there should be no issues building or running)
Build and run for device (this might cause a crash due to the framework not being correctly linked, ignore this crash)
Click the + under "Embedded Binaries", select the framework. This should add it to the project (possible duplicate under "Linked Frameworks and Libraries")
Repeat for all required frameworks
Once building and running (on device) is confirmed you can remove any duplicate (and/or red) frameworks in the Project Navigator or target General tab
Just to add to #Daniel's answer, if your Location dropdown is greyed out you may have selected the wrong file. Make sure to select the framework that's in your app project (not framework project).

Project Missing Frameworks folder

I downloaded the latest AVCam from Apple. I can't seem to find there is the Frameworks folder. Also if you go to Build Phases, the "Link Binary With Libraries" is not there. You can click the + sign and add a new one. But it shows a blank.
But the project works fine. What is up with that?
You can add the framework from your download direction.
Just right click the framework folder->add files->add your framework
You maybe have to link the added framework.

SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag IOS

I am trying to use SDWebImage in an IOS project.
I am following these instructions from their github:
import the project as a static library.
Add the SDWebImage project to your project
Download and unzip the last version of the framework from the download page
Right-click on the project navigator and select "Add Files to "Your Project":
In the dialog, select SDWebImage.framework:
Check the "Copy items into destination group's folder (if needed)" checkbox
Add dependencies
In you application project app’s target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block:
Click the "+" button again and select the "ImageIO.framework", this is needed by the progressive download feature:
Add Linker Flag
Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag:
Import headers in your source files
In the source files where you need to use the library, import the header file:
#import <SDWebImage/UIImageView+WebCache.h>
But I am getting this error:
SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc
I have tried to search for header search paths that some other answers say and I get these results:
Always search user paths -No
Header search paths
User header search paths
Must I set a value there? Or should I do anything else?
Another thing that i noticed in their demo is that: in their demo, in the frameworks folder they have imported the .xcodeproject of sdwebimageview and I have imported sdwebimageview.framework as the instructions say in the github.
Thanks!
Edit: my project is non-Arc.
I tried changing the other Linker flags from -ObjC to fobjc-arc but I still get the same error.
1)was that correct or should I change something else?
2) if I change my project from non-arc to arc what should I change? I only want to use that library so I prefer not change it.
In the .h file os SDWebImage it says:
#if !__has_feature(objc_arc)
#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif
This tutorial shows you how to set ARC or non-ARC per file in your project.
Unless you wanted to switch to ARC anyway, I suggest you leave your project as it is and just enable the -fobjc-arc option for the files in SDWebImage. Look at the tutorial above, the image in that shows you where to put the flags. (Their example uses -fno-objc-arc, which does the opposite, so just make sure you use -fobjc-arc. You type it in the same place.)

Resources