# Can't access the macro-generated code from obj-c

**URL:** <https://forums.swift.org/t/cant-access-the-macro-generated-code-from-obj-c/74559>\
**Category:** Using Swift\
**Tags:** swift-macro, macro\
**Created:** [September 13, 2024, 9:49am UTC](https://forums.swift.org/t/cant-access-the-macro-generated-code-from-obj-c/74559 "2024-09-13T09:49:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlch911](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/mlch911/32/19832_2.png) [@mlch911](https://forums.swift.org/u/mlch911)\
**Post date:** [September 13, 2024, 9:49am UTC](https://forums.swift.org/t/cant-access-the-macro-generated-code-from-obj-c/74559/1 "2024-09-13T09:49:45Z")

</div>

I'm writing a swift-macro to expand a function with param which has default value. I want it to write those convenient functions exposed to oc.  
I have done this macro. But those functions are not accessable from obj-c. Anyone can help?

original code:

```swift
@ExpandVariantsForOC
func testExpandVariantsForOC(test topic: Int, _ option: Double = 0, h_src: String? = nil) {
    print(topic)
}

```

expanded code:

```swift
@objc
@available(swift, obsoleted: 1.0)
func testExpandVariantsForOC(test topic: Int) {
    testExpandVariantsForOC(test: topic, 0, h_src: nil)
}

@objc
@available(swift, obsoleted: 1.0)
func testExpandVariantsForOC(test topic: Int, _ option: Double) {
    testExpandVariantsForOC(test: topic, option, h_src: nil)
}

@objc
@available(swift, obsoleted: 1.0)
func testExpandVariantsForOC(test topic: Int, h_src: String?) {
    testExpandVariantsForOC(test: topic, 0, h_src: h_src)
}

```
