prebid / prebid-mobile-ios

Prebid Mobile SDK for iOS applications
Apache License 2.0
48 stars 93 forks source link

Problem with printing Logging and build dynamic Framework from source code #1015

Open maiquannguyen opened 5 months ago

maiquannguyen commented 5 months ago

1. Logging wont write to file when not in debug mode, and should not using print for log The logging function wont work when scheme not in debug mode, both from write log to file and print the message to console. I understand that should not print log to console when not in debug mode, but instead of using debugPrint, in Log file the code was like this

func print(_ object: Any) {
    // Only allowing in DEBUG mode
    #if DEBUG
    Swift.print(object)
    #endif
}

Also the function for check if logging enable isLoggingEnabled, always return false when it is not in Debug.

private class func isLoggingEnabled(for currentLevel: LogLevel) -> Bool {
        #if !(DEBUG)
        return false
        #endif

        if currentLevel.rawValue < Log.logLevel.rawValue {
            return false
        }

        return true
    }

It will block write log to file, it should not have check for DEBUG, if using debugPrint function instead of print.

2. The xcframework build command guide from readme file is not really working The current command for archive simulator framework only work on simulator on macbook with intel chip, it not work on macbook which run m1 chip.

xcodebuild archive \
    only_active_arch=NO \
    defines_module=YES \
    SKIP_INSTALL=NO \
    -workspace PrebidMobile.xcworkspace \
    -scheme "${schemes[$n]}" \
    -configuration Release \
    -arch x86_64 \
    -sdk "iphonesimulator" \
    -derivedDataPath $XCODE_BUILD_DIR \
    -archivePath "$XCODE_ARCHIVE_DIR/${schemes[$n]}$POSTFIX_SIMULATOR.xcarchive" \

Because the arch is x86_64, now m1 macbook simulator already run with arm architecture chip. It should be update like this

xcodebuild archive \
    only_active_arch=NO \
    defines_module=YES \
    SKIP_INSTALL=NO \
    -workspace PrebidMobile.xcworkspace \
    -scheme "${schemes[$n]}" \
    -configuration Release \
    -destination 'generic/platform=iOS Simulator' \
    -derivedDataPath $XCODE_BUILD_DIR \
    -archivePath "$XCODE_ARCHIVE_DIR/${schemes[$n]}$POSTFIX_SIMULATOR.xcarchive" \

So it can run on both Macbook with intel chip and Apple chip simulators.

May i suggest a PR for this ?

jsligh commented 4 months ago

@maiquannguyen you are free to create a PR for fixes for these issues. If you do not have the time and/or ability to fix this yourself, this will be added to the list of issues myself and the Prebid Mobile Committee will triage.