Xmppframework could not build module libxml - ios

On DDXMLNode.h
My project import XMPPFramework by cocoapods ,like:
pod 'XMPPFramework', '~> 3.6.6'
I find some way like:
1.header search paths add "$(SDKROOT)/usr/include/libxml2"
2.Other Linker Flags add "-lxml2"
3.Framework Search Path add "/usr/lib/libxml2.dylib"
All not working!

Instead of changing path of the files, you can do what I have done to resolve my error in Xcode 7.2 beta. First check if you have file libxml2.tbd framework and libresolve.tbd framework; if not then add it to you project and replace few things:
#if !(TARGET_IPHONE_SIMULATOR)
//#import dnssd;
#import <dns_sd.h>
#else
//#import dnssdSimu;
#import <dns_sd.h>
#endif
Second thing you have to do is replace this one:
#if !(TARGET_IPHONE_SIMULATOR)
//#import libxml;
#import <libxml/tree.h>
#else
//#import libxmlSimu;
#import <libxml/tree.h>
#endif
This resolved my problem.

Ok, I'll say get down to business. I use Cocoapods at the beginning, everything goes well and do not configure something, but because of the need to modify the source code to meet certain requirements, so manually add XMPPFramework, but encountered all sorts of issues.
The First : Modlue 'libxmlSimu' not found
In order to solve this problem, I did two things:
Download the file https://github.com/robbiehanson/KissXML/blob/master/libxml/module.modulemap
and import to your project. Like this:
Configure Build Settings - Header Search Paths, like this:
The Second : Module 'KissXml' not found
By replace #import KissXml; to #import "DDXML.h"

Related

How to fix the Xcode path error

In the AFNetworking's sample code, I use several folders to classify the source codes.
And the Xcode reports:
/Users/.../Framework/AFNetworking.h:19:9: 'AFNetworking/AFURLRequestSerialization.h' file not found
/Users/.../AFNetworking-master/Example/Classes/Networking Extensions/AFAppDotNetAPIClient.h:4:9: While building module 'AFNetworking' imported from /Users/dengjiangzhou/Documents/源码/2_AFNetworking/AFNetworking-master/Example/Classes/Networking Extensions/AFAppDotNetAPIClient.h:4:
/Users/.../AFNetworking-master/Example/:1:9: In file included from :1:
And
Here is the code:
In the AFNetworking.h file
#import <Foundation/Foundation.h>
//! Project version number for AFNetworking.
FOUNDATION_EXPORT double AFNetworkingVersionNumber;
//! Project version string for AFNetworking.
FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <AFNetworking/PublicHeader.h>
#import <Availability.h>
#import <TargetConditionals.h>
#ifndef _AFNETWORKING_
#define _AFNETWORKING_
#import <AFNetworking/AFURLRequestSerialization.h>
#import <AFNetworking/AFURLResponseSerialization.h>
#import <AFNetworking/AFSecurityPolicy.h>
#if !TARGET_OS_WATCH
#import <AFNetworking/AFNetworkReachabilityManager.h>
#endif
#import <AFNetworking/AFURLSessionManager.h>
#import <AFNetworking/AFHTTPSessionManager.h>
Error occurs in the last line.
And I didn't change any code. I just organized the files to check the functions of each module easily.
Maybe insert a file name in the search path of Xcode build settings, is quite OK.
I have not figured it out.
Many Thanks in advance.
You should remove AFNetworking/ from import line and use
#import ""
instead of
#import <>
Go to Build Phases -> Open Headers section -> Move files from Project to Public.
Try this:
Select AFURLRequestSerialization.m
Go to the right tab in the Xcode. Find Target Membership. Uncheck and check again all the boxes.
Product > Clean
Hold Alt and perform: Product > Clean Build Folder...
Build again.

Why import .m file?

I have a source file, well actually it is a Google API library.
It has this code on GTLCommon_Sources.m:
#if defined(__has_feature) && __has_feature(objc_arc)
#error "This file needs to be compiled with ARC disabled."
#endif
#import "Objects/GTLBatchQuery.m"
#import "Objects/GTLBatchResult.m"
#import "Objects/GTLDateTime.m"
#import "Objects/GTLErrorObject.m"
#import "Objects/GTLObject.m"
#import "Objects/GTLQuery.m"
#import "Objects/GTLRuntimeCommon.m"
#import "Objects/GTLService.m"
#import "Objects/GTLUploadParameters.m"
#import "Utilities/GTLBase64.m"
#import "Utilities/GTLFramework.m"
#import "Utilities/GTLJSONParser.m"
#import "Utilities/GTLUtilities.m"
However, try to build it, results on duplicate symbols on GTLCommon_Sources and GTLJSONParser. I tried change the source file to #import "Utilities/GTLJSONParser.h" instead of #import "Utilities/GTLJSONParser.m" and the duplicate symbols error goes away.
Can anyone advise why this library imports a .m file? While AFAIK, we always import .h file.
It's just a convenient way to build all the source files without having all of them included in your project. See the documentation.
Rather than link to the GTL framework, you can compile the GTL library
sources directly into your own project. To do this, find the library's
GTLCommon_Sources.m and GTLCommon_Networking.m files, and drag the
files into your project's window.
Then add the library's source folders to the Header Search Paths entry
of your project's build settings: Source, Source/Objects,
Source/Utilities, Deps/gtm-session-fetcher/Source,
Deps/gtm-oauth2/Source, Deps/gtm-oauth2/Source/Touch (or
Deps/gtm-oauth2/Source/Mac).
For that to work, do not add any other of the other sources (GTLBatchQuery.m, etc.) to your project.

Chartboost and swift integration

