Code signing after adding Swift to Watch Extension

I have a project that was originally ObjC, iOS 8, WatchKit 1. It's been upgraded to iOS 9/WatchKit 2. I'm using Xcode 7, beta 5.


Everything was running swimmingly until I added a Swift class to the WatchKit Extension. Short description: Xcode is adding the Swift libraries to the extension after code signing, which results in the Watch refusing to run the app.


I've confirmed this by running this:


codesign --verify --verbose myWatchApp.app


which returns:


/Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app: a sealed resource is missing or invalid
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/Frameworks/libswiftCoreLocation.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/Frameworks/libswiftCoreGraphics.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/Frameworks/libswiftDispatch.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/Frameworks/libswiftDarwin.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/Frameworks/libswiftFoundation.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/Frameworks/libswiftWatchKit.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/Frameworks/libswiftUIKit.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/Frameworks/libswiftObjectiveC.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/PlugIns/myApp WatchKit Extension.appex/Frameworks/libswiftCoreLocation.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/PlugIns/myApp WatchKit Extension.appex/Frameworks/libswiftDispatch.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/PlugIns/myApp WatchKit Extension.appex/Frameworks/libswiftCoreGraphics.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/PlugIns/myApp WatchKit Extension.appex/Frameworks/libswiftObjectiveC.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/PlugIns/myApp WatchKit Extension.appex/Frameworks/libswiftDarwin.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/PlugIns/myApp WatchKit Extension.appex/Frameworks/libswiftUIKit.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/PlugIns/myApp WatchKit Extension.appex/Frameworks/libswiftWatchKit.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/PlugIns/myApp WatchKit Extension.appex/Frameworks/libswiftFoundation.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/Frameworks/libswiftCore.dylib
file modified: /Users/myname/Library/Developer/Xcode/DerivedData/myApp-eznjrdjylikczqbwuajqlktierch/Build/Products/Debug-iphoneos/myApp.app/Watch/myApp Watch App.app/PlugIns/myApp WatchKit Extension.appex/Frameworks/libswiftCore.dylib


When attempting to install the Watch app via the iPhone, this is the error I see on the Watch:


Aug 13 12:18:55 My-AppleWatch installd[35] <Error>: 0x1f1ac000 +[MICodeSigningVerifier _validateSignatureAndCopyInfoForURL:withOptions:error:]: 142: Failed to verify code signature of /private/var/mobile/Library/Caches/com.apple.mobile.installd.staging/temp.Zi9FHv/extracted/Payload/myApp Watch App.app : 0xe8008017 (A signed resource has been added, modified, or deleted.)


While researching the problem I did find this:


http://stackoverflow.com/questions/25639270/xcode-6-beta-7a-signed-resource-has-been-added-modified-or-deleted/25707565#25707565


which suggests adding:

touch "${PROJECT_DIR}/SOME SWIFT FILE IN EXTENSION.SWIFT"


to the Extension build phase. This did not change the result (the above answer was created prior to watchOS 2).


I do have Swift in the main iOS app, which runs fine.


At this point I'm stuck, with the only option to back out the Swift code from the Watch Extension and rewrite in ObjC. That's fine, but I'm trying to write new classes in Swift...


Thanks!

Hi Mitch,


This will be slim comfort but both the Beta 4 and Beta 5 release notes mention/ask:


WatchKit Known Issues

Some apps that run in Simulator may fail to launch on device.

  • Note: If you see this, please file a Radar so that we can follow up to obtain logs.


You can file a radar here: https://bugreport.apple.com/


-Max

Code signing after adding Swift to Watch Extension
 
 
Q