# New Xcode modifier conditional compilation

**URL:** <https://forums.swift.org/t/new-xcode-modifier-conditional-compilation/50324>\
**Category:** Using Swift\
**Tags:** xcode, availability\
**Created:** [July 9, 2021, 1:51pm UTC](https://forums.swift.org/t/new-xcode-modifier-conditional-compilation/50324 "2021-07-09T13:51:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [July 9, 2021, 1:51pm UTC](https://forums.swift.org/t/new-xcode-modifier-conditional-compilation/50324/1 "2021-07-09T13:51:23Z")

</div>

i'm using this code with the new searchable modifier available with Xcode-13 beta. is there any way to have some conditional compilation check to compile this with Xcode 12? obviously i can't built with it to those newer platforms but i'd expect it'd be able to compile and deploy to the older platforms.

```
struct MyView: View {
    @State private var searchText = ""
    
    var body: some View {
        if #available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) {
            SomeView(searchText: searchText)
                .searchable(text: $searchText) // no member 'searchable' error
        } else {
            // fallback
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![suyashsrijan](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/suyashsrijan/32/5292_2.png) [@suyashsrijan](https://forums.swift.org/u/suyashsrijan)\
**Post date:** [July 9, 2021, 2:05pm UTC](https://forums.swift.org/t/new-xcode-modifier-conditional-compilation/50324/2 "2021-07-09T14:05:59Z")

</div>

You can use `#if compiler(>= 5.5)` perhaps, as Swift 5.5 ships with Xcode 13.

```swift
struct MyView: View {
    @State private var searchText = ""
    
    var body: some View {
        #if compiler(>= 5.5)
          if #available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) {
            SomeView(searchText: searchText)
                .searchable(text: $searchText) // no member 'searchable' error
          } else {
            // fallback
          }
        #else
          // fallback
        #endif
    }
}

```

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [July 9, 2021, 2:59pm UTC](https://forums.swift.org/t/new-xcode-modifier-conditional-compilation/50324/3 "2021-07-09T14:59:47Z")

</div>

this works indeed, thanks.

when i run this app under Xcode 13 beta Xcode + iOS14 simulator the app crashes, probably because it is beta after all.

```
struct ContentView: View {
    @State private var searchText = ""
    
    var body: some View {
        if #available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) {
            #if compiler(>=5.5)
            Text("Hello-1")
                .searchable(text: $searchText)
            #else
            Text("Hello-2")
            #endif
        } else {
            Text("Hello-3")
        }
    }
}

```

Xcode 12.5 + iOS 14 simulator: "Hello-3"

Xcode 12.5 + iOS 15 simulator: "Hello-2"

Xcode 13 Beta + iOS 15 simulator: "Hello-1"

Xcode 13 Beta + iOS 14 simulator: crash on load:

" **dyld: Symbol not found: \_$s7SwiftUI4ViewPAAE10searchable4text9placementQrAA7BindingVySSG\_AA20SearchFieldPlacementVtFQOMQ**"
