If you're using a framework written in Swift in an Objective-C application, you need to include the Swift toolchain in the app that consumes the framework.
The way I've found to do this is to create a dummy swift file in the app so that XCode recognizes swift and appropriately adds it to the project. You can then delete the dummy file.
I would love if someone knew of a better way to explicitly add swift to an objective-c project without adding a swift file.
Adding the framework to the embedded binary asset list fixed this. Here is what the setup of a foreign framework looks like in final form in the Xcode GUI as an Embedded Framework (Xcode 9.2, personally I like a visual bread crumb trail better ;-) ):
Did Apple intentionally crash the runtime to somehow tell the developer about the problem that you cannot use non-Apple frameworks as simply linked frameworks in iOS development? It would be better to have it come up as a build error I would think... with a button that said "move it!"
The use of Embedded Binaries keeps the end user from having to add the Framework independently of your app (or have you do with an installer). In the case of the iPhone (iOS), that is impossible, but on macOS, it is possible but can get messy fast.
For the end user, it is much nicer to simply drag and drop an app to install it on macOS, which is where embedded becomes a benefit. Embedding also avoids the classic "DLL conflicts" of having external versions of your framework to manage. (disk space is cheap, my customer's time is precious).
I encountered an error with the same signature (my project was in Obj-C) and discovered I had forgotten to link with the appropriate framework. The error message in the debug log that led to finding the error was:
dyld: Symbol not found: _OBJC_CLASS_$_SFSafariViewController
For my specific error, adding SafariServices.framework in the Targets --> Build Phases --> "Link Binary With Libraries" resolved the issue. While you probably don't have the same specific error and resolution, checking the debug log for clues is useful.
If you're using a framework written in Swift in an Objective-C application, you need to include the Swift toolchain in the app that consumes the framework.
The way I've found to do this is to create a dummy swift file in the app so that XCode recognizes swift and appropriately adds it to the project. You can then delete the dummy file.
I would love if someone knew of a better way to explicitly add swift to an objective-c project without adding a swift file.
Adding the framework to the embedded binary asset list fixed this. Here is what the setup of a foreign framework looks like in final form in the Xcode GUI as an Embedded Framework (Xcode 9.2, personally I like a visual bread crumb trail better ;-) ):
Did Apple intentionally crash the runtime to somehow tell the developer about the problem that you cannot use non-Apple frameworks as simply linked frameworks in iOS development? It would be better to have it come up as a build error I would think... with a button that said "move it!"
The use of Embedded Binaries keeps the end user from having to add the Framework independently of your app (or have you do with an installer). In the case of the iPhone (iOS), that is impossible, but on macOS, it is possible but can get messy fast.
For the end user, it is much nicer to simply drag and drop an app to install it on macOS, which is where embedded becomes a benefit. Embedding also avoids the classic "DLL conflicts" of having external versions of your framework to manage. (disk space is cheap, my customer's time is precious).
For me a simple
Clean
andRebuild
sorted it out. Hope it helps.I encountered an error with the same signature (my project was in Obj-C) and discovered I had forgotten to link with the appropriate framework. The error message in the debug log that led to finding the error was:
dyld: Symbol not found: _OBJC_CLASS_$_SFSafariViewController
For my specific error, adding SafariServices.framework in the Targets --> Build Phases --> "Link Binary With Libraries" resolved the issue. While you probably don't have the same specific error and resolution, checking the debug log for clues is useful.
I was facing the same issue. Setting 'Always Embed Swift Standard Libraries' to Yes in Build Settings of my target worked for me.