7 Replies
      Latest reply on Aug 27, 2016 4:01 AM by dacheng
      dacheng Level 1 Level 1 (0 points)

        I creat a custom framework. In the framework, I define a protocol and a class. The class realize the protocol, and in my application create a class inheritance that class in the framework. Run it ,The console output not find the protocol`s method

        xcode 8 bata 5 have no the problem.

        • Re: swift 3 on XCode 8 bata 6 a protocol problem
          macnib Level 1 Level 1 (10 points)

          Does the protocol have public?

           

          Since its a framework, it defaults to internal. From what I know, a framework or an app is its own module. So, for an app to see the symbol from the framework it would have to be public. Setting to private limits the visibility to the file. Internal limits visibility to the module.

           

          Hope that helps...

           

          public protocol myproto {

               func myfunc()

          }

            • Re: swift 3 on XCode 8 bata 6 a protocol problem
              QuinceyMorris Level 8 Level 8 (6,050 points)

              As of beta 6, it's necessary to change "public" to "open" for classes that are intended to be subclassed across module boundaries. It may be that this is the issue, not the protocol visibility.

              • Re: swift 3 on XCode 8 bata 6 a protocol problem
                dacheng Level 1 Level 1 (0 points)
                public protocol DCGameViewCreatedDelegate {
                    func gameViewFinish(_ layer:CALayer)
                }
                
                
                open func gameViewFinish(_ layer: CALayer) {
                        if DCDirector.getInstance.renderMode == .metal {
                            gameLayer = layer
                            gameLayer.frame = view.frame
                            view.layer.addSublayer(gameLayer)
                        }
                    }
                

                This method does`t work

                  • Re: swift 3 on XCode 8 bata 6 a protocol problem
                    QuinceyMorris Level 8 Level 8 (6,050 points)

                    Can you show the exact error message?

                      • Re: swift 3 on XCode 8 bata 6 a protocol problem
                        dacheng Level 1 Level 1 (0 points)
                        
                        dyld: Symbol not found: __TFC13DCGameKit_IOS20DCGameViewController14gameViewFinishfCSo7CALayerT_
                          Referenced from: /var/containers/Bundle/Application/063C7C79-AA44-4CC7-B13D-EAD5044AF323/DCGameKit-IOS-test.app/DCGameKit-IOS-test
                          Expected in: /private/var/containers/Bundle/Application/063C7C79-AA44-4CC7-B13D-EAD5044AF323/DCGameKit-IOS-test.app/Frameworks/DCGameKit_IOS.framework/DCGameKit_IOS
                         in /var/containers/Bundle/Application/063C7C79-AA44-4CC7-B13D-EAD5044AF323/DCGameKit-IOS-test.app/DCGameKit-IOS-test
                        (lldb) 
                        

                        This`s console output

                          • Re: swift 3 on XCode 8 bata 6 a protocol problem
                            QuinceyMorris Level 8 Level 8 (6,050 points)

                            .__TFC13DCGameKit_IOS20DCGameViewController14gameViewFinishfCSo7CALayerT_ is a mangled method name. I think there's a command-line tool to unmangle Swift names, but clearly it's:

                             

                                 module: DCGameKit_IOS

                                 class: DCGameViewController

                                 method: gameViewFinish

                             

                            and code in the application is trying to call this method in the framework. (That suggests the subclass of DCGameViewController in the application does not override gameViewFinish.)

                             

                            It looks like the Swift compiler thought that DCGameViewController.gameViewFinish was available to the application, but either it doesn't exist or isn't visible. Assuming you didn't do anything with linker commands to suppress the symbol, this might indicate that the Swift compiler is confused.

                             

                            I'd suggest you submit a bug report with the project that shows the problem. Someone else might jump in with ideas, but it might be hard to find the problem via this forum.