Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import Swift module with plus (+) sign in Xcode

I'm trying to import a module called "NSObject+Rx" but Xcode complains with an obscure error (consecutive statements separated with ; etc).

import NSObject+Rx

Any idea how to import a module with special characters like this?

like image 761
David James Avatar asked May 25 '16 11:05

David James


1 Answers

From Apple docs:

Naming Your Product Module

The name of the Xcode-generated header for Swift code, and the name of the Objective-C bridging header that Xcode creates for you, are generated from your product module name. By default, your product module name is the same as your product name. However, if your product name has any nonalphanumeric characters, such as a period (.), they are replaced with an underscore (_) in your product module name. If the name begins with a number, the first number is replaced with an underscore.

You can also provide a custom name for the product module name and Xcode will use this when naming the bridging and generated headers. To do this, change the Product Module Name build setting.

NOTE

You cannot override the product module name of a framework.

In your case, replace NSObject+Rx with NSObject_Rx or set your own name by changing the Product Module Name build setting.

like image 50
Daniel Avatar answered Oct 31 '22 16:10

Daniel