I need to make a library with swift that support both swift and object c project (also support xcode 5), this will be a distribution library (do not share source code). There are two ways to do this: create a Cocoa Touch Framework or create a Cocoa Touch Static Library. I make some research, but still find out the solution. It seems the Cocoa Touch Framework not support to buid a distribution library, and I'm not sure the Cocoa Touch Static Library work perfect with with Swift yet or not. Any solutions for it. Thanks.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- “Zero out” sensitive String data in Swift
- back button text does not change
- SwiftUI: UIImage (QRCode) does not load after call
相关文章
- 现在使用swift开发ios应用好还是swift?
- Handling ffmpeg library interface change when upgr
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
I faced the same issue as you to build one Pod library for both Swift and Objective-C, using pure code respectively without messing languages or include bridging headers. Actually I didn't try it by myself, but I came to several possible solutions:
1) To use a different branches of the same repo:
2) Experimenting with Subspecs as a way to install a subset of your library. (official cocoapods documentation: subspec )
It probably would look like:
pod 'YourPodLib/Swift'
Maybe my approach is far away from being ideal, but I would be appreciate if you correct me or suggest a better idea.
A very good example for this kind of library is Realm.
They both support swift and objective-c project integration. Check the repo on GitHub , and browse it : here
In fact, they have all the library coded in Objective-C, and the add Support for swift specifecity with extensions on objects used by the client. (For example, check the Realm/RLMSwiftSupport.m in their repo)
EDIT
To access a Swift class in Objective-C, just add
@objc(MyClass)
in your Swift Class and it will be available in Objective-C files.Read the this for more informations about Objective-C and Swift working together