Ok, this is the first time I am trying to integrate chartboost and swift, so I will start from the beginning, maybe I missed something. First I have imported chartboost framework into my project, and then manually created the .h file, which I named BridgingHeader.h I added the needed import statements so that file looks like that now:
#ifndef appname_BridgingHeader_h
#define appname_BridgingHeader_h
#import <Chartboost/Chartboost.h>
#import <Chartboost/CBNewsfeed.h>
#import <CommonCrypto/CommonDigest.h>
#import <AdSupport/AdSupport.h>
#import <UIKit/UIKit.h>
#endif
I tried to build, everything went fine, but I noticed that it does not actually import this file. Hence I went to my project build settings, located Swift Compiler - Code Generation and found Objective-C Bridging Header and named it as appname/BridgingHeader.h . Now I am sure it did find the file and tried to import chartboost files, because I got 56 errors, of which all are in the chartboost files. Erros are such as "function definition is not allowed here" or "expected a type". The last error says that it failed to import bridging header. Anyone knows or has any ideas how to make this work?
Thanks
Ok, I my problem.
1) UIKit import should be done as follows:
#import <UIKit/UIKit.h>
#ifndef appname_BridgingHeader_h
#define appname_BridgingHeader_h
#import <Chartboost/Chartboost.h>
#import <Chartboost/CBNewsfeed.h>
#import <CommonCrypto/CommonDigest.h>
#import <AdSupport/AdSupport.h>
#endif
2) for the path, I should just went to the bridging file, in the file inspector copy the full path and paste it in the Swift Compiler - Code Generation.

Using RestKit in Swift

I have successfully added 'RestKit' pod into my project and also followed steps described in this article: Cocoapods in swift. I imported the RestKit into my ViewController class's source file:
import RestKit
But I don't know why I can't access it. It doen't show any of the classes in the RestKit. It shows:
'RestKit' No such module exists.
I tried again creating a new project and added 'RestKit'. and created a bridging header and imported 'RestKit' into ViewController claas's source file. Now i run the project
it shows errors like
// in this file Pods-SOCKit-prefix.pch
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "Pods-environment.h" // Pods-environment.h file not found
// and also in this file Pods-TransitionKit-prefix.pch
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "Pods-environment.h" // Pods-environment.h file not found
If someone knows what's the problem behind this, please explain it to me, and suggest a way to work with RestKit in Swift.
I'm not sure what the Cocoapods problem you are having. I added RestKit to my bridging header and didn't need to add import RestKit to my Swift file.
My bridging header looks like the following:
# if you are using Core Data:
#import <CoreData/CoreData.h>
#import <RestKit/RestKit.h>
# if you are using Core Data:
#import <RestKit/CoreData.h>

OpenCV compiler error when using Stitcher under iOS

Whenever I try to use the OpenCV Stitcher class in iOS and I include the stitcher-header ( #include ) I end up with a compile error "Expected '{'" in exposure_compensate.hpp. Apparently the line
enum { NO, GAIN, GAIN_BLOCKS };
is causing some sort of error.
I am very new to openCV but using other functions like filter2d() work as expected. How can I resolve this?
Try
#import <opencv2/opencv.hpp>
then
#import <UIKit/UIKit.h>
Update: this answer only highlights the bare minimum fix of the problem, and perhaps the root cause: order of dependencies. Please refer to other answers for better code / setup that you put in your project.
In your project, create a Prefix Header, MyProject.pch, and set it in your project's build settings.
Then within that pch file, do something like this:
#ifdef __cplusplus
# include <opencv2/opencv.hpp>
# include <opencv2/stitching/detail/blenders.hpp>
# include <opencv2/stitching/detail/exposure_compensate.hpp>
#else
# import <Foundation/Foundation.h>
# import <UIKit/UIKit.h>
# import <Availability.h>
#endif
I also ran into this problem. As G. Führ ensure you include the opencv headers first. The easiest way to do this is add:
#ifdef __cplusplus
#include <opencv2/opencv.hpp>
#endif
near the top of the apps "Appname-Prefix.pch" header. This is a precompiled header and makes it easy to guarantee that your opencv header will be included before any of the apple headers.
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __cplusplus
#include <opencv2/opencv.hpp>
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
This means you won't accidentally include an apple header before this anywhere else in the app.
I had a similar issue and I solved editing directly the opencv-framework files involved (in your case compensate.hpp) and comment from them the definition of the NO enum case definition. In this case the file was blender.hpp, but compensate.hpp has the same structure
Hope this helps
I solved this issue by importing any Apple headers before those of OpenCV, as mentioned in the beginning of the header:
#if defined(NO)
# warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
#endif
Hope that helps.
In my case, I create a vertical image stitching app with openCV, error show as screenshot below. It is from exposure_compensate.hpp and blenders.hpp. From the error description, the top file is ../CVWrapper.mm, which is in my project instead of openCV pod project.
As above guys said, there is some conflict issue between C++ and Apple MACRO. And we should put C++ header above Apple header.
First, I try a workaround from internet, which said "replace NO with NO_EXPOSURE_COMPENSATOR = 0". This worked, but it modified openCV source code, I don't want to do that because I will not do version control on Pod files, then if other guys clone my repo/project, they will need to do the same modification on those source code.
Then, I follow the error message in Xcode, I did following changes in my CVWrapper.mm file. After that, those two error disappear.
// Before change
#import "CVWrapper.h"
#import "UIImage+OpenCV.h"
#import "stitching.h"
#import "UIImage+Rotate.h"
// After change
#import "stitching.h"
#import "CVWrapper.h"
#import "UIImage+OpenCV.h"
#import "UIImage+Rotate.h"

Resources