How to use Swift App + (Swift Framework + Objective C static Framework) without warnings
What I am trying to do:
- Create a swift dynamic framework – Say SwiftDemo.framework
- Swift.framework depends upon an external Objective-C static framework
(No source code available) – Say ObjCDemo.framework. This framework has
it’s module file and placed inside ObjCDemo.framework/Modules/module.modulemap
- Put this SwiftDemo.framework inside an Swift application. Ideally I would want my swift app to be able to use both SwiftDemo.framework and ObjCDemo.framework without any error or warning.
What I have tried:
Create a swift dynamic framework SwiftDemo.framework
Added ObjCDemo.framework in “Linked Frameworks and Libraries”. Put ObjCDemo.frameworks path in “Framework Search Paths” if not added automatically. Access ObjCDemo.framework using “import ObjCDemo”. Build the SwiftDemo.framework. It builds fine, No error, No warning
Create a SwiftDemo application.
Add SwiftDemo.framework in “Embedded Binaries” section.
Try to build SwiftDemo.app, below is the error:
ld: framework not found ObjCDemo for architecture x86_64
Obviously SwiftDemo.app not able to find the ObjCDemo.framework which is used by SwiftDemo.framework, So next I did:
- Added ObjCDemo.framework in “Linked Frameworks and Libraries” and accordingly set the “Frameworks Search Paths” of SwiftDemo.app target
Try to build SwiftDemo.app, No error but this is the console warning I get for every file in ObjCDemo.framework:
objc: Class is implemented in both /Users/tarun/Library/Developer/CoreSimulator/Devices/4391A259-64DF-4893-BE09-31B5D2D5BC8C/data/Containers/Bundle/Application/CD896A7B-1868-44D1-BFEA-6CC081AD41DB/SwiftDemo.app/Frameworks/SwiftDemo.framework/Swift and /Users/tarun/Library/Developer/CoreSimulator/Devices/4391A259-64DF-4893-BE09-31B5D2D5BC8C/data/Containers/Bundle/Application/CD896A7B-1868-44D1-BFEA-6CC081AD41DB/SwiftDemo.app/SwiftDemo. One of the two will be used. Which one is undefined.
Obviously these files are duplicated in both SwiftDemo.framework and SwiftDemo.app, So to avoid next I did:
- Remove ObjCDemo.framework form “Linked Frameworks and Libraries” of
SwiftDemo.app target but keep “Frameworks Search Paths” still
pointing to ObjCDemo.framework path.
Try to build SwiftDemo.app, No error but this is the compile time warning:
ld: warning: Auto-Linking supplied ‘…/SwiftDemo/ObjCDemo.framework/ObjCDemo’, framework linker option at …./SwiftDemo/ObjCDemo.framework/ObjCDemo is not a dylib
No matter what I just couldn’t get pass these errors or warnings. Anyone got any solution to this?
- Detect when “back to app” is pressed
- Custom table view cell: IBOutlet label is nil
- What are the difference and use-cases for va_list, CVaListPointer, AnyObject …, CVarArgType?
- How to properly handle NSFileHandle exceptions in Swift 2.0?
- Realm, Swift, Many-to-many relationship
- Auto scrolling to a cell with a specific value
- Trigger an incoming VoIP call using CallKit and Twilio-Video API
- Mixins or Multiple Inheritance in Objective-C?
- iOS App default Language “en” is not applied
- How do I fix this warning: “Method not found (return type defaults to 'id')”
- Customize header in UITableView
- Get path for NSFileWrapper
- Xcode 7 doesn't autocomplete if using bridging header
- UITableViewCellAccessoryCheckmark and AutoLayout constraints
- Where are the iOS frameworks binaries located in the filesystem?
- Waiting until the task finishes
- Try to load a created Map in MKMapView
- Missing argument for parameter #1 in call when setting initial value
- Tab Bar with Large Icons
- Where can I get the magnifying glass icon used in UISearchBar?
- Looking for a list of all available languages in iOS