libsqlite in simulator and iOS compiling - ios

I'm having some issues when compiling my app to iOS.
I'm using sqlite3 and imported as
#import <sqlite3.h>
Well, I only found a file named libsqlite3.0.dylib in my Mac and I copied it to my project.
When I compile it for iOS Simulator, it works just fine. However, when I try to compile the app for iOS Device, it throws an error (Apple Match-O Linker Error) in every call I do in my implementation to sqlite's function (such as _sqlite3_open, etc.)
How can I compile it to iOS Device?
Thank you!

Instead of simply copying the library, do it like this:
in Xcode Navigator, click on your target (the upmost entry)
go to Build Phases, then Link Binary With Libraries
add the libsqlite3.dylib from it's location at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSxx.sdk/usr/lib/

Just in case someone faced that same problem as me. If you are unit testing your code, add the lib file also to your test target.

Did you try to import sqlite3 library like:
#import "sqlite3.h"
instead of:
#import <sqlite3.h>

The best way that I have found to use SQLite in your IOS application is to build your own copy of the SQLit library and include it in your project. libsqlite3.0.dylib is a very old copy of SQLite.
You can easily download the SQLite Amalgamation source code and build it for IOS. this gives you the latest SQLite source code that has all the latest bug fixes and improvements.
If you can open Xcode and create a new static library project, then you are 75% of the way there.
Once you have the static library project, include the SQLite sources that you downloaded from the SQLite Amalgamation and set a few Preprocessor options and your off and running with the latest code.
For complete details and sample source code you can visit my blog conedogers

Related

Xcode AFHTTPSessionManager.h file not found

I'm a newcomer to Xcode and native iOS development, having had previous experience on Android native and React native. I inherited an Objective-C codebase for an iOS application, which has not been touched for about 2 years. I tried to build the project on an iOS simulator, but I encountered this error during the build.
I have seen quite a few posts on StackOverflow where "xxxx.h" file is not found, however, I was unable to find a definitive solution. As you can see in the screenshots below, the AFHTTPSessionManager.h file is indeed in the Pods folder, however, for some reason, the header file just cannot be found.
What I have tried is to add the full path of where the file is found into the Header Search in the build settings for both the project and the pods directory.
Some help is very much appreciated so I can start working on the project. Thank you!
When you're importing files inside your module/framework, you use #import "file.h"
But when you need to use an instance defined in an other framework, you can't do that. You need to import that framework header file, in this case #import <AFNetworking.h>, or #import AFNetworking;

Polidea ios-class-guard is DEAD in XCode 7, replace it or fix it?

Everything is great before XCode 7 and iOS 9. After we upgrade XCode to 7.0 and 7.0.1, the ios-class-guard keep annoying us.
You can't install ios-class-guard based on the official tutorial. The homebrew is failed to install formula.
The following build commands failed:
CompileC /Users/Digiflex/Library/Developer/Xcode/DerivedData/ios-class-guard-afpnixzupjudctebfxyqptpmbgpa/Build/Intermediates/ios-class-guard.build/Release/MachObjC.build/Objects-normal/x86_64/CDLCSegment.o Source/CDLCSegment.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Then, we download source code from Polidea/ios-class-guard. After we fixed couple bugs, and compiled it. We archived build and export to
/usr/bin/ios-class-guard
When we do the obfuscation, it looks OK. But when we run project in XCode 7, we got many errors like:
Unexpected '#' in program
or
Missing context for method declaration
After many hours research with no conclusion, our question are:
How to fix the ios-class-guard problem by myself, under XCode 7 environment?
Is there any other open source project provide a similar feature, which is can obfuscate Class, Method and String?
There is new version (0.8) of iOS Class Guard with Xcode 7 support.
I succeeded to fix errors like this by replacing
#import <Foundation/Foundation.h>
with:
#import UIKit;
In my project .pch file.
Then I also changed in my project build settings:
Enable modules (C and objective C) to YES
However I end up having the same problem for imports of classes in the .pch file:
#import "BDError.h"
The latest version of iOS Class Guard (0.8, as of this writing) still has issues with Xcode 7.3, and didn't fully fix support for prior versions of Xcode 7.
How to fix the ios-class-guard problem by myself, under XCode 7 environment?
Starting with Xcode 7, the iPhoneOS SDK that ships with Xcode does not include the ARM-based .dylib dynamic-library files anymore, and these have been replaced .tdb files. The .tbd files appear to be markup (text) files describing their corresponding .dylib files, specifically including at least some of the symbols. The errors you see are because of this change.
The consequence of this is that in order to obfuscate an ARM-based build, the symbols to exclude can only be found by examining the iPhone simulator libraries. Currently, this implies that an x86/x86_64 build must be created for the analyze phase of building.
According to "apple staff":
"For those who are curious, the .tbd files are new 'text-based stub libraries', that provide a much more compact version of the stub libraries for use in the SDK, and help to significantly reduce its download size."
These .tbd files do not contain all the necessary symbols, for automatically finding excludes, though.
iOS Class Guard 0.8 fixed the error messages, but in such a way that it wasn't finding all the symbols that should be excluded.
Is there any other open source project provide a similar feature, which is can obfuscate Class, Method and String?
Yes, PPiOS-Rename is a fork of ios-class-guard that fixes this issue, by always searching for symbols in the iPhoneSimulator SDK, even if the build was compiled for a device. It has also been updated to work with Xcode 7.3. (Full disclosure: I work for PreEmptive Solutions who created this fork, but it is open source and free.)

iostream not found in Xcode

I have problem including ZXing in my App. I get error: "iostream file not found".
I have done everything like in ZXing instruction but i can't get this working.
I'm including this in .mm file.
I use story boards this project is for iOS 6.0
This is error i get:
In file included from
/Users/adam/Developer/project/project/SecondViewController.mm:11: In
file included from zxing/iphone/ZXingWidget/Classes/QRCodeReader.h:10:
In file included from
zxing/iphone/ZXingWidget/Classes/FormatReader.h:22:
zxing/cpp/core/src/zxing/common/Counted.h:23:10: fatal error:
'iostream' file not found
Any idea what can i do to get this working?
EDIT:
When i select Compile Source File As Objcetive-C++ project comiples without issues, BUT as i was told this is not god soultion beacuse this can make some problems later on with other parts of app.
Just rename your implementation file with .mm extension instead of .m solve the issue.
Project -> Build Settings -> Apple LLVM compiler 4.1-Language -> C++ Standard Library
Make sure to set that to "libstdc++"
Try to create a new project, and choose "command line tool" as the template for your project. Choose C++. Paste your code into the new project (it should be a .cpp file). When you run the program, it should be able to include iostream without any problems.
Just a tip: be sure the implement file extension is .mm
placing #import "QRCodeReader.h" in the mm-file instead of it's header-file fixed the issue for me

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.

Using DCMTK in iOS application

I want to use DCMTK in my application and have successfully compiled DCMTK 3.6.0 for the iOS Simulator. Then I created a workspace into which I added the DCMTK project and my application. I added the .a files as target dependencies and linked the binaries. I think I am missing the part where I have to set the header/library search paths. I try to include a header file say #include "dcm2xml.h" and it says file not found. What am I doing wrong?
I have seen this. -> How to use DCMTK in an iPhone project But I think there's a simpler way without using that framework.
you can find some info on how to compile dctmk for ios and simulator here,
and from here you can download a demo project which make use of the dcmtk. It will not display the image but will print the information found in some tags found in the file. I hope it will help you start.

Resources