Issue with OSLog on swift XCFramework swiftinterface

42 views Asked by At

I am creating a very simple XCFramework. The framework has only one class and one function:

import Foundation
import OSLog

public class MyFrameWork {
    public func setLog(log: os.OSLog) {
        
    }
    
    public func sendLogs(entries: [OSLogEntry]) {
        
    }
}

I then archive it, and create an XCFramework using command line tools as in the following script:

function archive() {
    xcodebuild archive \
        -project "./TestFramework.xcodeproj" \
        -scheme "TestFramework" \
        -configuration "Release" \
        -destination 'generic/platform=iOS' \
        -archivePath "$BASE_PATH/TestFramework.framework-iphoneos.xcarchive" \
        SKIP_INSTALL=NO \
        BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

    xcodebuild archive \
        -project "./TestFramework.xcodeproj" \
        -scheme "TestFramework" \
        -configuration "Release" \
        -destination 'generic/platform=iOS Simulator' \
        -archivePath "$BASE_PATH/TestFramework.framework-iphonesimulator.xcarchive" \
        SKIP_INSTALL=NO \
        BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
}

function create_framework() {
    xcodebuild -create-xcframework \
        -framework "$BASE_PATH/TestFramework.framework-iphoneos.xcarchive/Products/Library/Frameworks/TestFramework.framework" \
        -framework "$BASE_PATH/TestFramework.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/TestFramework.framework" \
        -output "$OUTPUT_PATH/TestFramework.xcframework"
}

archive
create_framework

Since I build for distribution the following swift interface file is created

// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
// swift-module-flags: -target arm64-apple-ios17.2 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -module-name TestFramework
// swift-module-flags-ignorable: -enable-bare-slash-regex
import Foundation
import OSLog
import Swift
@_exported import TestFramework
import _Concurrency
import _StringProcessing
import _SwiftConcurrencyShims
@_hasMissingDesignatedInitializers public class MyFrameWork {
  public func setLog(log: os.OSLog)
  public func sendLogs(entries: [OSLog.OSLogEntry])
  @objc deinit
}

Notice the OSLogEntry is written as OSLog.OSLogEntry where OSLog is the OSLog Module.

However, when I put this framework in a test project I receive a build time error:

'OSLogEntry' is not a member type of class 'os.OSLog'

Since the compiler interprets OSLog as the OSLog class under os Module and not OSLog Module.

All help will be appreciated.

0

There are 0 answers