Balanced Payments tutorial in iOS [duplicate] - ios

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

Related

Xcode import my framework into a project

I've created an objC dynamic framework and I'd like to add it as a dependency into an objC project.
I've read those guides and some SO answers but none of them works:
https://developer.apple.com/library/content/technotes/tn2435/_index.html
http://netsplit.com/xcode-two-apps-with-a-shared-private-framework-in-a-workspace
https://medium.com/swiftworld/my-xcode-project-structure-for-open-source-project-1d363ff48534
https://www.raywenderlich.com/126365/ios-frameworks-tutorial
Basically what I do is open the host app and drag the framework project in it.
Then I drag the framework from the Products group of the framework project into the Embedded binaries section of the sample app.
What I see in the build phases is that I have:
In the target dependencies I can see the framework
In link binary with libraries I can see the framework
It has been added a new phase called Embed framework and my framework is there
If I try to import the framework module the compiler says
Module XXX not found
The only way to make it work seems to add in the framework search path of the build phases, the direct path to the product of the framework itself.
For what I understood it seems that somehow the path of the framework is not taken into account, but as far as I know in none of the guide is written to change it.
[NOTE]: no cocoapods or Carthage solution
Turns out that I had a wrong build settings in Per-configuration Build Products Path, instead of having it to point to build/debug-iphoneos it was pointing just to build .
Thus the process explained in the question works.
Hope this will help someone else.

Add a framework to an existing project without using cocoapods

I've got an existing project where i want to add the framework called CoreActionSheetPicker from
https://github.com/skywinder/ActionSheetPicker-3.0
The problem is i cant seem to add the framework to my project? when i pull the framework over to my existing project none of the files below is added and when i try to import it says it does not exist
import CoreActionSheetPicker
I want to do this without cocoaPods. What is the steps in order to do such? i'm using swift. Do i first need to create a WorkSpace?
I've just cloned it, and it appears the project file is invalid. You can see this by trying to open it. You should raise the issue with the owner on GitHub, which is how you're supposed to ask questions about projects there. Then you will get feedback directly from the creator or at least someone else who knows about that project.
As for adding a project,
Download the source
Drag the .xcodeproj into your project within Xcode
Add the framework in Build Phases / link binary with libraries
Add it as a Build Phase / target dependency.
Note that at the moment, you should always builds 3rd part libraries with your swift project, and not just include the binary. See here about binary compatibility of frameworks:
https://developer.apple.com/swift/blog/?id=2

Any way to make bundle xcode project to include a static library xcode project?

I have a static library xcode project (.a) and a bundle xcode project (.bundle)
I added the (.a) as a sub project of (.bundle) and added to [Target Dependencies] and [Link Binary With Libraries].
After run the bulid the (.bundle) still not contain any binary file inside (.bundle).
It's work if I add the .c and .h files to under (.bundle) directly, but that make me need to handle two project files. Any way can make (.bundle) just build with the (.a) ?
This question same as what I asked, I tried to follow his 11 steps without the step 10 because he said lastly no need that step. But the generated (.bundle) still without contain any binary
Finally, I make it work.
The step 10 still important and below is corrected step 10.
create a dummy.c under (.bundle) project and the dummy.c can just totally empty. remove the setting for the library you want to link inside Link Binary With Libraries instead use -Wl,-force_load,$(CONFIGURATION_BUILD_DIR)/libYourLib.a or -all_load to Other Linker Flags
PS: And also can use sub-project instead of workspace. and use Target Dependencies instead of Edit Scheme to achieve the same effect.
The testing project

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.

Framework import issue in xcode

Here the problem: For a project at work we need to include an extern API: mobileAppTrackeriOS from HasOffers.
It gives us a framework to include in our projet and instruction to enter in our code.
So I copy the framework in the project directory and drag it into xcode to include it.
But when i want to use it with:
#import <framework/mainheader.h>
The build give me an error :
Lexical or Processor issue 'MobileAppTrackeriOS_arc/MobileAppTracker.h' file not found
I check the framework search path in my target build setting, my main directory where is the framework is here.
I test with "" instead of <> same issue...
i cleaned and rebuilt, try to include directly the header... many ridiculous things... no changes.
So what I forget?
I'm on Xcode 4.5 and develop for iOS 6.0.
A question, can you see if the framework is in Build Phases -> Link binary with Libraries?
If answer is not, you must add in this section.

Resources