From 8394f4f11d50a7b7657827027fe35c645a5c19dd Mon Sep 17 00:00:00 2001 From: Kyriakos Sidiropoulos Date: Thu, 14 Nov 2024 19:24:19 +0100 Subject: [PATCH] fix (Laerdal.Dfu.Bindings.iOS.csproj): milestone refactoring to support mac-catalyst we now build against ios sdk 18.1 and maccatalyst sdk 15.1 while using xcode 16.1 on macos-15 vmimage (up from 14) --- .github/workflows/github-actions.yml | 18 +- .gitignore | 3 +- .../Laerdal.Dfu.Bindings.iOS.csproj | 142 +++++-- .../Laerdal.Mac.CompileAndGenerateFatLibs.sh | 364 ++++++++++++++++ Laerdal.Dfu.Bindings.iOS/Laerdal.targets | 35 +- .../Sharpie/ApiDefinitions.cs | 399 ------------------ .../Sharpie/StructsAndEnums.cs | 112 ----- Laerdal.Scripts/Laerdal.Builder.targets | 27 +- 8 files changed, 527 insertions(+), 573 deletions(-) create mode 100755 Laerdal.Dfu.Bindings.iOS/Laerdal.Mac.CompileAndGenerateFatLibs.sh delete mode 100644 Laerdal.Dfu.Bindings.iOS/Sharpie/ApiDefinitions.cs delete mode 100644 Laerdal.Dfu.Bindings.iOS/Sharpie/StructsAndEnums.cs diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 0a03d2d..cbd51f2 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -30,6 +30,14 @@ env: DOTNET_TARGET_WORKLOAD_VERSION: "8.0.402" # dont upgrade this lightheartedly the workload snapshot implicitly defines which versions of Android/iOS/MacCatalyst SDKs are supported + BINDINGS_IOS___SDK_VERSION: "18.1" # for xcodebuild + BINDINGS_IOS___XCODE_IDE_DEV_PATH: "/Applications/Xcode_16.1.app/Contents/Developer" # for xcodebuild + BINDINGS_IOS___DOTNET_TARGET_PLATFORM_VERSION: "17.0" # for the csproj file + + BINDINGS_MACCATALYST___SDK_VERSION: "15.1" # for xcodebuild + BINDINGS_MACCATALYST___XCODE_IDE_DEV_PATH: "/Applications/Xcode_16.1.app/Contents/Developer" # for xcodebuild + BINDINGS_MACCATALYST___DOTNET_TARGET_PLATFORM_VERSION: "17.0" # for the csproj file + on: workflow_call: # so that other workflows can trigger this @@ -48,7 +56,7 @@ jobs: build: - runs-on: 'macos-14' + runs-on: 'macos-15' timeout-minutes: 20 steps: @@ -90,6 +98,14 @@ jobs: -p:Laerdal_Github_Access_Token="${{ env.SCL_GITHUB_ACCESS_TOKEN }}" \ -p:Laerdal_Should_Generate_and_Upload_Sbom="true" \ \ + -p:Laerdal_Bindings_iOS___Sdk_Version="${{env.BINDINGS_IOS___SDK_VERSION}}" \ + -p:Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path="${{env.BINDINGS_IOS___XCODE_IDE_DEV_PATH}}" \ + -p:Laerdal_Bindings_iOS___DotnetTargetPlatformVersion="${{env.BINDINGS_IOS___DOTNET_TARGET_PLATFORM_VERSION}}" \ + \ + -p:Laerdal_Bindings_MacCatalyst___Sdk_Version="${{env.BINDINGS_MACCATALYST___SDK_VERSION}}" \ + -p:Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path="${{env.BINDINGS_MACCATALYST___XCODE_IDE_DEV_PATH}}" \ + -p:Laerdal_Bindings_MacCatalyst___DotnetTargetPlatformVersion="${{env.BINDINGS_MACCATALYST___DOTNET_TARGET_PLATFORM_VERSION}}" \ + \ -p:Laerdal_Dependency_Tracker_Server_Url="${{ env.SCL_DEPENDENCY_TRACKER_SERVER_URL }}" \ -p:Laerdal_Dependency_Tracker_Api_Key_File_Path="${{ env.BUILD_REPOSITORY_FOLDERPATH }}/Laerdal.Scripts/dependency_tracker_api_key.ppk" \ -p:Laerdal_Dependency_Tracker_Private_Signing_Key_File_Path="${{ env.BUILD_REPOSITORY_FOLDERPATH }}/Laerdal.Scripts/dependency_tracker_private_signing_key.ppk" \ diff --git a/.gitignore b/.gitignore index 0432f75..5eec62a 100644 --- a/.gitignore +++ b/.gitignore @@ -406,7 +406,8 @@ ASALocalRun/ Output/ Laerdal.Dfu.Bindings.iOS/Carthage/ -# Laerdal.Dfu.Bindings.iOS/Sharpie/ +Laerdal.Dfu.Bindings.iOS/Sharpie/ +Laerdal.Dfu.Bindings.iOS/Frameworks/ *.binlog *.csproj.xml diff --git a/Laerdal.Dfu.Bindings.iOS/Laerdal.Dfu.Bindings.iOS.csproj b/Laerdal.Dfu.Bindings.iOS/Laerdal.Dfu.Bindings.iOS.csproj index c58e49e..72a9641 100644 --- a/Laerdal.Dfu.Bindings.iOS/Laerdal.Dfu.Bindings.iOS.csproj +++ b/Laerdal.Dfu.Bindings.iOS/Laerdal.Dfu.Bindings.iOS.csproj @@ -9,8 +9,6 @@ - true - $(TargetFrameworks)net8.0-ios; $(TargetFrameworks)net8.0-maccatalyst @@ -21,6 +19,8 @@ + true + full false -v -v -v -v @@ -30,6 +30,15 @@ $(DefaultItemExcludes);Carthage\** + $([System.IO.Path]::Combine($(MSBuildThisFileDirectory), 'Frameworks')) + $(NativeFrameworkParentFolderpath)/NordicDFU.framework + + + + + + + @@ -62,6 +71,16 @@ + + + + + + + + @@ -72,63 +91,104 @@ - - - Framework - False - Foundation - - - + + + + + - + + + <_PreexistingFilesToClean Include="$(NativeFrameworkActualTargetFolderpath)\**\*"/> + + + + + - <_CarthageBuildCommand>$(_CarthageBuildCommand) GITHUB_ACCESS_TOKEN="github.com=$(Laerdal_Github_Access_Token)" - <_CarthageBuildCommand>$(_CarthageBuildCommand) carthage update - <_CarthageBuildCommand>$(_CarthageBuildCommand) --platform iOS - <_CarthageBuildCommand>$(_CarthageBuildCommand) --no-use-binaries - <_CarthageBuildCommand>$(_CarthageBuildCommand) --use-xcframeworks - <_CarthageBuildCommand>$(_CarthageBuildCommand) --project-directory Carthage + <_CarthageCheckoutCommand>$(_CarthageCheckoutCommand) GITHUB_ACCESS_TOKEN="github.com=$(Laerdal_Github_Access_Token)" + <_CarthageCheckoutCommand>$(_CarthageCheckoutCommand) carthage update + <_CarthageCheckoutCommand>$(_CarthageCheckoutCommand) --no-build + + <_CarthageBase_FolderPath>$(MSBuildThisFileDirectory)\Carthage + <_CarthageCheckout_FolderPath>$(_CarthageBase_FolderPath)\Carthage\Checkouts + <_CarthageCheckoutNordicIosPodsDfuLibrary_FolderPath>$(_CarthageCheckout_FolderPath)\IOS-Pods-DFU-Library + + <_CompileAndGenerateFatLibs_FilePath>$(MSBuildThisFileDirectory)/Laerdal.Mac.CompileAndGenerateFatLibs.sh - + - + - - - - - - - + + + + + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) SUPPORTS_MACCATALYST='NO' + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) XCODEBUILD_TARGET_SDK='iphoneos' + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) XCODE_IDE_DEV_PATH='$(Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path)' + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) XCODEBUILD_TARGET_SDK_VERSION='$(Laerdal_Bindings_iOS___Sdk_Version)' + + + + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) SUPPORTS_MACCATALYST='YES' + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) XCODEBUILD_TARGET_SDK='macosx' + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) XCODE_IDE_DEV_PATH='$(Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path)' + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) XCODEBUILD_TARGET_SDK_VERSION='$(Laerdal_Bindings_MacCatalyst___Sdk_Version)' + + + + + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) INVOKE_SHARPIE='NO' + <_CompileAndGenerateFatLibs_Config>$(_CompileAndGenerateFatLibs_Config) SWIFT_OUTPUT_PATH='$(NativeFrameworkParentFolderpath)' + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + Framework + False + Foundation + + + diff --git a/Laerdal.Dfu.Bindings.iOS/Laerdal.Mac.CompileAndGenerateFatLibs.sh b/Laerdal.Dfu.Bindings.iOS/Laerdal.Mac.CompileAndGenerateFatLibs.sh new file mode 100755 index 0000000..7ba5d50 --- /dev/null +++ b/Laerdal.Dfu.Bindings.iOS/Laerdal.Mac.CompileAndGenerateFatLibs.sh @@ -0,0 +1,364 @@ +#!/usr/bin/env bash + +# set -x # echo on for debugging + +# Builds a fat library for a given xcode project (framework) +# +# Derived from https://github.com/xamcat/xamarin-binding-swift-framework/blob/master/Swift/Scripts/build.fat.sh#L3-L14 +# +# Note that all parameters passed to xcodebuild must be in the form of -parameter value instead of --parameter + +declare INVOKE_SHARPIE="${INVOKE_SHARPIE:-YES}" + +declare XCODE_IDE_DEV_PATH="${XCODE_IDE_DEV_PATH:-}" + +declare XCODEBUILD_TARGET_SDK="${XCODEBUILD_TARGET_SDK:-iphoneos}" +declare XCODEBUILD_TARGET_SDK_VERSION="${XCODEBUILD_TARGET_SDK_VERSION}" # xcodebuild -showsdks + +if [ "${XCODEBUILD_TARGET_SDK}" == "iphoneos" ] && [ -z "${XCODEBUILD_TARGET_SDK_VERSION}" ]; then # ios + XCODEBUILD_TARGET_SDK_VERSION="18.1" # requires xcode 16.1 + +elif [ "${XCODEBUILD_TARGET_SDK}" == "macosx" ] && [ -z "${XCODEBUILD_TARGET_SDK_VERSION}" ]; then # maccatalyst + XCODEBUILD_TARGET_SDK_VERSION="15.1" # requires xcode 16.1 +fi + +declare SWIFT_BUILD_CONFIGURATION="${SWIFT_BUILD_CONFIGURATION:-Release}" + +declare SUPPORTS_MACCATALYST="${SUPPORTS_MACCATALYST:-NO}" +declare XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY="${XCODEBUILD_TARGET_SDK}${XCODEBUILD_TARGET_SDK_VERSION}" + +declare SWIFT_OUTPUT_PATH="${SWIFT_OUTPUT_PATH:-./VendorFrameworks/swift-framework-proxy/}" + +declare SWIFT_PROJECT_NAME="NordicDFU" +declare SWIFT_BUILD_PATH="./${SWIFT_PROJECT_NAME}/build" +declare SWIFT_BUILD_SCHEME="NordicDFU" +declare SWIFT_PROJECT_PATH="./IOS-Pods-DFU-Library/${SWIFT_PROJECT_NAME}.xcodeproj" +declare SWIFT_PACKAGES_PATH="./packages" + +declare OUTPUT_FOLDER_POSTFIX="" +if [ "${XCODEBUILD_TARGET_SDK}" == "macosx" ]; then + OUTPUT_FOLDER_POSTFIX="" # special case for mac catalyst +else + OUTPUT_FOLDER_POSTFIX="-${XCODEBUILD_TARGET_SDK}" +fi + +declare OUTPUT_FOLDER_NAME="${SWIFT_BUILD_CONFIGURATION}${OUTPUT_FOLDER_POSTFIX}" # Release-iphoneos or Release-maccatalyst note that we intentionally *omitted* the sdk-version +declare OUTPUT_SHARPIE_HEADER_FILES_PATH="SharpieOutput/SwiftFrameworkProxy.Binding" # from the folder name contains the resulting files ApiDefinitions.cs and StructsAndEnums.cs + +function print_setup() { + echo "** xcode path : '$( "xcode-select" --print-path )'" + echo "** xcode version : '$( "xcodebuild" -version )'" + echo "** xcode sdks :" + xcodebuild -showsdks + echo "** xcode sdks visible to sharpie :" + sharpie xcode -sdks + + echo + echo "** SWIFT_BUILD_PATH : '${SWIFT_BUILD_PATH}' " + echo "** SWIFT_OUTPUT_PATH : '${SWIFT_OUTPUT_PATH}' " + echo "** SWIFT_BUILD_SCHEME : '${SWIFT_BUILD_SCHEME}' " + echo "** SWIFT_PROJECT_NAME : '${SWIFT_PROJECT_NAME}' " + echo "** SWIFT_PROJECT_PATH : '${SWIFT_PROJECT_PATH}' " + echo "** SWIFT_PACKAGES_PATH : '${SWIFT_PACKAGES_PATH}' " + echo "** SWIFT_BUILD_CONFIGURATION : '${SWIFT_BUILD_CONFIGURATION}' " + echo + echo "** PWD : '${PWD}' " + echo "** OUTPUT_FOLDER_NAME : '${OUTPUT_FOLDER_NAME}' " + echo "** OUTPUT_SHARPIE_HEADER_FILES_PATH : '${OUTPUT_SHARPIE_HEADER_FILES_PATH}' " + echo + echo "** INVOKE_SHARPIE : '${INVOKE_SHARPIE}' " + echo "** SUPPORTS_MACCATALYST : '${SUPPORTS_MACCATALYST}' " + echo + echo "** XCODE_IDE_DEV_PATH : '${XCODE_IDE_DEV_PATH:-(No path specified so the system-wide default xcode currently in effect will be used)}'" + echo + echo "** XCODEBUILD_TARGET_SDK : '${XCODEBUILD_TARGET_SDK}' " + echo "** XCODEBUILD_TARGET_SDK_VERSION : '${XCODEBUILD_TARGET_SDK_VERSION:-(No specific version specified so the latest version will be used)}'" + echo "** XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY : '${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}' " + echo +} + +function set_system_wide_default_xcode_ide() { + declare -r currentXcodeDevPath=$( "xcode-select" --print-path ) + if [ "${XCODE_IDE_DEV_PATH}" != "" ] && [ "${currentXcodeDevPath}" != "${XCODE_IDE_DEV_PATH}" ]; then + echo "** Setting Xcode IDE path to '${XCODE_IDE_DEV_PATH}' - remember to manually revert it back to '${currentXcodeDevPath}' after the build is done!" + sudo xcode-select --switch "${XCODE_IDE_DEV_PATH}" + local exitCode=$? + + if [ ${exitCode} -ne 0 ]; then + echo "** [FAILED] Failed to set xcode-select to '${XCODE_IDE_DEV_PATH}'" + exit 1 + fi + fi +} + +function build() { + echo "** Building '${OUTPUT_FOLDER_NAME}' framework for device ..." + + echo "**** (Build 1/3) Cleanup any possible traces of previous builds" + + rm -Rf "${SWIFT_BUILD_PATH}" + rm -Rf "${SWIFT_PACKAGES_PATH}" + rm -Rf "${OUTPUT_SHARPIE_HEADER_FILES_PATH}" + + echo "**** (Build 2/3) Restore packages for '${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}'" + + xcodebuild \ + -sdk "${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}" \ + -arch "arm64" \ + -scheme "${SWIFT_BUILD_SCHEME}" \ + -project "${SWIFT_PROJECT_PATH}" \ + -configuration "${SWIFT_BUILD_CONFIGURATION}" \ + -clonedSourcePackagesDirPath "${SWIFT_PACKAGES_PATH}" \ + -resolvePackageDependencies + local exitCode=$? + + if [ ${exitCode} -ne 0 ]; then + echo "** [FAILED] Failed to download dependencies for '${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}'" + exit 1 + fi + + echo "**** (Build 3/3) Build for '${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}'" + + # https://stackoverflow.com/a/74478244/863651 + xcodebuild \ + -sdk "${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}" \ + -arch "arm64" \ + -scheme "${SWIFT_BUILD_SCHEME}" \ + -project "${SWIFT_PROJECT_PATH}" \ + -configuration "${SWIFT_BUILD_CONFIGURATION}" \ + -derivedDataPath "${SWIFT_BUILD_PATH}" \ + -clonedSourcePackagesDirPath "${SWIFT_PACKAGES_PATH}" \ + CODE_SIGN_IDENTITY="" \ + CODE_SIGNING_ALLOWED="NO" \ + SUPPORTS_MACCATALYST="${SUPPORTS_MACCATALYST}" \ + CODE_SIGNING_REQUIRED="NO" + local exitCode=$? + + if [ ${exitCode} -ne 0 ]; then + echo "** [FAILED] Failed to build '${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}'" + exit 1 + fi +} + +function create_fat_binaries() { + echo "** Create fat binaries for '${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}-${SWIFT_BUILD_CONFIGURATION}'" + + echo "**** (FatBinaries 1/8) Copy '${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}' build as a fat framework" + cp \ + -R \ + "${SWIFT_BUILD_PATH}/Build/Products/${OUTPUT_FOLDER_NAME}" \ + "${SWIFT_BUILD_PATH}/fat" + local exitCode=$? + + if [ ${exitCode} -ne 0 ]; then + echo "** [FAILED] Failed to copy" + exit 1 + fi + + echo "**** LISTING 'PRODUCTS' FILES" + ls -lR "${SWIFT_BUILD_PATH}/Build/Products/" + + echo "**** LISTING LIPO INPUT FILES" + ls -lR "${SWIFT_BUILD_PATH}/Build/Products/${OUTPUT_FOLDER_NAME}/${SWIFT_PROJECT_NAME}.framework/${SWIFT_PROJECT_NAME}" + + echo "**** (FatBinaries 2/8) Turn artifacts in '${OUTPUT_FOLDER_NAME}' into fat libraries" + lipo \ + -create \ + -output "${SWIFT_BUILD_PATH}/fat/${SWIFT_PROJECT_NAME}.framework/${SWIFT_PROJECT_NAME}" \ + "${SWIFT_BUILD_PATH}/Build/Products/${OUTPUT_FOLDER_NAME}/${SWIFT_PROJECT_NAME}.framework/${SWIFT_PROJECT_NAME}" + local exitCode=$? + + if [ ${exitCode} -ne 0 ]; then + echo "** [FAILED] Failed to combine configurations" + exit 1 + fi + + echo "**** LISTING LIPO OUTPUT FILES" + ls -lR "${SWIFT_BUILD_PATH}/fat/${SWIFT_PROJECT_NAME}.framework/${SWIFT_PROJECT_NAME}" + + echo "**** (FatBinaries 3/8) Verify results" + lipo \ + -info \ + "${SWIFT_BUILD_PATH}/fat/${SWIFT_PROJECT_NAME}.framework/${SWIFT_PROJECT_NAME}" + local exitCode=$? + + if [ ${exitCode} -ne 0 ]; then + echo "** [FAILED] Failed to verify results" + exit 1 + fi + + echo "**** (FatBinaries 4/8) Copy fat frameworks to the output folder" + rm -Rf "${SWIFT_OUTPUT_PATH}" && + mkdir -p "${SWIFT_OUTPUT_PATH}" && + cp -Rf \ + "${SWIFT_BUILD_PATH}/fat/${SWIFT_PROJECT_NAME}.framework" \ + "${SWIFT_OUTPUT_PATH}" + local exitCode=$? + + if [ ${exitCode} -ne 0 ]; then + echo "** [FAILED] Failed to copy fat frameworks" + exit 1 + fi + + if [ "${INVOKE_SHARPIE}" != "YES" ]; then + echo "** Skipping sharpie invocation" + return + fi + + echo "**** (FatBinaries 5/8) Generating binding api definition and structs" + set -x + sharpie \ + bind \ + -sdk "${XCODEBUILD_TARGET_SDK_WITH_VERSION_IF_ANY}" \ + -scope "${SWIFT_OUTPUT_PATH}/${SWIFT_PROJECT_NAME}.framework/Headers/" \ + -output "${OUTPUT_SHARPIE_HEADER_FILES_PATH}" \ + -namespace "${SWIFT_PROJECT_NAME}" \ + "${SWIFT_OUTPUT_PATH}/${SWIFT_PROJECT_NAME}.framework/Headers/${SWIFT_PROJECT_NAME}-Swift.h" \ + -clang -arch arm64 # vital needed for mac-catalyst + local exitCode=$? + set +x + + if [ ${exitCode} -ne 0 ]; then + echo "** [FAILED] Failed to generate binding api definitions and structs" + exit 1 + fi + + echo "**** (FatBinaries 6/8) Print metadata files in their original form" + + echo + echo "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/ApiDefinitions.cs (original):" + echo "===================================================" + cat "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/ApiDefinitions.cs" + echo + echo "====================================================" + echo + + echo + echo "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/StructsAndEnums.cs (original):" + echo "====================================================" + cat "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/StructsAndEnums.cs" + echo + echo "====================================================" + echo + + echo "**** (FatBinaries 7/8) Replace NativeHandle -> IntPtr in the generated c# files" + + rm -f "${OUTPUT_SHARPIE_HEADER_FILES_PATH}"/*.bak || : + + # starting from net8 sharpie seems to generate a file that is missing the using CoreBluetooth; directive from the top of the file so we have to add it ourselves + sed -i.bak '1s/^/using CoreBluetooth;\n/' "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/ApiDefinitions.cs" + + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak "s/NativeHandle[ ]/IntPtr /gi" {} \; + + rm -f "${OUTPUT_SHARPIE_HEADER_FILES_PATH}"/*.bak || : + + # also need to get rid of stupid autogenerated [verify(...)] attributes which are intentionally placed there + # by sharpie to force manual verification of the .cs files that have been autogenerated + # + # https://learn.microsoft.com/en-us/xamarin/cross-platform/macios/binding/objective-sharpie/platform/verify + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/\[Verify\s*\(.*\)\]//gi' {} \; + + rm -f "${OUTPUT_SHARPIE_HEADER_FILES_PATH}"/*.bak || : + + # [BaseType (typeof(NSObject), Name = "...")] -> [BaseType (typeof(NSObject))] + # find \ + # "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + # -type f \ + # -exec sed -i.bak 's/\[BaseType\s*\(.*_TtC17McuMgrBindingsiOS17IOSDeviceResetter.*\)\]/[BaseType (typeof(NSObject), Name = "IOSDeviceResetter")]/gi' {} \; + # + # rm -f "${OUTPUT_SHARPIE_HEADER_FILES_PATH}"/*.bak || : + + # https://learn.microsoft.com/en-us/xamarin/ios/internals/registrar?force_isolation=true#new-registrar-required-changes-to-bindings + # + # adding [Protocol] to the 'interfaces' representing actual swift classes seems to be mandatory for the azure pipelines to generate a valid nuget + # for ios if we omit adding this attribute then the nuget generated by the azure pipelines gets poisoned and it causes a very cryptic runtime error + # so I'm not 100% sure why the [Protocol] attribute does away with the observed error but it does the trick of solving the problem somehow + + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSFileUploader/[Protocol] interface IOSFileUploader/gi' {} \; + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSFileDownloader/[Protocol] interface IOSFileDownloader/gi' {} \; + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSDeviceResetter/[Protocol] interface IOSDeviceResetter/gi' {} \; + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSFirmwareEraser/[Protocol] interface IOSFirmwareEraser/gi' {} \; + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSFirmwareInstaller/[Protocol] interface IOSFirmwareInstaller/gi' {} \; + + rm -f "${OUTPUT_SHARPIE_HEADER_FILES_PATH}"/*.bak || : + + # https://stackoverflow.com/a/49477937/863651 its vital to add [BaseType] to the interface otherwise compilation will fail + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSListenerForFileUploader/[BaseType(typeof(NSObject))] [Model] interface IOSListenerForFileUploader/gi' {} \; + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSListenerForFileDownloader/[BaseType(typeof(NSObject))] [Model] interface IOSListenerForFileDownloader/gi' {} \; + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSListenerForDeviceResetter/[BaseType(typeof(NSObject))] [Model] interface IOSListenerForDeviceResetter/gi' {} \; + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSListenerForFirmwareEraser/[BaseType(typeof(NSObject))] [Model] interface IOSListenerForFirmwareEraser/gi' {} \; + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/interface IOSListenerForFirmwareInstaller/[BaseType(typeof(NSObject))] [Model] interface IOSListenerForFirmwareInstaller/gi' {} \; + + # some plain methods unfortunately get autoprojected into properties by sharpie so we need to fix that + find \ + "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/" \ + -type f \ + -exec sed -i.bak 's/bool TryInvalidateCachedTransport { get; }/bool TryInvalidateCachedTransport();/gi' {} \; + + rm -f "${OUTPUT_SHARPIE_HEADER_FILES_PATH}"/*.bak || : + + echo "**** (FatBinaries 8/8) Print metadata files in their eventual form" + + echo + echo "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/ApiDefinitions.cs (eventual):" + echo "===================================================" + cat "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/ApiDefinitions.cs" + echo + echo "====================================================" + echo + + echo + echo "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/StructsAndEnums.cs (eventual):" + echo "====================================================" + cat "${OUTPUT_SHARPIE_HEADER_FILES_PATH}/StructsAndEnums.cs" + echo + echo "====================================================" + echo +} + +function main() { + set_system_wide_default_xcode_ide # order + print_setup # order + build # order + create_fat_binaries # order + + echo "** Done!" +} + +main "$@" diff --git a/Laerdal.Dfu.Bindings.iOS/Laerdal.targets b/Laerdal.Dfu.Bindings.iOS/Laerdal.targets index 1ad7344..4d86d37 100644 --- a/Laerdal.Dfu.Bindings.iOS/Laerdal.targets +++ b/Laerdal.Dfu.Bindings.iOS/Laerdal.targets @@ -82,19 +82,26 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -110,4 +117,4 @@ $(Laerdal_Version_Full) $(Laerdal_Version_Full) - \ No newline at end of file + diff --git a/Laerdal.Dfu.Bindings.iOS/Sharpie/ApiDefinitions.cs b/Laerdal.Dfu.Bindings.iOS/Sharpie/ApiDefinitions.cs deleted file mode 100644 index f6f8fd8..0000000 --- a/Laerdal.Dfu.Bindings.iOS/Sharpie/ApiDefinitions.cs +++ /dev/null @@ -1,399 +0,0 @@ -using System; -using CoreBluetooth; -using CoreFoundation; -using Foundation; -using NordicDFU; -using ObjCRuntime; - -namespace Laerdal.Dfu.Bindings.iOS -{ - // @interface DFUFirmware : NSObject - [BaseType (typeof(NSObject), Name = "_TtC9NordicDFU11DFUFirmware")] - [DisableDefaultCtor] - interface DFUFirmware - { - // @property (readonly, copy, nonatomic) NSString * _Nullable fileName; - [NullAllowed, Export ("fileName")] - string FileName { get; } - - // @property (readonly, copy, nonatomic) NSURL * _Nullable fileUrl; - [NullAllowed, Export ("fileUrl", ArgumentSemantic.Copy)] - NSUrl FileUrl { get; } - - // @property (readonly, nonatomic) BOOL valid; - [Export ("valid")] - bool Valid { get; } - - // @property (readonly, nonatomic, strong) DFUFirmwareSize * _Nonnull size; - [Export ("size", ArgumentSemantic.Strong)] - DFUFirmwareSize Size { get; } - - // @property (readonly, nonatomic) NSInteger parts; - [Export ("parts")] - nint Parts { get; } - - // -(instancetype _Nullable)initWithUrlToZipFile:(NSURL * _Nonnull)urlToZipFile error:(NSError * _Nullable * _Nullable)error; - [Export ("initWithUrlToZipFile:error:")] - NativeHandle Constructor (NSUrl urlToZipFile, [NullAllowed] out NSError error); - - // -(instancetype _Nullable)initWithUrlToZipFile:(NSURL * _Nonnull)urlToZipFile type:(enum DFUFirmwareType)type error:(NSError * _Nullable * _Nullable)error __attribute__((objc_designated_initializer)); - [Export ("initWithUrlToZipFile:type:error:")] - [DesignatedInitializer] - NativeHandle Constructor (NSUrl urlToZipFile, DFUFirmwareType type, [NullAllowed] out NSError error); - - // -(instancetype _Nullable)initWithZipFile:(NSData * _Nonnull)zipFile error:(NSError * _Nullable * _Nullable)error; - [Export ("initWithZipFile:error:")] - NativeHandle Constructor (NSData zipFile, [NullAllowed] out NSError error); - - // -(instancetype _Nullable)initWithZipFile:(NSData * _Nonnull)zipFile type:(enum DFUFirmwareType)type error:(NSError * _Nullable * _Nullable)error __attribute__((objc_designated_initializer)); - [Export ("initWithZipFile:type:error:")] - [DesignatedInitializer] - NativeHandle Constructor (NSData zipFile, DFUFirmwareType type, [NullAllowed] out NSError error); - - // -(instancetype _Nullable)initWithUrlToBinOrHexFile:(NSURL * _Nonnull)urlToBinOrHexFile urlToDatFile:(NSURL * _Nullable)urlToDatFile type:(enum DFUFirmwareType)type error:(NSError * _Nullable * _Nullable)error __attribute__((objc_designated_initializer)); - [Export ("initWithUrlToBinOrHexFile:urlToDatFile:type:error:")] - [DesignatedInitializer] - NativeHandle Constructor (NSUrl urlToBinOrHexFile, [NullAllowed] NSUrl urlToDatFile, DFUFirmwareType type, [NullAllowed] out NSError error); - - // -(instancetype _Nonnull)initWithBinFile:(NSData * _Nonnull)binFile datFile:(NSData * _Nullable)datFile type:(enum DFUFirmwareType)type __attribute__((objc_designated_initializer)); - [Export ("initWithBinFile:datFile:type:")] - [DesignatedInitializer] - NativeHandle Constructor (NSData binFile, [NullAllowed] NSData datFile, DFUFirmwareType type); - - // -(instancetype _Nullable)initWithHexFile:(NSData * _Nonnull)hexFile datFile:(NSData * _Nullable)datFile type:(enum DFUFirmwareType)type error:(NSError * _Nullable * _Nullable)error __attribute__((objc_designated_initializer)); - [Export ("initWithHexFile:datFile:type:error:")] - [DesignatedInitializer] - NativeHandle Constructor (NSData hexFile, [NullAllowed] NSData datFile, DFUFirmwareType type, [NullAllowed] out NSError error); - } - - // @interface DFUFirmwareSize : NSObject - [BaseType (typeof(NSObject), Name = "_TtC9NordicDFU15DFUFirmwareSize")] - [DisableDefaultCtor] - interface DFUFirmwareSize - { - // @property (readonly, nonatomic) uint32_t softdevice; - [Export ("softdevice")] - uint Softdevice { get; } - - // @property (readonly, nonatomic) uint32_t bootloader; - [Export ("bootloader")] - uint Bootloader { get; } - - // @property (readonly, nonatomic) uint32_t application; - [Export ("application")] - uint Application { get; } - } - - // @protocol DFUPeripheralSelectorDelegate - [Protocol (Name = "_TtP9NordicDFU29DFUPeripheralSelectorDelegate_"), Model (AutoGeneratedName = true)] - interface DFUPeripheralSelectorDelegate - { - // @required -(BOOL)select:(CBPeripheral * _Nonnull)peripheral advertisementData:(NSDictionary * _Nonnull)advertisementData RSSI:(NSNumber * _Nonnull)RSSI hint:(NSString * _Nullable)name __attribute__((warn_unused_result(""))); - [Abstract] - [Export ("select:advertisementData:RSSI:hint:")] - bool Select (CBPeripheral peripheral, NSDictionary advertisementData, NSNumber RSSI, [NullAllowed] string name); - - // @required -(NSArray * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuServiceUUID __attribute__((warn_unused_result(""))); - [Abstract] - [Export ("filterByHint:")] - [return: NullAllowed] - CBUUID[] FilterByHint (CBUUID dfuServiceUUID); - } - - // @interface DFUPeripheralSelector : NSObject - [BaseType (typeof(NSObject), Name = "_TtC9NordicDFU21DFUPeripheralSelector")] - interface DFUPeripheralSelector : IDFUPeripheralSelectorDelegate - { - // -(BOOL)select:(CBPeripheral * _Nonnull)peripheral advertisementData:(NSDictionary * _Nonnull)advertisementData RSSI:(NSNumber * _Nonnull)RSSI hint:(NSString * _Nullable)name __attribute__((warn_unused_result(""))); - [Export ("select:advertisementData:RSSI:hint:")] - bool Select (CBPeripheral peripheral, NSDictionary advertisementData, NSNumber RSSI, [NullAllowed] string name); - - // -(NSArray * _Nullable)filterByHint:(CBUUID * _Nonnull)dfuServiceUUID __attribute__((warn_unused_result(""))); - [Export ("filterByHint:")] - [return: NullAllowed] - CBUUID[] FilterByHint (CBUUID dfuServiceUUID); - } - - // @protocol DFUProgressDelegate - [Protocol (Name = "_TtP9NordicDFU19DFUProgressDelegate_"), Model (AutoGeneratedName = true)] - interface DFUProgressDelegate - { - // @required -(void)dfuProgressDidChangeFor:(NSInteger)part outOf:(NSInteger)totalParts to:(NSInteger)progress currentSpeedBytesPerSecond:(double)currentSpeedBytesPerSecond avgSpeedBytesPerSecond:(double)avgSpeedBytesPerSecond; - [Abstract] - [Export ("dfuProgressDidChangeFor:outOf:to:currentSpeedBytesPerSecond:avgSpeedBytesPerSecond:")] - void OutOf (nint part, nint totalParts, nint progress, double currentSpeedBytesPerSecond, double avgSpeedBytesPerSecond); - } - - // @interface DFUServiceController : NSObject - [BaseType (typeof(NSObject), Name = "_TtC9NordicDFU20DFUServiceController")] - [DisableDefaultCtor] - interface DFUServiceController - { - // -(void)pause; - [Export ("pause")] - void Pause (); - - // -(void)resume; - [Export ("resume")] - void Resume (); - - // -(BOOL)abort __attribute__((warn_unused_result(""))); - [Export ("abort")] - [Verify (MethodToProperty)] - bool Abort { get; } - - // -(void)restart; - [Export ("restart")] - void Restart (); - - // @property (readonly, nonatomic) BOOL paused; - [Export ("paused")] - bool Paused { get; } - - // @property (readonly, nonatomic) BOOL aborted; - [Export ("aborted")] - bool Aborted { get; } - } - - // @protocol DFUServiceDelegate - [Protocol (Name = "_TtP9NordicDFU18DFUServiceDelegate_"), Model (AutoGeneratedName = true)] - interface DFUServiceDelegate - { - // @required -(void)dfuStateDidChangeTo:(enum DFUState)state; - [Abstract] - [Export ("dfuStateDidChangeTo:")] - void DfuStateDidChangeTo (DFUState state); - - // @required -(void)dfuError:(enum DFUError)error didOccurWithMessage:(NSString * _Nonnull)message; - [Abstract] - [Export ("dfuError:didOccurWithMessage:")] - void DfuError (DFUError error, string message); - } - - // @interface DFUServiceInitiator : NSObject - [BaseType (typeof(NSObject), Name = "_TtC9NordicDFU19DFUServiceInitiator")] - [DisableDefaultCtor] - interface DFUServiceInitiator - { - [Wrap ("WeakDelegate")] - [NullAllowed] - DFUServiceDelegate Delegate { get; set; } - - // @property (nonatomic, weak) id _Nullable delegate; - [NullAllowed, Export ("delegate", ArgumentSemantic.Weak)] - NSObject WeakDelegate { get; set; } - - [Wrap ("WeakProgressDelegate")] - [NullAllowed] - DFUProgressDelegate ProgressDelegate { get; set; } - - // @property (nonatomic, weak) id _Nullable progressDelegate; - [NullAllowed, Export ("progressDelegate", ArgumentSemantic.Weak)] - NSObject WeakProgressDelegate { get; set; } - - // @property (nonatomic, weak) id _Nullable logger; - [NullAllowed, Export ("logger", ArgumentSemantic.Weak)] - LoggerDelegate Logger { get; set; } - - // @property (nonatomic, strong) id _Nonnull peripheralSelector; - [Export ("peripheralSelector", ArgumentSemantic.Strong)] - DFUPeripheralSelectorDelegate PeripheralSelector { get; set; } - - // @property (nonatomic) uint16_t packetReceiptNotificationParameter; - [Export ("packetReceiptNotificationParameter")] - ushort PacketReceiptNotificationParameter { get; set; } - - // @property (nonatomic) BOOL forceDfu; - [Export ("forceDfu")] - bool ForceDfu { get; set; } - - // @property (nonatomic) BOOL forceScanningForNewAddressInLegacyDfu; - [Export ("forceScanningForNewAddressInLegacyDfu")] - bool ForceScanningForNewAddressInLegacyDfu { get; set; } - - // @property (nonatomic) NSTimeInterval connectionTimeout; - [Export ("connectionTimeout")] - double ConnectionTimeout { get; set; } - - // @property (nonatomic) NSTimeInterval dataObjectPreparationDelay; - [Export ("dataObjectPreparationDelay")] - double DataObjectPreparationDelay { get; set; } - - // @property (nonatomic) BOOL alternativeAdvertisingNameEnabled; - [Export ("alternativeAdvertisingNameEnabled")] - bool AlternativeAdvertisingNameEnabled { get; set; } - - // @property (copy, nonatomic) NSString * _Nullable alternativeAdvertisingName; - [NullAllowed, Export ("alternativeAdvertisingName")] - string AlternativeAdvertisingName { get; set; } - - // @property (nonatomic) BOOL enableUnsafeExperimentalButtonlessServiceInSecureDfu; - [Export ("enableUnsafeExperimentalButtonlessServiceInSecureDfu")] - bool EnableUnsafeExperimentalButtonlessServiceInSecureDfu { get; set; } - - // @property (nonatomic, strong) DFUUuidHelper * _Nonnull uuidHelper; - [Export ("uuidHelper", ArgumentSemantic.Strong)] - DFUUuidHelper UuidHelper { get; set; } - - // @property (nonatomic) BOOL disableResume; - [Export ("disableResume")] - bool DisableResume { get; set; } - - // -(instancetype _Nonnull)initWithCentralManager:(CBCentralManager * _Nonnull)centralManager target:(CBPeripheral * _Nonnull)target __attribute__((objc_designated_initializer)) __attribute__((deprecated("Use init(queue: DispatchQueue?) instead."))); - [Export ("initWithCentralManager:target:")] - [DesignatedInitializer] - NativeHandle Constructor (CBCentralManager centralManager, CBPeripheral target); - - // -(instancetype _Nonnull)initWithQueue:(dispatch_queue_t _Nullable)queue delegateQueue:(dispatch_queue_t _Nonnull)delegateQueue progressQueue:(dispatch_queue_t _Nonnull)progressQueue loggerQueue:(dispatch_queue_t _Nonnull)loggerQueue centralManagerOptions:(NSDictionary * _Nullable)centralManagerOptions __attribute__((objc_designated_initializer)); - [Export ("initWithQueue:delegateQueue:progressQueue:loggerQueue:centralManagerOptions:")] - [DesignatedInitializer] - NativeHandle Constructor ([NullAllowed] DispatchQueue queue, DispatchQueue delegateQueue, DispatchQueue progressQueue, DispatchQueue loggerQueue, [NullAllowed] NSDictionary centralManagerOptions); - - // -(DFUServiceInitiator * _Nonnull)withFirmware:(DFUFirmware * _Nonnull)file __attribute__((warn_unused_result(""))); - [Export ("withFirmware:")] - DFUServiceInitiator WithFirmware (DFUFirmware file); - - // -(DFUServiceController * _Nullable)start __attribute__((warn_unused_result(""))) __attribute__((deprecated("Use start(target: CBPeripheral) instead."))); - [NullAllowed, Export ("start")] - [Verify (MethodToProperty)] - DFUServiceController Start { get; } - - // -(DFUServiceController * _Nullable)startWithTarget:(CBPeripheral * _Nonnull)target __attribute__((warn_unused_result(""))); - [Export ("startWithTarget:")] - [return: NullAllowed] - DFUServiceController StartWithTarget (CBPeripheral target); - - // -(DFUServiceController * _Nullable)startWithTargetWithIdentifier:(NSUUID * _Nonnull)uuid __attribute__((warn_unused_result(""))); - [Export ("startWithTargetWithIdentifier:")] - [return: NullAllowed] - DFUServiceController StartWithTargetWithIdentifier (NSUuid uuid); - } - - // @interface DFUUuid : NSObject - [BaseType (typeof(NSObject), Name = "_TtC9NordicDFU7DFUUuid")] - [DisableDefaultCtor] - interface DFUUuid - { - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull uuid; - [Export ("uuid", ArgumentSemantic.Strong)] - CBUUID Uuid { get; } - - // @property (readonly, nonatomic) enum DFUUuidType type; - [Export ("type")] - DFUUuidType Type { get; } - - // -(instancetype _Nonnull)initWithUUID:(CBUUID * _Nonnull)withUUID forType:(enum DFUUuidType)forType __attribute__((objc_designated_initializer)); - [Export ("initWithUUID:forType:")] - [DesignatedInitializer] - NativeHandle Constructor (CBUUID withUUID, DFUUuidType forType); - } - - // @interface DFUUuidHelper : NSObject - [BaseType (typeof(NSObject), Name = "_TtC9NordicDFU13DFUUuidHelper")] - interface DFUUuidHelper - { - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull legacyDFUService; - [Export ("legacyDFUService", ArgumentSemantic.Strong)] - CBUUID LegacyDFUService { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull legacyDFUControlPoint; - [Export ("legacyDFUControlPoint", ArgumentSemantic.Strong)] - CBUUID LegacyDFUControlPoint { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull legacyDFUPacket; - [Export ("legacyDFUPacket", ArgumentSemantic.Strong)] - CBUUID LegacyDFUPacket { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull legacyDFUVersion; - [Export ("legacyDFUVersion", ArgumentSemantic.Strong)] - CBUUID LegacyDFUVersion { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull secureDFUService; - [Export ("secureDFUService", ArgumentSemantic.Strong)] - CBUUID SecureDFUService { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull secureDFUControlPoint; - [Export ("secureDFUControlPoint", ArgumentSemantic.Strong)] - CBUUID SecureDFUControlPoint { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull secureDFUPacket; - [Export ("secureDFUPacket", ArgumentSemantic.Strong)] - CBUUID SecureDFUPacket { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull buttonlessExperimentalService; - [Export ("buttonlessExperimentalService", ArgumentSemantic.Strong)] - CBUUID ButtonlessExperimentalService { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull buttonlessExperimentalCharacteristic; - [Export ("buttonlessExperimentalCharacteristic", ArgumentSemantic.Strong)] - CBUUID ButtonlessExperimentalCharacteristic { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull buttonlessWithoutBonds; - [Export ("buttonlessWithoutBonds", ArgumentSemantic.Strong)] - CBUUID ButtonlessWithoutBonds { get; } - - // @property (readonly, nonatomic, strong) CBUUID * _Nonnull buttonlessWithBonds; - [Export ("buttonlessWithBonds", ArgumentSemantic.Strong)] - CBUUID ButtonlessWithBonds { get; } - - // -(instancetype _Nonnull)initWithCustomUuids:(NSArray * _Nonnull)uuids; - [Export ("initWithCustomUuids:")] - NativeHandle Constructor (DFUUuid[] uuids); - } - - // @interface IntelHex2BinConverter : NSObject - [BaseType (typeof(NSObject), Name = "_TtC9NordicDFU21IntelHex2BinConverter")] - interface IntelHex2BinConverter - { - } - - // @interface LegacyDFUServiceInitiator : DFUServiceInitiator - [BaseType (typeof(DFUServiceInitiator), Name = "_TtC9NordicDFU25LegacyDFUServiceInitiator")] - interface LegacyDFUServiceInitiator - { - // -(DFUServiceController * _Nullable)startWithTargetWithIdentifier:(NSUUID * _Nonnull)uuid __attribute__((warn_unused_result(""))); - [Export ("startWithTargetWithIdentifier:")] - [return: NullAllowed] - DFUServiceController StartWithTargetWithIdentifier (NSUuid uuid); - - // -(instancetype _Nonnull)initWithCentralManager:(CBCentralManager * _Nonnull)centralManager target:(CBPeripheral * _Nonnull)target __attribute__((objc_designated_initializer)) __attribute__((deprecated("Use init(queue: DispatchQueue?) instead."))); - [Export ("initWithCentralManager:target:")] - [DesignatedInitializer] - NativeHandle Constructor (CBCentralManager centralManager, CBPeripheral target); - - // -(instancetype _Nonnull)initWithQueue:(dispatch_queue_t _Nullable)queue delegateQueue:(dispatch_queue_t _Nonnull)delegateQueue progressQueue:(dispatch_queue_t _Nonnull)progressQueue loggerQueue:(dispatch_queue_t _Nonnull)loggerQueue centralManagerOptions:(NSDictionary * _Nullable)centralManagerOptions __attribute__((objc_designated_initializer)); - [Export ("initWithQueue:delegateQueue:progressQueue:loggerQueue:centralManagerOptions:")] - [DesignatedInitializer] - NativeHandle Constructor ([NullAllowed] DispatchQueue queue, DispatchQueue delegateQueue, DispatchQueue progressQueue, DispatchQueue loggerQueue, [NullAllowed] NSDictionary centralManagerOptions); - } - - // @protocol LoggerDelegate - [Protocol (Name = "_TtP9NordicDFU14LoggerDelegate_"), Model (AutoGeneratedName = true)] - interface LoggerDelegate - { - // @required -(void)logWith:(enum LogLevel)level message:(NSString * _Nonnull)message; - [Abstract] - [Export ("logWith:message:")] - void Message (LogLevel level, string message); - } - - // @interface SecureDFUServiceInitiator : DFUServiceInitiator - [BaseType (typeof(DFUServiceInitiator), Name = "_TtC9NordicDFU25SecureDFUServiceInitiator")] - interface SecureDFUServiceInitiator - { - // -(DFUServiceController * _Nullable)startWithTargetWithIdentifier:(NSUUID * _Nonnull)uuid __attribute__((warn_unused_result(""))); - [Export ("startWithTargetWithIdentifier:")] - [return: NullAllowed] - DFUServiceController StartWithTargetWithIdentifier (NSUuid uuid); - - // -(instancetype _Nonnull)initWithCentralManager:(CBCentralManager * _Nonnull)centralManager target:(CBPeripheral * _Nonnull)target __attribute__((objc_designated_initializer)) __attribute__((deprecated("Use init(queue: DispatchQueue?) instead."))); - [Export ("initWithCentralManager:target:")] - [DesignatedInitializer] - NativeHandle Constructor (CBCentralManager centralManager, CBPeripheral target); - - // -(instancetype _Nonnull)initWithQueue:(dispatch_queue_t _Nullable)queue delegateQueue:(dispatch_queue_t _Nonnull)delegateQueue progressQueue:(dispatch_queue_t _Nonnull)progressQueue loggerQueue:(dispatch_queue_t _Nonnull)loggerQueue centralManagerOptions:(NSDictionary * _Nullable)centralManagerOptions __attribute__((objc_designated_initializer)); - [Export ("initWithQueue:delegateQueue:progressQueue:loggerQueue:centralManagerOptions:")] - [DesignatedInitializer] - NativeHandle Constructor ([NullAllowed] DispatchQueue queue, DispatchQueue delegateQueue, DispatchQueue progressQueue, DispatchQueue loggerQueue, [NullAllowed] NSDictionary centralManagerOptions); - } -} diff --git a/Laerdal.Dfu.Bindings.iOS/Sharpie/StructsAndEnums.cs b/Laerdal.Dfu.Bindings.iOS/Sharpie/StructsAndEnums.cs deleted file mode 100644 index ba9ed2c..0000000 --- a/Laerdal.Dfu.Bindings.iOS/Sharpie/StructsAndEnums.cs +++ /dev/null @@ -1,112 +0,0 @@ -using ObjCRuntime; - -namespace Laerdal.Dfu.Bindings.iOS -{ - [Native] - public enum DFUError : long - { - RemoteLegacyDFUSuccess = 1, - RemoteLegacyDFUInvalidState = 2, - RemoteLegacyDFUNotSupported = 3, - RemoteLegacyDFUDataExceedsLimit = 4, - RemoteLegacyDFUCrcError = 5, - RemoteLegacyDFUOperationFailed = 6, - RemoteSecureDFUSuccess = 11, - RemoteSecureDFUOpCodeNotSupported = 12, - RemoteSecureDFUInvalidParameter = 13, - RemoteSecureDFUInsufficientResources = 14, - RemoteSecureDFUInvalidObject = 15, - RemoteSecureDFUSignatureMismatch = 16, - RemoteSecureDFUUnsupportedType = 17, - RemoteSecureDFUOperationNotPermitted = 18, - RemoteSecureDFUOperationFailed = 20, - RemoteSecureDFUExtendedError = 21, - RemoteExtendedErrorWrongCommandFormat = 22, - RemoteExtendedErrorUnknownCommand = 23, - RemoteExtendedErrorInitCommandInvalid = 24, - RemoteExtendedErrorFwVersionFailure = 25, - RemoteExtendedErrorHwVersionFailure = 26, - RemoteExtendedErrorSdVersionFailure = 27, - RemoteExtendedErrorSignatureMissing = 28, - RemoteExtendedErrorWrongHashType = 29, - RemoteExtendedErrorHashFailed = 30, - RemoteExtendedErrorWrongSignatureType = 31, - RemoteExtendedErrorVerificationFailed = 32, - RemoteExtendedErrorInsufficientSpace = 33, - RemoteExperimentalButtonlessDFUSuccess = 9001, - RemoteExperimentalButtonlessDFUOpCodeNotSupported = 9002, - RemoteExperimentalButtonlessDFUOperationFailed = 9004, - RemoteButtonlessDFUSuccess = 91, - RemoteButtonlessDFUOpCodeNotSupported = 92, - RemoteButtonlessDFUOperationFailed = 94, - RemoteButtonlessDFUInvalidAdvertisementName = 95, - RemoteButtonlessDFUBusy = 96, - RemoteButtonlessDFUNotBonded = 97, - FileNotSpecified = 101, - FileInvalid = 102, - ExtendedInitPacketRequired = 103, - InitPacketRequired = 104, - FailedToConnect = 201, - DeviceDisconnected = 202, - BluetoothDisabled = 203, - ServiceDiscoveryFailed = 301, - DeviceNotSupported = 302, - ReadingVersionFailed = 303, - EnablingControlPointFailed = 304, - WritingCharacteristicFailed = 305, - ReceivingNotificationFailed = 306, - UnsupportedResponse = 307, - BytesLost = 308, - CrcError = 309, - InvalidInternalState = 500 - } - - public enum DFUFirmwareType : byte - { - Softdevice = 1, - Bootloader = 2, - Application = 4, - SoftdeviceBootloader = 3, - SoftdeviceBootloaderApplication = 7 - } - - [Native] - public enum DFUState : long - { - Connecting = 0, - Starting = 1, - EnablingDfuMode = 2, - Uploading = 3, - Validating = 4, - Disconnecting = 5, - Completed = 6, - Aborted = 7 - } - - [Native] - public enum DFUUuidType : long - { - LegacyService = 0, - LegacyControlPoint = 1, - LegacyPacket = 2, - LegacyVersion = 3, - SecureService = 4, - SecureControl = 5, - SecurePacket = 6, - ButtonlessService = 7, - ButtonlessCharacteristic = 8, - ButtonlessWithoutBondSharing = 9, - ButtonlessWithBondSharing = 10 - } - - [Native] - public enum LogLevel : long - { - Debug = 0, - Verbose = 1, - Info = 5, - Application = 10, - Warning = 15, - Error = 20 - } -} diff --git a/Laerdal.Scripts/Laerdal.Builder.targets b/Laerdal.Scripts/Laerdal.Builder.targets index b35b3ca..cdc02dd 100644 --- a/Laerdal.Scripts/Laerdal.Builder.targets +++ b/Laerdal.Scripts/Laerdal.Builder.targets @@ -13,9 +13,9 @@ + - @@ -43,6 +43,16 @@ true true + + + + + + + + + + 4.15.3 $(BUILD_BUILDID) @@ -68,15 +78,22 @@ <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Configuration=$(Configuration) <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);PackageOutputPath=$(PackageOutputPath) + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);SourceRoot=$(Laerdal_RootDirectory_Folderpath)/Laerdal.McuMgr.Bindings.MacCatalyst/ + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Laerdal_Version_Full=$(Laerdal_Version_Full) <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Laerdal_Github_Access_Token=$(Laerdal_Github_Access_Token) + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Laerdal_Bindings_MacCatalyst___Sdk_Version=$(Laerdal_Bindings_MacCatalyst___Sdk_Version) + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Laerdal_Bindings_MacCatalyst___Sdk_Version=$(Laerdal_Bindings_MacCatalyst___Sdk_Version) + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path=$(Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path) + <_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters);Laerdal_Bindings_MacCatalyst___DotnetTargetPlatformVersion=$(Laerdal_Bindings_MacCatalyst___DotnetTargetPlatformVersion) - - - - + + + + +