Linking static libraries to XCode Project libMWPhotoBrowser.a - ios

I'm trying to add MWPhotoBrowser as a static library to my project.
I've added MWPhotoBrowser.xcodeproj and the instructions for adding a static library are to know go to build phases and add libMWPhotoBrowser.a - I think this is a product of the MWPhotoBrowser build (from what I've ready and the little that I understand) but I'm not sure what to do here?
I go to build phases and click add but, obviously, libMWPhotoBrowser.a is not showing up and I'm not sure why - can anybody else point me in the right direction on what to do next?

I think the only problem you are facing here is that you didn't build your static lib: libMWPhotoBrowser.a from the MWPhotoBrowser.xcodeproj you have added to your project. Once this is built you can add the .a file from the build phase section or just make a drag and drop of the file there.

Related

The frameworks' link path has changed after the project moved to another place

please take a look at the picture:
It's my project structure:
1 app(top one)
3 frameworks (create by myself)
1 cocoa pods static library(bottom one)
When I cmd+b, all the sub projects would be build start from the bottom one to the top one, here is no problem, everything are fine.
To refer/link the frameworks, I drop the framework product to every sub project's /Build Phases/Link Binary With Libraries and /Build Phases/Copy Files.
The problem is:
When I copy/move the project folder to another place (like ~/oldFolder/app to ~/newFolder/app) the sub project cannot finds the frameworks, it report Not Found Error, I need re-build and drop the framework product to link to fix the error.
It's too stupid and hard to work with other people, anyone can help?
p.s.: sorry for my poor english.
Add error pic:
You can use $(SRCROOT) if you want to refer paths relative to your source directory . $(SRCROOT) will point where your project files are . apple doc
An example :
if you have a directory x in your MyApp folder which contains your project file then the folder x can be reffered as $(SRCROOT)/x. Enter this in frameworks path section in Build settings to refer to your library .
This all boils down to you not being able to change the location of the already imported frameworks right? This is an example with the FBSDKCoreKit.framework. If I were to change the folder location I would need to change the relative path. Click on the folder Icon right next to the name and choose the new location
I post the detail of how to fix this issue on my side here:
In Framework:
set "$(SRCROOT)/../build" at item "Per-configuration Build Products Path" in Build Setting page;
shift+cmd+k to clean up the framework build, then cmd+b rebuild the framework;
In MyApp
add "$(SRCROOT)/../build" at item "Framework Search Path" in Build Setting page;
Drag the framework from the product of framework project to "Link Binary With Libraries" in Build Phases page;
Drag the framework from the product of framework project to "Copy Files" in Build Phases page(you can add the "Copy Files" item by
click the top left of Build Phases page);
Please note if you use one more framework in the same project, and the framework also links to another one like the sample I sent in my question, you also need to do all the steps as above I posted(Steps of Framework and App).
Another problem you will meet if you also use cocoapods in your project like my sample: After you done all the steps above, XCode will response error in your framework project like:
ld: framework not found Pods_xxx.framework
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The "xxx" should be your framework project name. To fix it, you just need remove the Pods_xxx.framework in your project/General/Linked Frameworks and Libraries. The error will be disappeared after you rebuild the project. Here you can find the detail of this problem.
p.s.: the Pods_xxx.framework will appear in General/Linked Frameworks and Libraries after you install pod, so you need remove it again if you run command "pod install"

Adding an Objective-C framework to a Swift XCode project

I know this is a very simple - maybe obvious - question, but I've been struggling with it for a while. I'm working on a SpriteKit project in XCode (using Swift) and I'm trying to add this SKEasing Framework from GitHub.
I've already downloaded and extracted the zip file, and I did everything that 孙博弘 answered including the bridging header (which I made the with the help of this site);
However, the framework doesn't seem to be working. I can't use any of the actions provided by this library. Is there something I'm missing? What am I doing wrong?
You don't add the project to your project.
First open the SKEasing project in xcode by itself. Set the build target to generic iOS device. (With the pop up in the top left corner of the xocde project window.) Then use the Build command (under Product) and when that's done run Archive. There should be a library built now under the products folder (left side of project window). Control click on the library name and select Show in Finder. This will lead you to the library. Copy this file to your project and you should be good to go.
if you use .a, you should use it as follow img.

How to make XCode add the linked project headers and implementaion files to the static library and framework

I have a static library project and in that project I linked a .xcodeproj to the source code so I can update easily actually and to not copy and paste files in the static library project for easy update.
The purpose thought it's to embed this .xcodeproj with my code into the result static library or .framework that I will build using a script.
Although I can see that there is nothing added in the compile sources or the copy header files which I added. If I try to add with drag and drop files from the linked project to my static library build phases copy header section it copies the file to my project again, but I don't want this.
And if I add a header file #import to one of my public headers and try to use the static library to the client project it complains that the header is not found!
So, in the end, what I want is the whole linked project files to be copied in the resulting static library or .framework with the scripts and target I have.
Is this possible to achieve, I think I miss some project setting that I'm not aware about that will see and copy all header and implementation files to my result static library or .framework?
Is my approach overall correct? I don't think that there is no option to use a linked project in a static library and embed it when the build is happening since I am using it in my project!
I could add the .framework of the third party component too and merge to my static library. I have created this question earlier today. Is it possible to include a .framework in a .framework and how?
Regards.
Not sure if your #import-not-found issue is a linker issue, but...
Make sure to use the -ObjC flag in "Other Linker Flags" in the library's Build Settings. This gets the linker to build everything in the library.
Mentioned here:
https://developer.apple.com/library/ios/technotes/iOSStaticLibraries/Articles/configuration.html
And also make sure you link in the library in the build settings for the project that needs it.

Balanced Payments tutorial in iOS [duplicate]

I am trying to do the payment using https://www.balancedpayments.com/ . They have their iPhone library for this https://github.com/balanced/balanced-ios . The problem is that there is not enough documentation on how the Balanced.framework has to be added in the XCode 4.5 project?
Download the Balanced framework.
Add Balanced.framework to your project and to Build Phases -> Link Binary With Libraries.
Add CoreTelephony.framework to Build Phases -> Link Binary With Libraries.
Usage:
#import <Balanced/Balanced.h>
Balanced *balanced = [[Balanced alloc] initWithMarketplaceURI:#"/v1/marketplaces/TEST-MP2autgNHAZxRWZs76RriOze"];
BPCard *card = [[BPCard alloc] initWithNumber:#"4242424242424242" expirationMonth:8 expirationYear:2025 securityCode:#"123"];
If you need more help, look at the example project they have attached...
You Just Need to add those Balanced- Classes as a static library, It will work out.
Add a Static Library to your Project.
Now add those balanced classes to your static Library.
Goto YourProject->Target->BuildPhases->LinkWithBinaryLibraries
Here add the StaticLibrary.
Hope this will help you.
Follow this issue on Github. The lack of linking Balanced.framework is related to Xcode templates. The fix is documented in the project's "Contributing" section. You need to build it.
The balanced-ios project has changed quite a bit since this question was asked. It now creates a static library instead of a framework. This change was made for the reasons described in balanced-ios Project Architecture.
To integrate balanced-ios into iOS projects, do the following:
Download the latest pre-built release zip from https://github.com/balanced/balanced-ios/releases
Copy balanced.a to your project
Add balanced.a to Build Phases -> Link Binary With Libraries
Add CoreTelephony.framework to Build Phases -> Link Binary With Libraries
Copy includes/balanced to your project's include folder (or create an include folder and copy includes/balanced to it) includes is automatically included in header search paths. Drag includes to your project so you can see the files from there. If you copy the include files to a location other than includes you'll probably need to add the path to User Header Search Paths in your project settings
Code usage examples can be found in the README at https://github.com/balanced/balanced-ios

Trouble Creating Cross Project Reference for Xcode 4

I'm trying to pick up some better code organization practices. Over time, I've developed a collection of utility-type files that I import into all of my iOS projects. Rather than continuing to copy them in, I want to setup a separate "Library" project which builds these files to a static library. Then, I reference the static library in my app's project.
In Xcode 4.2 I created a new project "JTLibrary" with a static library as the target, added some files, and it builds as expected.
Now, I created a new project "LibraryTest" which should behave like any other app project I might be working on. My understanding was that I should be able to drag the JTLibrary project into this project to create a cross project reference. Once that was done, I would link LibraryTest's binary against the static library from JTLibrary.
However, when I drag the JTLibary project into the LibraryTest project, it does not appear expandable. I expected I should be able to see the files in it, etc. See screenshot below:
Can anyone offer some insight to why the project appears like this rather than expandable? Once it is expandable, I should be able to see the static library in the app's project.
Thanks!
EDIT 11/7
It's worth mentioning that I'm working with a VERY basic project now. From the new project window, select Framework & Library >> Cocoa Touch Static Library. Add one function to the default class and build.
I can copy the header and .a files into another project and use them successfully, but if I try to drag the project itself, it appears like the picture above.
To create a subproject simply drag a project node from Finder into Xcode.
DO NOT open two Xcode instances and drag the project node from one to the other (that's why the subproject is not expandable).

Resources