简体   繁体   中英

Xcode 6.3 can't find watchkit extension swift file

We have a mixed code base in our WatchKit extension. In a couple of Objective-C files, we need access to the Swift code base from the extension. We've been using the following import:

#import "MyProject_WatchKit_Extension-Swift.h"

This has worked fine for the entire dev process.

I am in the process of moving to Xcode 6.3. After updating our code base to Swift 1.2, I'm getting File not found for my extension-swift file.

What I've tried:

  • Full clean w/ cmd + opt + shift + k
  • Deleted derived data
  • Deleted and reinstalled Xcode
  • Changed extension module name and used that import
  • Reverted to pre update commits and updated manually as opposed to the automated: `Convert > To Latest Swift>

Anybody have any thoughts.

It seems Xcode has changed it's default behaviour for file paths defined in the target's build settings. Previously it was happy to look recursively for a file within the project directory, so you could just define the file name and you were good to go. Now you need to prepend the folder name.

Go to your targets build settings and search for 'Objective-C Bridging Header', you'll probably see the entry 'MyProject_WatchKit_Extension-Swift.h'. You need to prepend the path to the file relative to the root project folder.

If your folder was structured as so:

 PROJECT_ROOT_FOLDER
 - CLASSES_FOLDER
 -- MyProject_WatchKit_Extension-Swift.h
 - .xcodeproj
 - TESTS_FOLDER

Then you would need to change the value to

CLASSES_FOLDER/MyProject_WatchKit_Extension-Swift.h

I was able to figure out the answer by editing the Objective-C Generated Interface Header Name field in the extension's build settings. I had never previously edited this field, and I'm not sure how the value was removed. I'll leave this here in case others have the same problem:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM