Skip to content

Escape invalid characters in file names when generating bridging code #63

@marcprux

Description

@marcprux

I have a NativeViewModel+Bridging.swift file with the code:

public var swiftClosure1Var: (Int) -> String = { i in "value = \(i)" }

in a package with skip.yml:

skip:
  mode: 'swift'
  bridging: true

It raises the following compile error in the child SKIP_BRIDGE build because it is tying to generate a name with the "+" in it. We should escape out invalid characters from the file name (like maybe replacing it with the codepoint like JNI signatures, or just an underscore).

/Users/marc/Library/Developer/Xcode/DerivedData/Skip-Everything-aqywrhrzhkbvfseiqgxuufbdwdft/SourcePackages/plugins/skipapp-appdroid.output/AppDroidModelTests/skipstone/AppDroidModel/.build/AppDroidModel/swift/plugins/outputs/swift/AppDroidModel/destination/skipstone/SkipBridgeGenerated/NativeViewModel+Bridging_Bridge.swift:32:21: error: expected '(' in argument list of function declaration
30 | }
31 | @_cdecl("Java_app_droid_model_NativeViewModel+BridgingKt_Swift_1swiftClosure1Var")
32 | func NativeViewModel+BridgingKt_Swift_swiftClosure1Var(_ Java_env: JNIEnvPointer, _ Java_target: JavaObjectPointer) -> JavaObjectPointer {
   |                     `- error: expected '(' in argument list of function declaration
33 |     return SwiftClosure1.javaObject(for: swiftClosure1Var)!
34 | }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions