Hi I have downloaded the iOS source code for iOS but for some reason I cannot seem to find the place where the API_ID is anywhere. Please can you tell me where this information is in the source code so I can add in my own.
Add a file called "config.h" beside Telegraph.xcodeproj and place this code in that:
#define SETUP_API_ID(apiId) apiId = YOUR_API_ID;
#define SETUP_API_HASH(apiHash) apiHash = YOUR_API_HASH;
Then replace YOUR_API_ID and YOUR_API_HASH with values obtained from telegram api support.
Then compile and enjoy it!
Try to use the project search and put API, it`ll return the files where is.
Related
To set up Receipt-Validation in my iOS app, I am now following this tutorial:
https://www.raywenderlich.com/9257-in-app-purchases-receipt-validation-tutorial
and reading at this point: Loading the Receipt.
While reading and attempting to understand what is going on I also try to integrate the code in my own app, by doing so getting a hands-on understanding of the process.
Here is one problem I am hitting at this moment:
On this line of code:
private func loadReceipt() -> UnsafeMutablePointer<PKCS7>? {
I get this error message:
Use of undeclared type 'PKCS7'
After searching the net and trying a few things, I guess it is related to the use of the use of the ReceiptVerifier-Bridging-Header.h file. But I am not sure how to set it in the project.
I will be glad if anyone has some tip allowing me to move forward.
Thanks in advance!
In case this can be useful, here is the meaningful contents of the bridging header file (ReceiptVerifier-Bridging-Header.h):
#import <openssl/pkcs7.h>
#import <openssl/objects.h>
#import <openssl/evp.h>
#import <openssl/ssl.h>
#import <openssl/asn1_locl.h>
The problem is that I had simply copied the bridge-header file, without doing the proper setting as explained here:
https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_objective-c_into_swift
I want to get the device location in the application that I want to develop. I have created a SWIFT project and I want to add the code here
https://github.com/intuit/LocationManager
into my existing swift project.
So here it says
Manually from GitHub
Download all the files in the INTULocationManager subdirectory.
Add the source files to your Xcode project (drag and drop is easiest).
Import the INTULocationManager.h to your bridging header.
Swift: Add #import "INTULocationManager.h" to your bridging header.
So basically can I just drag the source code to my project?
Also how do I create the bridging header?
then let say how do I use it in my ViewController?
Thanks
Maybe you should consider using CocoaPods as it may be easier for you to integrate, and in the long-run, is easier to update.
To answer your specific question about a manual installation:
Yes, you can just drag the source code into your project. Instructions for creating the bridging header can be found on the internet (for example, here).
Next, as the instructions say, add #import "INTULocationManager.h" to your bridging header, e.g:
#ifndef TestBridgingHeader_Bridging_Header_h
#define TestBridgingHeader_Bridging_Header_h
#import "INTULocationManager.h"
#endif /* TestBridgingHeader_Bridging_Header_h */
To use the library, you have to translate the example given on the Github page from Objective-C to Swift.
let locMgr = INTULocationManager.sharedInstance()
locMgr.requestLocationWithDesiredAccuracy(INTULocationAccuracy.City, timeout: 10, block: { currentLocation, achievedAccuracy, status in
if status == .Success {
} else if status == .TimedOut {
} else {
}
})
This is made easier by remembering a few rules:
Method calls in Obj-C are called via enclosing square brackets (e.g. [INTULocationManager sharedInstance]) while in Swift they use dot-syntax (e.g. INTULocationManager.sharedInstance())
Enums such as INTULocationAccuracyCity generally get translated to only their last part (.City in this case). Swift infers that .City is equivalent to INTULocationAccuracy.City.
Obj-C blocks such as INTULocationRequestBlock are equivalent to Swift closures of the same type.
I am trying to follow the steps given here:
http://docs.pushmote.com/docs/import-pushmote-ios-sdk-swift
but I am getting this error: 'PushmoteSDK/Headers/Pushmote.h' file not found, when I try and build my app.
Its my Pushmote-Bridging-Header.h file that has this import statement and the file is clearly there, in project_dir/PushmoteSDK.framework/Headers/Pushmote.h
I have read about a few other header file not found error with xcode and the solutions seem to vary a lot, so I think it might have to do with the specific version of xcode. Perhaps someone has used pushmote with xcode7 before and can assist?
EDIT:
This is my Pushmote-Bridging-Header.h file found in /Users/alex/ios_projects/Monkey/Monkey/Pushmote-Bridging-Header.h
#ifndef Pushmote_Bridging_Header_h
#define Pushmote_Bridging_Header_h
#import "PushmoteSDK/Pushmote.h"
#endif /* Pushmote_Bridging_Header_h */
You should change import line like this;
#import "PushmoteSDK/Headers/Pushmote.h"
to
#import "PushmoteSDK/Pushmote.h"
I have an xcode 6 swift project and I am trying to use C++ with it. In my project on the left I clicked 'new file' and I chose empty C++ file. Then I click yes and xcode generated Bridging-Header.h file.
In my new .cpp file I have #include <string>. I tried to compile the file and everything compiled fine. Later I realized that I forgot to include the .cpp file in the bridging-header.h because my swift files didn't have access to a function in my .cpp file. When I added the #import "cplusplusfile.cpp" in the bridging-header file, I get this error on this line:
#include <string> (!)'String' file not found
my goal is to get a string the user enters in a UITextField and send that string from my Swift files to a function in my C++ file so then I can use C++ to write that string to a file (I don't know how to read/write files in swift and couldn't find much on it..).
Would anyone know possible solutions? I looked online and other questions. One of the solutions was to change my cplusplusfile.cpp to cplusplusfile.mm. Unfortunately it didn't help :(
I'll answer something completely different cause I know you're going in the wrong direction, using C++ just to write a string to file is running around in circles, you want to use NSString and write that string directly to a file, in swift you can use the method
func writeToFile(_ path: String,
atomically useAuxiliaryFile: Bool,
encoding enc: UInt,
error error: NSErrorPointer) -> Bool
And give it a string which is the filename and the string to write get that by reading it directly from your UITextField by using myTextField.text, it should write that to file right away.
Good luck learning swift ! :)
also here's the class reference for NSString
Use following instead:
#import <string.h>
I am using Google Cloud Endpoint with iOS. I am trying to create the service object per the instructions at https://developers.google.com/appengine/docs/java/endpoints/consume_ios#Java_Creating_the_service_object. For the line of code [GTMHTTPFetcher setLoggingEnabled:YES]; xCode is showing the warning
class method '+setLoggingEnabled:' not found (return type defaults to 'id')
But when I look inside the .h file for GTMHTTPFetcher I can actually see the method as
#if STRIP_GTM_FETCH_LOGGING
// if logging is stripped, provide a stub for the main method
// for controlling logging
+ (void)setLoggingEnabled:(BOOL)flag;
#endif // STRIP_GTM_FETCH_LOGGING
and in the .m file it looks like this
#if STRIP_GTM_FETCH_LOGGING
+ (void)setLoggingEnabled:(BOOL)flag {
}
#endif // STRIP_GTM_FETCH_LOGGING
Also the class is generated by Google so...it should work (?)
Set as follows :
#define STRIP_GTM_FETCH_LOGGING 1
In the file that contains the following line of code:
[GTMHTTPFetcher setLoggingEnabled:YES];
Add the following importation:
#import "GTMHTTPFetcherLogging.h"
I just faced the same problem.
In my case, it was because I was using the GTMHTTPFetcher from the Google+ iOS SDK:
Adding required files to your iOS project (Point 2.)
I had set the header information as described (Copied below here for simplicity):
If you are using the Google+ iOS SDK, set up your Xcode project as follows:
In your Xcode project, go to the settings page for the target.
In the Build Settings tab, add the following item to Header Search Paths:
GOOGLE_PLUS_SDK_DIRECTORY/GoogleOpenSource.framework/Headers where
GOOGLE_PLUS_SDK_DIRECTORY is the directory where you installed the
Google+ iOS SDK.
(I have Google+ iOS SDK within my project so I am using: $(PROJECT_DIR)/MyProject/External/GoogleOpenSource.framework/Headers)
However to see the setLoggingEnabled method you will need to add -ObjC -all_load to Other Linker Flags