Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How should I build for iOS Simulator? I need to be able to compile simulators (even if I don't run the model in them) #2929

Open
bryan1anderson opened this issue Sep 20, 2024 · 8 comments
Labels
question Question about the usage

Comments

@bryan1anderson
Copy link

I followed the SDK guide for implementing this into an iOS app. That works. I have it compiling on device. However, if I try to use SwiftUI previews or try to build to simulator I get

ld: warning: no platform load command found in '/Users/user/Developer/JournalApp/dist/lib/libmodel_iphone.a2', assuming: iOS-simulator
ld: warning: no platform load command found in '/Users/user/Developer/JournalApp/dist/lib/libmodel_iphone.a3', assuming: iOS-simulator
ld: warning: no platform load command found in '/Users/user/Developer/JournalApp/dist/lib/libmodel_iphone.a4', assuming: iOS-simulator
ld: warning: no platform load command found in '/Users/user/Developer/JournalApp/dist/lib/libmodel_iphone.a5', assuming: iOS-simulator
ld: warning: no platform load command found in '/Users/user/Developer/JournalApp/dist/lib/libmodel_iphone.a6', assuming: iOS-simulator
ld: warning: no platform load command found in '/Users/user/Developer/JournalApp/dist/lib/libmodel_iphone.a7', assuming: iOS-simulator
ld: warning: no platform load command found in '/Users/user/Developer/JournalApp/dist/lib/libmodel_iphone.a8', assuming: iOS-simulator
ld: warning: no platform load command found in '/Users/user/Developer/JournalApp/dist/lib/libmodel_iphone.a9', assuming: iOS-simulator
ld: building for 'iOS-simulator', but linking in object file (/Users/user/Developer/JournalApp/dist/lib/libmlc_llm.a2) built for 'iOS'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@bryan1anderson bryan1anderson added the question Question about the usage label Sep 20, 2024
@tqchen
Copy link
Contributor

tqchen commented Sep 21, 2024

Unfortunately the SDK relies on GPU so do not work on simulator for now. One way to run might be to build for iPad on Mac.

@bryan1anderson
Copy link
Author

So having this an app completely disables the ability to run the app on simulator?

@PabloButron
Copy link

Unfortunately the SDK relies on GPU so do not work on simulator for now. One way to run might be to build for iPad on Mac.

the easiest way is the @tqchen solution, but always test on physical device, because these kind of bugs can happen:
#2904 (comment)

@bryan1anderson
Copy link
Author

I think ideally all this should be housed in a framework that is marked unavailable on simulator
#if canImport(_) could then handle it.
@PabloButron @tqchen has anyone tried to house the entire MLC bundle in a separate framework?

@tqchen
Copy link
Contributor

tqchen commented Sep 24, 2024

I am not that familar with iOS part of such dev, but the original swift source is here https://github.com/mlc-ai/mlc-llm/tree/main/ios/MLCSwift, feel free to take a look and see if any change can be made

@bryan1anderson
Copy link
Author

It seems like it would be ideal for there to be a script that generates an XCFramework with all that is necessary. I tried to make some progress on that last night but am running into so many linker issues. Is there someone who was responsible for generating the Swift package that is familiar with static library linking?

@bryan1anderson
Copy link
Author

@PabloButron i have just spend the better part of two evenings trying and failing to compile this on simulator. I need to be able to develop using SwiftUI previews on simulators.

I do not need to run the actual model on a sim.

I've tried xcframeworks but hit dead ends. I've tried to mimic the steps for integrating MLC into a code project for both frameworks and static libraries.

I'm having a very hard time of it. So if you have any ideas, even if not easy, I could use them

@bryan1anderson
Copy link
Author

bryan1anderson commented Sep 27, 2024

Of course, I can conditionalize all of the other Swift linker flags… But how to conditionally link this Library?

It's been a huge pain that this doesn't work out of the box for XC framework archives. You can't set the build for release flag to true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about the usage
Projects
None yet
Development

No branches or pull requests

3 participants