class method +setLoggingEnabled: not found - ios

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

Related

Could not build Objective-C module 'mupdfdk'

I'm trying to add mupdf framework to a swift project. I created a new project and copied the mupdfdk.framework to my project and referenced it in the frameworks section. Following is a screenshot of the documentation.
Now my project looks like this.
Then when I try to import it in viewcontroller, I get Could not build Objective-C module 'mupdfdk' error. Are there any other steps I'm missing? Please help.
You need to add this bridging header:
MuPDF-Bridging-Header.h
#ifndef MuPDF_Bridging_Header_h
#define MuPDF_Bridging_Header_h
#import "mupdfdk.framework/Headers/mupdfdk.h"
#endif /* MuPDF_Bridging_Header_h */
and declare it within the Swift Compiler section of the Build Settings:

Auto Generated -Swift file not able to add <MessageUI/MessageUI.h> Framework

I am working on a project where the code is in Objective-C & Swift 3.2,
I am sending mail from Swift file where I need to extend MFMailViewControllerDelgate
but when I Build project I get an error
Can not find protocol declaration for 'MFMailComposeViewControllerDelegate'
at Swift Header file
in below code part
#interface EmailManager (SWIFT_EXTENSION("targetname"))
<MFMailComposeViewControllerDelegate>
- (void)mailComposeController:(MFMailComposeViewController *
_Nonnull)controller didFinishWithResult:(MFMailComposeResult)result
error:(NSError * _Nullable)error;
#end
To resolve error I edit swift header file & add Manually <MessageUI/MessageUI.h>
And everything works fine.
but When new changes are made in Project or ad new Swift file this auto-generated file get reset & I get an error again.
please suggest some permanent solution
FYI:
In Auto generate file there is #import MessageUI
In Build Setting there is MessageUI in Framework
In Build Setting Define Modules set to YES
ignore target name in the code snippet

Where should I set KApiKey, KApiSecret, KToken and KURL in iOS SDK?

I am integrating my application code with Payeezy iOS SDK. but could not find the file to set KApiKey, KApiSecret, KToken and KURL
#define KApiKey #"test_apikey_bA8hIqpzuAVW6itHqXsXwSl6JtFWPCA0"
#define KApiSecret #"test_apitsecret_YmI4YzA1NmRkZmQzMzA1ZmIZjYzwMWIzZThkMWU2NGRjZmI4OWE5NGRiMzM4NA=="
#define KToken #"test_merchant_token_fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6"
#define KURL #"https://api-cert.payeezy.com/v1/transactions"
Please let me know the file name to set the parameter ? do you have any application that I can use for Authorize Capture and Purchase void ?
Either put them in a file that needs them, or if you want it throughout the app, you would put them in a prefix header.
To create a precompiled header, first make a .pch file, add those defines, and follow this to add the pch to your project.
You can set these parameters in the ViewController.m file in the payeezy sdk. You can also do it in the client specific .m file if you are doing custom implementation.
Initialize PayeezySDK object with KApiKey, KApiSecret, KToken and KURL like below
// initialize Payeezy object with key,token and secret value
PayeezySDK* myClient = [[PayeezySDK alloc]initWithApiKey:KApiKey apiSecret:KApiSecret merchantToken:KToken url:KURL];
Following is the link to the payeezy integration for ios
https://github.com/payeezy/payeezy_ios/blob/master/guide/payeezy_iOS_SDK042015.pdf

Using an Obj-C sub-project in a Swift application

