3

I have previously built a Keyboard extension project that has components of both Swift and Objective C. I'd like to built a new Keyboard app based on my previous app, with the simple goal of changing the name, keyboard UI and some keyboard mechanics.

I followed the guidelines here on duplicating and renaming an XCode Project. I even managed to get the project to compile after changing the Bundle IDs (for both the container app and the underlying keyboard). However, because of the name of the Targets have now changed, I am get the error that the following files:

#import "NewNameContainerApp-Swift.h"
#import "NewNameContainerApp-Bridging-Header.h"

cannot be found (these errors persist despite me manually changing OldNameContainerApp-Bridging-Header.h to NewNameContainerApp-Bridging-Header.h. It seems that the project has not regenerated a new set of bridging header and -Swift.h files matching the names of my new target.

My question is - is there a way to force XCode to regenerate a new set of these files? And if not, where do I find OldNameContainerApp-Swift.h so I can manually change it to NewNameContainerApp-Swift.h?

Thanks!

Community
  • 1
  • 1
daspianist
  • 5,336
  • 8
  • 50
  • 94

2 Answers2

2

Check in your applications Define-Module in the build section. Update it to your latest project name. To find it easily just search for Defines-Module and see if it needs updating. If it is updated try cleaning your project or deleting your Derived Data

Jesse Onolemen
  • 1,277
  • 1
  • 15
  • 32
  • Thanks for the suggestion! Define Module is set to "Yes" in the new app, and Derived Data has been deleted, but unfortunately the issue persists. – daspianist Apr 02 '15 at 22:07
  • Is there a snapshot of your project before the change? Usualy with changing project names xcode would create a snapshot of your project. If you just wanted to change the name of the app then you can do so in the info.plist. – Jesse Onolemen Apr 02 '15 at 22:45
  • That's indeed true, and good point. I am actually creating a whole new app, and therefore had to change the Bundle ID as well, which initially caused the problem. I managed to figure out a workaround where the container app's bundle ID was modified, but the extension bundle ID kept part of the original app's name, and this allowed it to work. – daspianist Apr 02 '15 at 22:54
0

I have found no way to force Xcode to regenerate these files. Removing them just causes builds to fail. The only reliable method is to do a clean build, or removed DerivedData and rebuild (effectively the same solution).

When renaming an Objective-C/Swift mixed app, the following additional changes have to be performed for a successful build.

The Swift to Objective-C header file depends on the module name:

<ModuleName>-Swift.h

So if the Module name changes, you need to change the import in your code. In build settings search for Product Module Name to find the module name that is being used.

The Objective-C to Swift bridging header name depends on the build setting Objective-C Bridging Header. Check the Xcode target build settings and modify to match your new name.

BitByteDog
  • 3,074
  • 2
  • 26
  • 39