Underlying Objective-C module not found for target Framework - swift

I am trying to create a framework that has a dependency to an external library (cordova). The framework is mainly in Objective-C with some Swift 3.x files (cordova plugins) and the linked external library in objective-C.
I have created an Umbrella header in order to avoid the bridging-header error for frameworks. I have also created a module.modulemap in order for the swift files to have access to the external Objective-C library (cordova).
This setup used to work when in Swift 2.3 and compile with no problems. After a recent xCode update, Swift 3.x is mandatory so I updated all the swift files to the latest version. After this update, all my swift files seem to not have access to the objective-c files, also located in the same project/target.
Now I'm getting the Underlying Objective-C module <moduleName> not found Error and a lot of Use of Undeclared type error messages.

As noted in the comments, renaming module.modulemap to nameofthemodule.modulemap fixed the problem.

Related

Failed to build module 'XXX' from its module interface while creating xcframework

Currently I am working in a framework project to distribute to a client we have. The Framework has SPM dependencies and I wanted to create an XCFramework from it. I found the scripts to archive and generate the XCFramework with the xcodebuild tool. The problem is that the generation is not working and I get the following error Failed to build module 'XXX' from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced. I don't know if it is possible to build a framework with SPM dependencies as an XCFramework I was trying to distribute it as binary framework to protect our source code. I previously looked for this but couldn't found any information in the matter. Can somebody help me?
One solution seems to add #_implementationOnly import for the modules from the third-party SDKs. This should fix your XCframework error if you aren't using anything from that SDK as part of your module's public interface.

Compiling unsupported module into Linux-based Swift project

I need to import the Apple GameController framework for a server-side Swift project running on Linux (where that framework is unsupported). I do not need the GameController functionality, which used by my code on other platforms - I just need to get my project to compile so I can use the unrelated parts of the code base.
What is the best approach for handling this situation?

Getting Realm Version in Code

Two part question:
How does one get the currently installed version of Realm in code? Swift 3, macOS. I was unable to location any Realm.version property - perhaps I overlooked it.
In a related question
What is the solution to upgrade Realm to the latest version within a project? After updating CocoaPods to the latest, and refreshing, pod install doesn't appear to update Realm. I have 2.0.3 installed and 2.2.0 is available.
If you're embedding Realm Swift as a dynamic framework directly, the version number is contained in the framework's info.plist file. It should be possible to access the plist during runtime; there's a few answers on SO discussing this.
Since CocoaPods creates dynamic frameworks for Swift, the above approach of accessing the info plists should work, but if it doesn't there might be other ways to access versions of pods.
In any case, I would definitely recommend you review why you're wanting to check the version numbers of your libraries. It's better practice to check a framework's capabilities at runtime (eg, testing a class you need exists etc) than to directly use the version number.
For your second question, you need to run pod update RealmSwift to get CocoaPods to check for an updated version of Realm.

Could Not Build Objective-C Module BranchInvite

I've installed the BranchInvite framework as a pod, it's up to date. My project even recognizes, and tries to autocomplete, the module when I try to import it but the throws the error Could Not Build Objective-C Module BranchInvite
This post, the only one I could find, did not solve the problem as I tried to import each piece in my bridging header: Swift 'Could not build Obj-C module 'BranchInvite'
I've uninstalled, reinstalled the pods. No dice. I'm running Xcode 7.1 and Swift 2.1, is this a generic issue or what could be possible work arounds/solutions?
On a side note, I would love to not have to do all of the UI and wiring involved in sending in-app invites. I can and I will but it would be a huge time saver not to. That's one of the reasons Branch was so appealing. If there aren't any solutions are there any other deep-link services that also offer out-of-the-box UI?

error: include of non-modular header inside framework module for cocoapods spec

I saw the similar issue in stackoverflow, and add --use-libraries after pod spec lint. It just says
[!] Pods written in Swift can only be integrated as frameworks; this feature is still in beta. Adduse_frameworks!to your Podfile or target to opt into using it. It very strange.
My question is how to create a framework which is written in objective-c and swift, and create a private cocoapods repository. I cannot create a correct .podspec because I use objective-c bridging header in framework, and pod spec lint always tell me error: include of non-modular header inside framework module. This makes me gonna be crazy...
I also post this issue in detail in github:
https://github.com/CocoaPods/CocoaPods/issues/3666
If anyone knows how to fix it, I'll be very appreciate for you. Thanks a lot!