Post

Replies

Boosts

Views

Activity

How do I exclude linking a library for simulator builds
I have a third party library added to my project as ThirdParty.framework, but it only supports real device. I want to make my project still build for simulators but exclude this library and any references of importing it. I tried a few things, for example in the target's build phase "Link Binary With Libraries" set this framework as "Optional", and in the code I have: #if !targetEnvironment(simulator) import ThirdParty class SomeClass: ProtocolFromThirdParty { // ... } #endif Also some view that has reference to this class: import SwiftUI #if targetEnvironment(simulator) struct TestViewSimulator: View { var body: some View { Text("See this view on real device") } } #else struct TestView: View { @StateObject var example = SomeClass() var body: some View { // ... } } #endif But still when I build for simulator, it still gives error for the linking issue: Building for 'iOS-simulator', but linking in object file (/<Path>/ThirdParty.framework/ThirdPartySDK[arm64][2](someobject.o)) built for 'iOS' Building to a real device works as expected. Any suggestions I could make it build on simulators? (I'd like to isolate this screen only for real device and not impacting other parts of the app)
2
0
770
Jun ’24