Compilation issues with Mix and Match Objective-C & Swift Cocoapod - objective-c

I'm working on a large mixed Objective-C and Swift codebase. I'm trying to move some of the code into a separate framework. This is going to end up being imported into the main project via a Cocoapod. The separate framework will end up having both Objective-C and Swift code.
So far I've moved all of the files for the new separate framework out of the main project and into a new folder. I've referenced these new files via a podspec and I'm importing them back into the main project as a development pod. All I'm trying to do right now is get this new framework to build on its own, I'm not trying to build it as part of the entire project yet.
The part I'm currently stuck on is, when it builds, in the MySplitOutFramework-Swift.h that it generates there is a a compilation error. The compilation error is on the line #import <MySplitOutFramework/MySplitOutFramework.h>. The error say 'this file cannot be found'.
What exactly am I doing wrong here? Is it some kind of circular dependency?

Related

Problems creating a NativeScript plugin that uses Objective-C code

I have followed the NativeScript documentation on adding Objective-C code to a NS project although I am struggling to call the Objective-C code in my iOS project. I am only trying to implement appPlugin.h and appPlugin.m files into my project.
My folder structure for the Objective-C files are as follows:
Project/app/App_Resources/iOS/src/...
I have also tried creating a NativeScript plugin that gets added to the dependencies in the projects package.json.
Are there any additional files that need to be added to make the Objective-C code compatible with the NS project. The documentation simply says run "If you run 'tns prepare ios' you will see that the files are now part of the project."
Link to the documentation I have been following:
https://www.nativescript.org/blog/adding-objective-c-code-to-a-nativescript-app
https://docs.nativescript.org/plugins/building-plugins
SOLVED: Files are added to the TNSNativeSource folder (Check in Xcode) and are available to use like any JS object.

How to include objectiveC dependency in a swift library

Xcode cannot find references to a obj-c library after adding the dependency to my library's Podspec file
I'm trying to write a flutter iOS plugin for the GVRAudioEngine. There are two parts to this:
The plugin implementation, which instantiates a native object--in this case a GVRAudioEngine instance--and a communication channel to the dart world. Dependencies for this part are defined in a Podspec file
A sample app that runs the plugin--for debugging and documentation purposes. Here is where a sample AppDelegate class would get implemented. Dependencies for this part are defined in a Podfile
I've been able to include the GVRAudioEngine as a Podfile dependency accessible from the sample app. For this I've had to create a header bridge.
However,I've so far not been able to access GVRAudioEngine from the library side i.e Podspec. I've added the dependecies, and tried creating a header bridge there, or checking the framework and header paths. I've not been able to get this to work.
Comparing this library to other libraries I do have access to, the only differences I've found so far are:
This one is written in objc
the framework is a .a file
I'm close to giving up. I'm a new iOS developer, so I fear there's something super obvious I'm missing.
I've added the following lines to my Podspec file.
s.dependency 'GVRKit', '1.140.0'
s.dependency 'GVRAudioSDK', '1.140.0'
s.static_framework = true
I expect to be able to declare a field of type GVRAudioEngine in my Podspec library. But Xcode complains that the type is undeclared

In a mixed objc/swift module, Xcode always tries to include the module itself

This one is not easy to explain, but is also very annoying.
I'm working on a Cocoapods framework (in development mode) with objc and swift sources. Let's call it the "SuperCompoment" framework
Xcode auto generates the SuperComponent-Swift.h file, to make Objc classes visible from Swift ones.
Some Objc classes also includes Swift classes.
At compile time, in the SuperComponent-Swift.h, Xcode adds the line
#import <SuperComponent/SuperComponent.h>
... and fails to compile with the message: SuperComponent/SuperComponent.h file not found
Xcode tries to include the framework inside the framework itself!
If I manually edit the auto-generated file by commenting the #import, the project compiles perfectly. But Xcode auto-generates the file after each clean and before archiving the project!
Any clue?
I don't know why Xcode automaticaly adds the #import <SuperComponent/SuperComponent.h> line (since it do work without it), but if i'm kind with him by adding an empty SuperComponent.h file at the root of my framework, it compiles gracefully.

PojectName-Swift.h Not found while using Both Swift and ObjC codebase

I had a perfectly working ObjC project integrated with Apple WatchKit App with Multiple Targets. Only one of the Targets is linked with the WatchKit App.
I am moving my classes to swift and hence there are ModuleName-Swift.h files being used in my code.
Followed steps given in ModuleName-Swift.h file not found in xcode8 and I have ensured to add the “$(PROJECT_NAME)-Swift.h” under Projects > Build Settings > Objective-C Generated Interface header name.
But when I go to the build settings - it shows as Objective-C generated interface header name for the project target and Swift_ObjC_Interface_header_name for WatchKitApp Target
Error thrown by compiler : ProjectName-Swift.h file Not found
Is this causing the error? Not sure what I am Missing.
This is how I've linked the -swift.h files in Other targets
The issue was:
There were Unit test cases that were failing, disrupting further Compiling of the Project
Quick Fix:
The ObjectiveC Classes had Unit test cases associated with it.
Some of the Unit tests were failing due to changes to the main code base.
I had to uncheck the the following under Edit Schemes > Build so that they don't Build while running the WatchKit App.
I agree I will have to update the test cases to work with the Updated app, But the issue of Watch App not working is Fixed! :)

Can't Find Framework .h File

I downloaded Andy Potion's "PFLetsMove" framework here and added the Xcode Project to my application's project. I then dragged the framework from that to the Link Binary with Libraries and Copy Files build phases.
Now, if I compile the application with a call to PFMoveToApplicationsFolderIfNecessary() it works fine, so the framework is definitely there. But if I put the line #import "PFLetsMove/PFMoveApplication.h" in the app delegate, I get the following error: 'PFLetsMove/PFMoveApplication.h' file not found.
I've checked the compiled PFLetsMove.framework in the build folder, and PFMoveApplication.h is there. I did the exact same thing with the AquaticPrime framework (import the header) and it works fine. Where am I going wrong here, or is there potentially an issue with how the framework is built?
If you use a framework, you put the file name in angle brackets (i.e. <FrameworkName/FileName.h>), if it's a local file, you use quotes (i.e. "FileName.h"). Note that even if the source file is in a group or subfolder, it is not referenced as such.