I have an app that supports Watchkit. When I run the application onto the iPhone, it builds fine but displays an alert in Xcode "The WatchKit app has an invalid stub executable". I have used the bundle identifier properly and installed the provisioning profiles and certificates properly as well. Any clue on this, please?
Pls note that I am building this project in Xcode 10.3 as the included frameworks are still in Swift 4.2 and couldn’t be upgraded to Swift 5.
2
Answers
This was a known issue in Xcode 10 beta where the proposed solution was to clean the build folder and run again. I imagine you’ve tried that of course, but I have to mention it.
Also ensure you have selected to "Trust this computer" on the Apple Watch. If you haven’t done that, then with Xcode open;
a) Connect the iPhone that you have your watch paired to the computer via cable.
b) Restart Apple Watch
c) Accept Trust This Computer when prompted on Apple Watch.
This error is more related to ipa making process than any project settings..
Avoid using older xcodes just to make ipa from the archive created using latest xcode as sometimes we don’t have permission to export build.
You can use xcodebuild command to create ipa from archive and resolve this error, but can’t make it to appstore as xocdebuild also come with a bug that it doesn’t create support directories for watchapp (WatchKitSupport) and swift (SwiftSupport). However with this ipa, application will get installed on Apple Watch without any errors.
Also you may find a valid command which would make valid ipa but other options also have the same issues. Eg xcrun
Solution to this is make this folder structure by yourself and create ipa.
Related links:
1- Binary Rejection – Invalid Watchkit Support
2- How to generate .ipa file from command line with watchkit app
3- Getting error in watch app installation