Exporting public C headers with SwiftPM - swift-package-manager

I have an open source Objective C framework, which I'd like to provide using Swift Package Manager as well.
Normally, I have public headers set in the Xcode project, which, when the framework is built, are copied under the framework bundle, and are discovered when linked to by Xcode.
I can't, however get it to work with SwiftPM.
I created a modulemap for my framework:
framework module LNPopupController {
umbrella header "LNPopupController.h"
export *
module * { export * }
}
and I define the library like so in the Package.swift:
let package = Package(
name: "LNPopupController",
platforms: [
.iOS(.v12),
.macOS(.v10_15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "LNPopupController",
type: .dynamic,
targets: ["LNPopupController"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "LNPopupController",
dependencies: [],
path: "LNPopupController",
publicHeadersPath: ".",
cSettings: [
.headerSearchPath("."),
.headerSearchPath("Private"),
]),
]
)
When added as a project dependency in Xcode, the framework compiles just fine, but when the dependent target attempts to import LNPopupController, an error is thrown: umbrella header 'LNPopupController.h' not found
Looking at the build folder, indeed, I see that Xcode has built a binary, but has not copied the public headers.
Any way to specify which headers are public, and make the build system copy them for import?

I eventually figured it out. This is what I did for LNPopupController:
I created a include/LNPopupController/ sub-directory tree, and put soft links to all public headers there.
In the package file, I added publicHeadersPath: "include".
You can see the final result here:
https://github.com/LeoNatan/LNPopupController/blob/master/Package.swift
It might not be the most optimal way, but it works for all my ObjC projects which I have tried this method on.

Related

Symfony 5 custom reusable bundle installation using flex - how to test and run a private recipe server

I have created a test reusable Symfony 5 bundle and have written a Flex recipe to automatically install and configure it within any project which is private.
My problem is, I have no idea how to run and test this. I cannot find any clear complete instructions anywhere. The official documentation does not specify how this would be done and only specifies how to create the manifest.json file.
https://github.com/symfony/recipes
I found the following info which specifies uploading the recipe to a private repository on GitHub and then activating Symfony Recipe Server for the repository which I have done.
https://blog.mayflower.de/6851-symfony-4-flex-private-recipes.html
but then what?
If understood this correctly, you want to add custom domain from where recipe would be downloaded and installed. Check this project:
Github https://github.com/moay/server-for-symfony-flex
Docs https://server-for-symfony-flex.readthedocs.io/en/latest/
Eventually you get to the point where you add custom endpoint from where to download the recipe like this:
Using the server in your Symfony project is as easy
as adding the proper endpoint to your composer.json:
{
...
"symfony": {
"endpoint": "https://your.domain.com"
}
}
I apologize if this is not in the desired format of an answer.

Unable to build project that includes a custom worker file

I'm facing a very strange issue with next-pwa. Whenever I try to build a next-pwa project that includes a custom worker js file, the build fails with the following error:
info - Creating an optimized production build ..buffer.js:333
throw new ERR_INVALID_ARG_TYPE(
^
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
at Function.from (buffer.js:333:9)
at writeOut (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\webpack\bundle4.js:56716:26)
at C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\webpack\bundle4.js:56735:7
at arrayIterator (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\neo-async\async.js:1:14270)
at timesSync (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\neo-async\async.js:1:5037)
at Object.eachLimit (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\neo-async\async.js:1:14216)
at emitFiles (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\webpack\bundle4.js:56617:13)
at C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\webpack\bundle4.js:36508:26
at FSReqCallback.oncomplete (fs.js:184:5) {
code: 'ERR_INVALID_ARG_TYPE'
}
I have tried several things so far to fix this issue:
Clone the repo and updated all dependencies (i thought the issue might be webpack related)
Building the project without a custom worker file (works fine)
Downgrade to Node 10, 12, 14, 15, and re-install dependencies.
I've also tried the to use the code provided in the /example folder of the repo, but the same issue occurs there as well.
I'm not the only one facing this issue so i would appreciate help.
You can test it yourself using Gitpod, just open this link and navigate to the example, install dependencies and try yarn build.
Are you using webpack 5 or 4.x? I faced the same issue with webpack > 5 and fixed the same by passing the future object to withPWA " future: { webpack5: true }".
module.exports = withPWA({ future: { webpack5: true },
pwa: {
disable: false,
dest: "public",
//register: false,
skipWaiting: false,
runtimeCaching
}
})

For QBS, What parameters would I set in my DynamicLibrary{} to install headers and libraries upon build?

I am migrating my Qt Libraries over from qmake to qbs, and I am trying to find a decent template that will help me understand what parameters are needed for streamlining the building and installing of said libraries.
Currently a qbs file for one of my libraries looks like this:
import qbs
DynamicLibrary {
name: "qparsingtoolkit";
Depends {name: "cpp"}
Depends {name: "Qt.core"}
files: [
"Headers/qparsingparameters.h",
"Headers/qparsingtoolkit.h",
"Headers/qparsingtoolkit_global.h",
"Sources/qparsingparameters.cpp",
"Sources/qparsingtoolkit.cpp",
]
}
The installation is relatively simple.
I just want a the headers placed in /usr/include/qconsoledesigner
and the .so libraries installed in
/usr/share/qconsoledesigner
DynamicLibrary {
name: "qparsingtoolkit";
Depends {name: "cpp"}
Depends {name: "Qt.core"}
qbs.installPrefix: "usr"
files: [
"Sources/qparsingparameters.cpp",
"Sources/qparsingtoolkit.cpp",
]
Group {
name: "api_headers"
files: [
"Headers/qparsingparameters.h",
"Headers/qparsingtoolkit.h",
"Headers/qparsingtoolkit_global.h",
]
qbs.install: true
qbs.installDir: "include/qconsoledesigner"
}
Group {
fileTagsFilter: ["dynamiclibrary", "dynamiclibrary_symlink"]
qbs.install: true
qbs.installDir: "share/qconsoledesigner"
}
}
Note that installation of target binaries will become more straightforward in the future; see e.g. http://doc-snapshots.qt.io/qbs/qml-qbsconvenienceitems-dynamiclibrary.html#installDir-prop.
A normal "qbs build" installs into an install root inside the build dir. To install "globally", follow the "qbs build" with "sudo qbs install --no-build --install-root /".

How to find Libpng library used in android project

When I upload my project to google play store I am getting Libpng library error and app getting rejected. I am not sure where it been used. I been used many library might be among those. How can I find it out exactly where this been used.
Is there any way to force fully by pass this like (Just an example)-
resolutionStrategy {
force 'com.google.android.gms:play-services-vision:11.4.2'
}
To get the list of dependency you can run this from Gradle -> Dependencies
Then you can find out which library causing issue and you can exclude it like this
dependencies
{
compile 'com.android.support:support-v4:xx.0.+'
compile ("com.xxx:xxx-commons:1.+")
{
exclude group: 'junit', module: 'junit'
}
}

meteorite local packages, having trouble setting the global namespace?

My current project is at https://github.com/jimmack1963/localPackages.git.
I am trying to get this code to work:
console.log("You pressed the button, " + MyName);
where MyName comes from a package called simple, that is JUST LOCAL. Per 6.5, am exporting via
Package.on_use(function (api, where) {
api.add_files(['constant.js'], 'client');
//below added per possible suggestion from Nathan, had no effect.
api.use('constant.js', 'client');
if (api.export)
api.export('MyName');
});
Am trying to factor my code out to local packages. This is not about publishing packages, but about using local ones, which is referred to in many places. My package is simply trying to publish a string, MyName. But the project wants none of it. "MyName is not defined."
I copy the technique in 'Discover Meteor,' but it doesn't work for me, and I try other things. Have had a lot of success in Meteor in general.
This spec seems to be changing. I get the 6.5 export requirement, but easily find contradictory advise about the base project's need to add that project in smart.json (not the one in the package). Most references don't list that as a requirement at all.
I've tried
{
"packages": {
"simple" : {
"path": "packages/simple"
}
}
}
and putting it into git and trying from a different project:
{
"packages": {
"simple" : {
"git": "https://github.com/jimmack1963/localPackages.git"
}
}
}
For the latter, pleasingly, the installer was smart enough to burrow down and extract the package itself, ignoring the project wrapping it in the git project. Nice! So, I have the same problem when I install the package directly from git, still not published to the world.
Ubuntu 13.04
Meteorite version 0.6.11
Meteor Release 0.6.5.1
I had the same issue after migrating to 0.6.5 -
You only get 'exported' variables from packages you explicitly "use"; Packages "use" other packages by calling .use inside Package.on_use, projects "use" packages by adding them to .meteor/packages
Additionally, it seems to be quite picky about exporting variables, and wont currently export ones preceded with this.

Resources