We are trying to build a KMM (Kotlin Multiplatform Mobile) app for ios and android. There are c/c++ modules included in this project.
At iOS build we are getting this error from a .h file:
error: use of '#import' when modules are disabled
In xcode this seems like an easy problem to fix, but in Android studio, we can't find a solution. I'm thinking this is a Podfile/.podspec issue, but I haven't been able to find any working solution.
instead of :
#import MyModule;
just try :
#import <MyModule/MyModule.h>
Related
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;
I want to import a library from native C source code to be used Unity, for iOs. I expect to require the .a binaries and the .h header (and any other file required if I'm missing any), but I cannot find any guide around about how to build it.
I tried to build the source code directly on Xcode, but I was not able to create a library from that. XCode accepts native C only with command line project, while I need a library.
Then I tried to run this CMake command on mac terminal:
cmake . -DCMAKE_SYSTEM_NAME=iOS "-DCMAKE_OSX_ARCHITECTURES=arm64;arm64e" -DCMAKE_OSX_DEPLOYMENT_TARGET=9.3 -DENET_STATIC=1 -DENET_LZ4=1 -GXcode
This creates an Xcode project, I build it for generic IOS but the code does not work on unity when I deploy it on the device.
A good place to start is the Bonjour example from the Unity Manual. This at least gives you a working iOS plugin as a starting point.
You include the files in your Unity project, and build for iOS. You will notice that the files under Plugins/iOS are automatically included in the generated Xcode project. They will only be compiled when you build/run your Xcode project.
Careful, an iOS plugin is not the same as a MacOS plugin. For a MacOS plugin, you will need to create the bundle and include this into your UnityProject. The DllImport decorator will also be different on your C# code. For iOS it is "__Internal", but for MacOS it is the name of the bundle.
If you are trying to interface with a third party library, you may need to manually modify the library search paths of your Xcode project to correctly locate your .a and .h files when building and linking.
As a side note, when including a third party .a binary, verify that it conforms to the iOS architecture requirements, otherwise your app may be rejected when submitting to the app-store.
I am preparing a SDK in objective framework, i added a file and imported a "FileName.h" but it giving me an error of file not found.
Any suggestion will be greatful
Are you able import the framework in your project. If YES, check
Framework Search Paths in Build settings.
Example: $(PROJECT_DIR)/xxxxxxxx/GoogleSignIn\
Add your framework inside
Embedded Binaries
I have been trying to create a git repo with my framework and trying to distribute it using pods. I have written a podspec which downloads all the dependencies as well as my framework. The pod functions properly. I even imported the framework to the appDelegate of the sample project to test its functionality.
Now when I am using a class of that framework I am getting the following error
'MyClass' is unavailable: cannot find Swift declaration for this class
I have tried to build the project for both simulator and iPhone, but the result being the same.
Does anyone has insight on this one?
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