Git Product home page Git Product logo

Comments (14)

royherma avatar royherma commented on June 30, 2024 3

Hey @scenee, the lib works (thanks!), however there are a good amount of properties that I can not access, such as:

public var isRemovalInteractionEnabled: Bool {
     set { floatingPanel.isRemovalInteractionEnabled = newValue }
        get { return floatingPanel.isRemovalInteractionEnabled }
}

because they are missing their @objc accesor, any way to add these please??

from floatingpanel.

scenee avatar scenee commented on June 30, 2024 1

Thanks for your feedback, @PasqualePuzio! I agree with you. I actually regret that this library loses objc API full compatibility because it has CocoaTouch-like API. But now I think the adapter approach is better for the reasons as you mention above.

from floatingpanel.

scenee avatar scenee commented on June 30, 2024 1

Hi there, since v2.0 the lib supports the full ObjC interoperability. Stay tuned.

from floatingpanel.

scenee avatar scenee commented on June 30, 2024

Hi @quannextfunc ,

I recommend to use this library in Objective-C project as the following steps

  1. Set up “Build Settings” in your project
    • Set “Always Embedded Swift Standard Library” to “YES”
  2. Add FlaotingPanelAdapter.swift
    • You must also add a “Objective-C Bridging Header”(even if it's empty).
  3. Implement FloatingPanelAdapter with FloatingPanel in Swift

Here is an example project.

SamplesObjCArchive.zip

$ unzip SamplesObjCArchive.zip
$ cd SamplesObjC/
$ pod install
$open SamplesObjC.xcworkspace/

Finally, it's not possible to use FloatingPanel library directly in Objective-C. I tried to change it for ObjC, but the change will break APIs for Swift so I'm not planning to change it for ObjC.

from floatingpanel.

pichirichi avatar pichirichi commented on June 30, 2024

I managed to change it to support in ObjC, I had to pull put the Position enum out into ObjC.
FloatingPanelPosition.h

typedef NSString * FloatingPanelPosition NS_STRING_ENUM NS_SWIFT_NAME(FloatingPanelPosition);
FOUNDATION_EXPORT FloatingPanelPosition FloatingPanelPositionFull;
FOUNDATION_EXPORT FloatingPanelPosition FloatingPanelPositionHalf;
FOUNDATION_EXPORT FloatingPanelPosition FloatingPanelPositionTip;
FOUNDATION_EXPORT FloatingPanelPosition FloatingPanelPositionHidden;

NS_ASSUME_NONNULL_END

FloatingPanelPosition.m

FloatingPanelPosition FloatingPanelPositionFull    = @"Full";
FloatingPanelPosition FloatingPanelPositionHalf    = @"Half";
FloatingPanelPosition FloatingPanelPositionTip     = @"Tip";
FloatingPanelPosition FloatingPanelPositionHidden  = @"Hidden";

add the h to the bridging header and add @objc to functions/properties you want to expose to ObjC.
You'll need to add "default" to switches.

from floatingpanel.

newmanw avatar newmanw commented on June 30, 2024

@pichirichi you say

I managed to change it to support in ObjC

Assume this means within your own project. Any way you can contribute those changes back via a PR so others that want to use this library in obj-c can?

from floatingpanel.

scenee avatar scenee commented on June 30, 2024

At first, Thank you, @pichirichi. You gave me a great insight for the objc support.

@quannextfunc & @newmanw,

I'm working to support ObjcC by creating a new artifact named as "FloatingPanelObjc.framework" that shares the core logic written in Swift with "FloatingPanel.framework"

Because I've struggled with the objc support in "FloatingPanel.framework" for a while, but these protocols and protocol extensions are the trouble.

  • FloatingPanelControllerDelegate
  • FloatingPanelLayout
  • FloatingPanelBehavior

If they support @objc, the usability in Swift becomes poor because protocol extensions can't be used in @objc protocols. https://bugs.swift.org/browse/SR-3349

As a result, I'm going to make "FloatingPanelObjc.framework".

from floatingpanel.

pichirichi avatar pichirichi commented on June 30, 2024

@pichirichi you say

I managed to change it to support in ObjC

Assume this means within your own project. Any way you can contribute those changes back via a PR so others that want to use this library in obj-c can?

Unfortunately it is too baked into our code since we also did some iOS 9 workarounds.
for Objc it is mainly the enum and @objc where it is required.|
We are not using all the functionality the pod provides so I'm not sure we covered all aspects.

from floatingpanel.

pichirichi avatar pichirichi commented on June 30, 2024

The wrapper approach might be a more elegant one, exposing the functions you need.

from floatingpanel.

scenee avatar scenee commented on June 30, 2024

I created FloatingPanelObjC.framework in support-objc branch. You can try it using both of CocoaPods and Carthage.

Carthage

github "scenee/FloatingPanel" "support-objc"

CocoaPods

pod 'FloatingPanelObjC', git: 'https://github.com/SCENEE/FloatingPanel.git', branch: "support-objc"

Could you please give me feedback about it?

NOTE: I didn't test it well, but I confirmed it worked with SamplesObjC app in this repo.

from floatingpanel.

aaronbrethorst avatar aaronbrethorst commented on June 30, 2024

I'm seeing a build error with Carthage when I try using the specified branch:

/Users/aaron/repos/OBANext/Carthage/Checkouts/FloatingPanel/Framework/Sources/FloatingPanelController.swift:102:18: error: method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C
    @objc public init(delegate: FloatingPanelControllerDelegate? = nil) {
                 ^

CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler (in target: FloatingPanel)
    cd /Users/aaron/repos/OBANext/Carthage/Checkouts/FloatingPanel/Framework
    export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
    export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk

I can confirm this error also happens when I open FloatingPanel.xcworkspace and build within Xcode.

from floatingpanel.

scenee avatar scenee commented on June 30, 2024

@aaronbrethorst, Thanks! I forgot to push a commit to fix the build error. Please try b14be9f commit.

from floatingpanel.

PasqualePuzio avatar PasqualePuzio commented on June 30, 2024

Hi all,

my 2 cents on this: we have taken the "adapter" approach recommended by @scenee
I must say it proved to be a very elegant and clean solution, allowing us to preserve FloatingPanel without making any changes and integrate it into our objective c project.

Even though it may look complex at a first look, I believe in the long run it's a much better approach in terms of simplicity. With an adapter we don't need to develop and maintain an objective c porting if FloatingPanel.

from floatingpanel.

scenee avatar scenee commented on June 30, 2024

v2 has already supported full ObjC interoperability. Thank you for all 👍

from floatingpanel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.