My team has a few full Obj-C libraries we like te reuse in our projects. To do so, we usually set up a git submodule, and then add it to the xcode project as a sub-project (Using target dependency, link binary with library and updating the User Header Search Paths)
So far it's only been done in full Obj-C projects, and I'm now trying to use it in a Swift project but with very little success so far. I tried to add the briding-header file, referenced it in the project and filled it like so :
#import "MyLibraryHeader.h"
With the target header being in the User Header Search Paths.
It lets me build, but when using it in my Swift files:
let test = MyLib();
let secondTest = MyLib.classMethod1("some_arguments");
I get an EXC_BAD_INSTRUCTION on secondTest, and the following logs in the debugger:
(lldb) po test
error: <EXPR>:1:1: error: use of unresolved identifier 'test'
(lldb) po secondTest
error: Error in auto-import:
failed to get module 'MyProject' from AST context:
/Users/siegele/Sources/MyProject_iOS/MyProject/Classes/MyProject-Bridging-Header.h:12:9: error: 'MyLibraryHeader.h' file not found
#import "MyLibraryHeader.h"
^
failed to import bridging header '/Users/siegele/Sources/MyProject_iOS/MyProject/Classes/MyProject-Bridging-Header.h'
Found the following question with no answer : Xcode 6 crashing when using Objective-C subproject inside Swift
Any help would be appreciated.
I followed the HockeyApp tutorial that can be found here:
http://support.hockeyapp.net/kb/client-integration-ios-mac-os-x/integrate-hockeyapp-for-ios-as-a-subproject
In the end, I was on the right tracks but messed up the Header Search Paths:
Add subproject xcodeproj to the workspace
On the main project : Link binary with library, and add the subproject product library (Bonus points : add it as a target dependency too)
Update Header Search Paths (not User Header Search Paths) accordingly
Import your Library.h in the main project Bridging-Header.h file
What threw me off for a while is that the Swift Compiler setting for the Objective-C Bridging Header was not set automatically. Check the Build Settings for your target and ensure the "Objective-C Bridging Header" setting is not blank.

Using Dropbox, or any third party, framework in Swift class

I'm trying to write a swift class that uses the Dropbox Sync API, but can't get swift to see the framework. The objective C in my project can use the Dropbox framework successfully. I have a bridging header that seems to be properly set up in the project settings and references <Dropbox/Dropbox.h>. But in my swift file it is as if I have done nothing.
This objective C code in my project works and is what I am trying to replicate in Swift:
#import <Dropbox/Dropbox.h>
...
if ([DBAccountManager sharedManager].linkedAccount == nil) {
[[DBAccountManager sharedManager] linkFromController:self];
[[DBAccountManager sharedManager] addObserver:self block:^(DBAccount *account) {
DBFilesystem *fileSystem = [[DBFilesystem alloc] initWithAccount:account];
[DBFilesystem setSharedFilesystem:fileSystem];
}];
As I said, I have <Dropbox/Dropbox.h> in the bridging header that Xcode automatically created for me. However this swift code fails to compile with the error 'Use of unresolved identifier 'DBAccountManager''
import UIKit
class PiecesListTableViewController : UITableViewController {
override func loadView() {
super.loadView()
// This fails with unresolved identifier 'DBAccountManager'
let accountManager = DBAccountManager.sharedManager
// As does this
let accountManagerNew = DBAccountManager(appKey:"", secret:"")
}
}
Any thoughts on how to get my swift code to be able to see the Dropbox framework?
I didn't manage to solve this. Instead I worked around it by abstracting all use of the Dropbox framework into objective C classes and using those in my swift code.
Actually I found the way to do it:
Create a dummy .m file so that XCode will ask you to create a bridging header, then delete the .m
Under project Build settings, add DropboxSDK.framework under Link Binary with Libraries
Open the bridging-header file and write in it #import <DropboxSDK/DropboxSDK.h>
XCode won't compile your code, and SourceKit Service will likely crash every time you'll open up a Swift file.
That's because of two errors in the Dropbox SDK (at least for a Swift environment):
Open the DropboxSDK.framework you linked before in Finder, then navigate to Headers folder
Open the file DBQuota.h and add #import <Foundation/Foundation.h> before #interface
Open the file DBSession+iOS.h and add #import <UIKit/UIKit.h> before #interface
Now you can use Dropbox SDK classes in your Swift files.
This will save you from creating an Objective-C wrapper on each class.

Resources