add sdk c++ headers into swift package manager project - swift-package-manager

I have a c++ project that i want to add to a swift package manager project
the c++ project references headers such as #include <string> this header resides in
iossdk/usr/include/c++/v1
how do i get the swift package manager to include those headers ?
let package = Package(
name: "LibProject",
platforms: [.iOS(.v13)],
products: [
.library(
name: "LibProject",
targets: ["LibModule1", "LibModule2Framework"]),
],
dependencies: [
],
targets: [
.target(
name: "LibModule1",
path: "Sources/LibModule1"),
.target(
name: "LibModule2Framework",
path: "Sources/LibModule2Framework",
publicHeadersPath: ".",
cxxSettings: [
.headerSearchPath("usr/include/c++/v1"),
]
),
.testTarget(
name: "LibModuleTests",
dependencies: ["LibModuleTests"]),
],
cLanguageStandard: .c17,
cxxLanguageStandard: .gnucxx17
)```

Related

Swift Package Manager: commit in project's sub-dependency doesn't appear in package code

I have a project which uses a dependency (Lib), which contains a sub-dependency (Utilities). I have just updated this sub-dependency, adding some code, but I can't see it from my project.
Here is the dependency declared in my project:
The Package in Lib, with the dependency to Utilities:
// swift-tools-version: 5.6
import PackageDescription
let package = Package(
name: "Lib",
defaultLocalization: "en",
platforms: [
.iOS("12.1")
],
products: [
.library(name: "Lib",
targets: ["Lib"])
],
dependencies: [
.package(url: "git#bitbucket.org:__UTILITIES__.git", branch: "development")
],
targets: [
.target(name: "Lib",
dependencies: [
.product(name: "Utilities",
package: "__UTILITIES__")
],
path: "code"
]
)
__UTILITIES__ is the utilities repo
I have committed and pushed the new code in Utilities's repo, on development branch. However, whatever I try (either resetting package caches, or updating to latest package versions), I never actually get my latest code from my project.
Am I missing something?
Thank you for your help

Swift Package Manager - binaryTarget with .zip file fails to validate

I tried different approaches to add a binaryTarget to a Swift package - 2 of them worked out fine (Target1 and Target2 in the example), but third approach (Target3) that should also work according to documentation does not validate: unsupported extension for binary target 'Target3'; valid extensions are: xcframework
For not bloating the repo too much with every binary release I would prefer the zip approach here... - Anyone got it working with a binaryTarget and a .zip file in path: added to the Package repository, or any hints what I'm doing wrong here?
(Xcode 12.4, t3.zip containing only the .xcframework at root level)
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "StackoverflowExamplePackage",
platforms: [
.iOS(.v9)
],
products: [
.library(
name: "Lib1",
targets: ["Target1"]),
.library(
name: "Lib2",
targets: ["Target2", "Target3"]),
],
dependencies: [
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
.binaryTarget(
name: "Target1",
url: "https://myurl.example.com/t1-xcframework.zip",
checksum: "777ddd6381e2201b7eb778b72f373f77e1190fd9dc9503f703e37c86d3b89674"
),
.binaryTarget(name: "Target2", path: "./Binaries/t2.xcframework"),
.binaryTarget(name: "Target3", path: "./Binaries/t3.zip"),
]
)
Zip archive support for local binary targets in SPM was merged last year in October and has been finally released along with Xcode 13.3.

swiftpm use binaryTarget got an error 'no such module' when archive

I'm trying to refactor the project using swiftpm and everything works fine, both in the emulator and on my iPhone device. But when I archive the project, I get an error 'no such module 'SFS2XAPIIOS''.
Here's the code of my Package.swift:
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "BaseIM",
platforms: [
.iOS(.v11)
],
products: [
.library(name: "BaseIM", targets: ["BaseIM"]),
.library(name: "SFS2XAPIIOSX", targets: ["SFS2XAPIIOS"])
],
dependencies: [
.package(name: "BaseTools", url: "http://192.168.1.28:8888/kevin/basetools.git", .branch("master")),
.package(name: "BaseClass", url: "http://192.168.1.28:8888/kevin/baseclass.git", .branch("master")),
.package(name: "MediaKit", url: "http://192.168.1.28:8888/kevin/mediakit.git", .branch("master")),
.package(name: "Realm", url: "https://github.com/realm/realm-cocoa", .upToNextMajor(from: "10.1.4"))
],
targets: [
.target(
name: "BaseIM",
dependencies: [
"SFS2XAPIIOSX", "BaseTools", "BaseClass", "MediaKit",
.product(name: "RealmSwift", package: "Realm")
]
),
.target(
name: "SFS2XAPIIOSX",
dependencies: [
"SFS2XAPIIOS"
],
path: "SFS2XAPIIOS",
cSettings: [
.headerSearchPath("Header.h")
]
),
.binaryTarget(name: "SFS2XAPIIOS", path: "SFS2XAPIIOS/SFS2XAPIIOS.xcframework"),
.testTarget(
name: "BaseIMTests",
dependencies: ["BaseIM"]),
]
)

Fresh install of Trellis by Roots on Ubuntu & VituralBox is missing composer.json under /srv/www/website.com/current

This is the error message I got when I first run 'vagrant provision' (after command 'vagrant up' blocked in 'Mounting NFS shared folders...') under the trellis directory:
TASK [wordpress-install : Install Dependencies with Composer] ******************
System info:
Ansible 2.9.11; Vagrant 2.2.9; Linux
Trellis version (per changelog): "Removes ID from Lets Encrypt bundled certificate and make filename stable"
---------------------------------------------------
Composer could not find a composer.json file in /srv/www/example.com/current
To initialize a project, please create a composer.json file
as described in the https://getcomposer.org/ "Getting Started"
section failed: [default] (item=example.com) =>
{
"ansible_loop_var": "item",
"changed": false,
"item": {
"key": "example.com",
"value": {
"admin_email": "admin#example.test",
"cache": {
"enabled": false
},
"local_path": "../site",
"multisite": {
"enabled": false
},
"site_hosts": [
{
"canonical": "example.test",
"redirects": [
"www.example.test"
]
}
],
"ssl": {
"enabled": false,
"provider": "self-signed"
}
}
},
"stdout": "Composer could not find a composer.json file in /srv/www/example.com/current\nTo initialize a project, please create a composer.json file as described in the https://getcomposer.org/ \"Getting Started\" section\n",
"stdout_lines": [
"Composer could not find a composer.json file in /srv/www/example.com/current",
"To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ \"Getting Started\" section"
]
}
PLAY RECAP *********************************************************************
default : ok=125 changed=83 unreachable=0 failed=1 skipped=34 rescued=0 ignored=0
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
How do I fix this? Where to find the right composer.json for Trellis, Bedrock, and Sage for local development on Linux?
Ubuntu 19.10

Custom Script Extension not working on Red Hat 7.2

I am unable to get Custom Script Extension working on Red Hat 7.2. I tried the latest extension and have the following in my ARM template -
{
"name": "[concat(parameters('VMNamePrefix'), parameters('startingNumeral')[copyindex()],'/',parameters('VMNamePrefix'), parameters('startingNumeral')[copyindex()],'-CUSTOMSCRIPT')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"location": "[parameters('region')]",
"apiVersion": "[variables('apiVersionVirtualMachines')]",
"tags": {
"ApmID": "[parameters('apmID')]",
"ApplicationName": "[parameters('applicationName')]",
"SharedService": "[parameters('sharedService')]",
"PaaSOnly": "[parameters('paasOnly')]"
},
"copy": {
"name": "customScriptLoop",
"count": "[parameters('vmInstanceCount')]"
},
"dependsOn": [
"[concat(parameters('VMNamePrefix'), parameters('startingNumeral')[copyindex()])]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"[variables('customScriptUri')]"
]
},
"protectedSettings": {
"commandToExecute": "[parameters('customScriptCommand')]"
}
}
}
The command to execute is pwd but after like 90 minutes, the extension gives up and I see the following in the waagent.log log file on Red Hat 7.2 -
2018/09/10 13:30:49.361162 INFO [Microsoft.Compute.CustomScriptExtension-1.9.1] Target handler state: enabled
2018/09/10 13:30:49.390061 INFO [Microsoft.Compute.CustomScriptExtension-1.9.1] [Enable] current handler state is: notinstalled
2018/09/10 13:30:49.585331 INFO [Microsoft.Compute.CustomScriptExtension-1.9.1] Initialize extension directory
2018/09/10 13:30:49.615784 INFO [Microsoft.Compute.CustomScriptExtension-1.9.1] Update settings file: 0.settings
2018/09/10 13:30:49.644631 INFO [Microsoft.Compute.CustomScriptExtension-1.9.1] Install extension [install.cmd]
2018/09/10 13:30:50.678474 WARNING [Microsoft.Compute.CustomScriptExtension-1.9.1] [ExtensionError] Non-zero exit code: 127, install.cmd
2018/09/10 13:30:50.713928 INFO [Microsoft.Compute.CustomScriptExtension-1.9.1] Remove extension handler directory: /var/lib/waagent/Microsoft.Compute.CustomScriptExtension-1.9.1
2018/09/10 13:30:50.723392 INFO ExtHandler ProcessGoalState completed [incarnation 4; 1534 ms]
I am not seeing any other logs as well. Any idea what could be going wrong? When I manually go and install the Custom Script extension from the portal, it works fine.
Thanks,
Pranav

Resources