Bundle all local transient Swift Packages into a single xcframework - swift

I am developing a SDK and use SPM to modularise my code. All code is written in Swift.
My project structure is like this:
SampleApp (Workspace) -> SDK (SPM) -> ModuleA (SPM)
I can build and run the sample app locally successfully.
Now I want to archive/build the SDK package into a dynamic xcframework that my other clients can just drag and drop into their Xcode to consume.
I'm using xcodebuild -create-xcframework for that purpose and can successfully build a sdk.xcframework file.
But in a separated sample app where I embed the sdk.xcframework there, when import SDK module, I get this error
No such module 'ModuleA'
Failed to build module 'SDK' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
I assume here, this is because the compiler can't find ModuleA
Is there anyway that I can bundle the ModuleA into sdk.xcframework statically, so that my clients can just drag only sdk.xcframework into their projects to consume the SDK module?
The question is pretty much: How can I bundle ModuleA and SDK into a single .xcframework for distribution

Related

File '*.swift' is part of module 'Module'; ignoring import

I am faced with warning that actually does nothing for me in this case, but is a bit anoying.
The project is combined with several subprojects via Cocoapods, so the structure is
Root folder
Main project (that combines all the others and is used to deliver the build to the end-users. Imports Subproject 1, Subproject
2, Core)
Subproject 1 (dependent on Core, imports it via Podfile)
Subproject 2 (dependent on Core, imports it via Podfile)
Core project (independent)
Module.podspec (describes subspecs, let's assume it declares the name of the framework - Module)
The development happens in Subproject 1/2, and to use some Core classes I need to import Module to the swift file. And it works fine. Because the development happens in the project directly and Cocoapods assembles Module.framework based on Podfile imports and Module.podspec
But when I am building the project from Main project - the Subproject 1/2 and Core are all in the Module.framework. Thus, the xCode displays warning:
⚠️ File 'FileFromOtherSubModule.swift' is part of module
'Module'; ignoring import
Is there any way to handle it? I haven't found such a warning in clang flags

Cocoapods SwiftWebSocket in Xcode project - library is not found

I'm experimenting with SwiftWebSocket in Swift using Xcode 10.1.
I've added the pod via this podfile:
platform :osx, '10.14'
target 'ViewWebSocketLearning' do
use_frameworks!
pod 'SwiftWebSocket', '~> 2.7'
end
and I've loaded the pod as follows:
$ pod install
Analyzing dependencies
Downloading dependencies
Using SwiftWebSocket (2.7.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
which produces a workspace with the SwiftWebSocket project included in it. I compiled the projects and you can see that it is correctly compiling both my empty project and the SwiftWebSocket project properly. Everything is looking good so far.
However as soon as I try to include a reference to the SwiftWebSocket project in my project's unit tests, Xcode chokes. Here's a snip of my code:
import SwiftWebSocket
...
let ws = WebSocket("wss://echo.websocket.org")
I get "No such module 'SwiftWebSocket'". If I take out the import, I get "Use of unresolved identifier 'WebSocket'". So something isn't linking properly by the looks of it.
I've tried adding the compiled framework from the SwiftWebSocket project to mine in the project organizer on the left, no change. I've added it to the Linked Frameworks and Libraries in the target settings, again no change.
What am I missing?
I'm a relative novice to Xcode so apologies but I really would like to get past this point so your help is much appreciated! Thank you.
It's not exactly the solution I was shooting for, but I solved this by building a class in my project which contains the logic to control the SwiftWebSocket, then called that class from inside the unit tests.
Architecturally this is probably cleaner but I remain unclear on why I couldn't access the SwitfWebSocket directly from the unit tests.

library not found for -lswiftCoreFoundation for architecture x86_64

I have workspace contains subprojects and one of the subproject generates static lib which is linked to main project. I have created a swift in static lib subproject and I get below build error.
library not found for -lswiftCoreFoundation for architecture x86_64
Solution: Add one .swift file to application target and it works

Compiling greenDAO source

When I do a fresh git clone of the greenDAO repo, import the project with Android Studio, and try to compile, references to all the Android objects throw Unresolved Symbol/Method errors. Similarly, the Android specific import statements are also unresolved.
I've gotten as far as realizing that the build.gradle files don't call apply plugin: 'android', but instead lists dependencies like:
dependencies {
provided 'com.google.android:android:4.1.1.4'
provided 'com.google.android:android-test:4.1.1.4'
provided 'com.google.android:annotations:4.1.1.4'
provided 'com.google.android:support-v4:r7'
provided 'com.google.android:support-v4:r7'
...
}
I've used the SDK manager to make sure I have all the files for API v4.1 installed. I also know how to use greenDAO by using the Maven repos and/or importing JARs. My problem is specific to building from source.
Update 1: As stated, when using provided, none of the Android files are found.
I don't have enough reputation to post images, but you can find a screenshot here.

Getting "Unable to execute dex: Multiple dex files define" error when trying to run main project which is using other library project

I am trying use androidVNC open source project as a Library Project in my MainProject. androidVNC has also used ZoomerWithKeys library project. I want start a activity of androidVNC library project in my MainProject by clicking on a Button.
I have done all the basic things like to define all the activity of library project in Manifest of main Project.
The problem is that i am getting following error when trying to running my MainProject -
Dex Loader] Unable to execute dex: Multiple dex files define Lcom/antlersoft/android/zoomer/R$drawable;
[2013-05-16 15:44:03 - OtherProj] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/antlersoft/android/zoomer/R$drawable;
Thanks in advance.
I resolve this by doing following steps:
Go to bin folder of you app and see which libraries are duplicated(in mine I had 2 supportv4****)
Hold your mouse on them and see where they compile from, keep in mind that you should keep the most important one, so if you are using appcompat and facebookSDK, you should keep that library which comes from appcompat
Go to the properties of the project of the other library (e.g facebookSDK) -> Java build path -> Libraries and delete the dependency in which the buggy lib come from(in mine, supportV4 nested in Android Private Libraries, so I delete it),
Also do it from a file manager, go to our project folder/libs and delete that buggy library if it's not cleaned by default
In that window, after deleting, choose Add Jars... and select the library of the other project(in mine, I choose SupportV4 from appcompat)
Clean you workspace, restart Eclipse
The problem should have gone, these steps work more than fine for me
1).did you added your lib project to the main project?? Make sure..
2).also add the project to your lib project by doing this process--
In the lib project-->>right click on project-->>java build path-->>on the project tab-->>add your main project.
Now build your project..hopefully it will help you.
EDITED::
3). Go to the project properties..edit this(can give some space) and then save..clean project...then build..
I tackled with this kind error in Android Studio.
In my case my main project was using two my own lib. But beside this those two libs were using the same library as external included
compile files('lib/external-lib.jar')
I solved it by doing following in my both own libs.
1)Removing old compile files('lib/external-lib.jar' ) from build.gradle and deleting old external_lib.jar from lib folder.
2)Adding library from jcenter() two my own libs
compile 'external.lib:1.9.2'
3)Rebuild.
Then rebuild and run main project
Then problem has disappeared.