9047
お世話になります  
タイトルの通り、swiftでprotocolの入ったframeworkを作りたいと考えております  
が、現在詰まっておりまして、framework自体はできたのですが、protocolがheaderファイルに見えてない状態でして、実質使えないという状態になって困っております

```

          //
      //  ConnectionBySession.swift
      //  ShotAlertForSwift
      //
      //  Created by 平塚 俊輔 on 2015/04/07.
      //  Copyright (c) 2015年 &#24179;&#22618;&#12288;&#20426;&#36628;. All rights reserved.
      //
    
      protocol ConnectionResultBySession{
          func showResult(resultMessage: String?) -> Void
          func handleErrorForConnection()
      }
    
      public class ConnectionBySession : NSObject,NSURLSessionDataDelegate{
    
          // 参考:
          // NSURLConnection ttp://stackoverflow.com/questions/24176362/ios-swift-and-nsurlconnection
          // Delegate, Protocol ttp://qiita.com/mochizukikotaro/items/a5bc60d92aa2d6fe52ca
    
          // nilが入ってるなんてあり得ない！
          var urlStr : String
          var data : NSMutableData? = nil
          var delegate : ConnectionResultBySession!
          var error:NSError?
          var status:Int?
          var session:NSURLSession!
    
          // コンストラクタ
          public init(urlStr: String) {
              self.data = NSMutableData()
              self.urlStr = urlStr
          }
    
          // アクセス
          public func doConnect() -> Void{
              println(urlStr)
              var url : NSURL = NSURL(string: urlStr)!
    
              //タイムアウトは15秒
              var config = NSURLSessionConfiguration.defaultSessionConfiguration()
              config.timeoutIntervalForRequest = 15
              //
              self.session = NSURLSession(configuration: config,
                  delegate: self,
                  delegateQueue: NSOperationQueue.mainQueue())
    
              var task:NSURLSessionDataTask = self.session.dataTaskWithURL(url)
              task.resume()
          }
    
          public func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse response: NSURLResponse, completionHandler: (NSURLSessionResponseDisposition) -> Void){
              println("request_start")
    
              if response.isKindOfClass(NSHTTPURLResponse){
                  let httpURLResponse:NSHTTPURLResponse = response as NSHTTPURLResponse
    
                  self.status = httpURLResponse.statusCode
    
    
                  if self.status == 200{
                      //println("success")
    
                      let disposition:NSURLSessionResponseDisposition = NSURLSessionResponseDisposition.Allow
                      completionHandler(disposition)
                  }else{
                      self.delegate.handleErrorForConnection()
                  }
              }
    
    
          }
          public func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didBecomeDownloadTask downloadTask: NSURLSessionDownloadTask){
              println("didBecomeDownloadTask")
          }
    
          public func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData data: NSData){
    
              //        let json : String = NSString(data: data, encoding: NSUTF8StringEncoding)!
              //        println(json)
    
    
              self.data!.appendData(data)
              self.delegate.showResult("success")
    
    
    
          }
    
          public func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?){
              println(error)
              if error != nil{
                  //println("didCompleteWithError")
                  self.delegate.handleErrorForConnection()
              }
    
    
          }
          public func URLSession(session: NSURLSession, didBecomeInvalidWithError error: NSError?){
              println(error)
    
              if error != nil{
                  //println("didCompleteWithError")
                  self.delegate.handleErrorForConnection()
              }
          }
    
          func cancelConnect(){
              self.session.getTasksWithCompletionHandler
                  {
                      (dataTasks, uploadTasks, downloadTasks) -> Void in
    
                      self.cancelTasksByUrl(dataTasks     as [NSURLSessionTask])
    
              }
          }
    
          private func cancelTasksByUrl(tasks: [NSURLSessionTask])
          {
              for task in tasks
              {
                  task.cancel()
              }
          }
      }
    
```

というファイルでframeworkを作り、ビルドは通ったのですが、実際に作られてる、frameworkのヘッダファイルを見ると

```

              // Generated by Swift version 1.1 (swift-600.0.57.4)
          #pragma clang diagnostic push
    
          #if defined(__has_include) && __has_include(<swift/objc-prologue.h>)
          # include <swift/objc-prologue.h>
          #endif
    
          #pragma clang diagnostic ignored "-Wauto-import"
          #include <objc/NSObject.h>
          #include <stdint.h>
          #include <stddef.h>
          #include <stdbool.h>
    
          #if defined(__has_include) && __has_include(<uchar.h>)
          # include <uchar.h>
          #elif !defined(__cplusplus) || __cplusplus < 201103L
          typedef uint_least16_t char16_t;
          typedef uint_least32_t char32_t;
          #endif
    
          typedef struct _NSZone NSZone;
    
          #if !defined(SWIFT_PASTE)
          # define SWIFT_PASTE_HELPER(x, y) x##y
          # define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
          #endif
          #if !defined(SWIFT_METATYPE)
          # define SWIFT_METATYPE(X) Class
          #endif
    
          #if defined(__has_attribute) && __has_attribute(objc_runtime_name)
          # define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
          #else
          # define SWIFT_RUNTIME_NAME(X)
          #endif
          #if !defined(SWIFT_CLASS_EXTRA)
          # define SWIFT_CLASS_EXTRA
          #endif
          #if !defined(SWIFT_PROTOCOL_EXTRA)
          # define SWIFT_PROTOCOL_EXTRA
          #endif
          #if !defined(SWIFT_CLASS)
          # if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted) 
          #  define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
          # else
          #  define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
          # endif
          #endif
    
          #if !defined(SWIFT_PROTOCOL)
          # define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
          #endif
    
          #if !defined(SWIFT_EXTENSION)
          # define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
          #endif
    
          #if !defined(OBJC_DESIGNATED_INITIALIZER)
          # if defined(__has_attribute) && __has_attribute(objc_designated_initializer)
          #  define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
          # else
          #  define OBJC_DESIGNATED_INITIALIZER
          # endif
          #endif
          #if defined(__has_feature) && __has_feature(modules)
          @import ObjectiveC;
          @import Foundation.NSURLSession;
          #endif
    
          #pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
          #pragma clang diagnostic ignored "-Wduplicate-method-arg"
          @class NSURLSession;
          @class NSURLSessionDataTask;
          @class NSURLResponse;
          @class NSURLSessionDownloadTask;
          @class NSData;
          @class NSURLSessionTask;
          @class NSError;
    
          SWIFT_CLASS("_TtC19ConnectionBySession19ConnectionBySession")
          @interface ConnectionBySession : NSObject <NSURLSessionDataDelegate>
          - (instancetype)initWithUrlStr:(NSString *)urlStr OBJC_DESIGNATED_INITIALIZER;
          - (void)doConnect;
          - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler;
          - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask;
          - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data;
          - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error;
          - (void)URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)error;
          @end
    
          #pragma clang diagnostic pop
    
```

あれ、protocolは何処へ。。。  
当然使おうとしても、delegateがないよと怒られてしまいます

調べてるのですが、解決策が見つからず。。。  
どうしたらよいかお分かりになる方いらっしゃいますでしょうか  
よろしくお願いします。
CC BY-SA 3.0
2015-04-11T02:37:56.443
9037
2015-04-11T09:20:34.603
403
question
swift xcode6 playframework delegate
swiftでprotocolが入ったframeworkを作りたい
`protocol`についてもモジュールの外から使用するには`public`を指定する必要があります。

```

    public protocol ConnectionResultBySession {
        func showResult(resultMessage: String?) -> Void
        func handleErrorForConnection()
    }
    
```

書かれてる内容からすると、おそらく`delegate`プロパティも同様に`public`にする必要がありそうだなと思いました。

```

    public　var delegate : ConnectionResultBySession!
    
```
CC BY-SA 3.0
2015-04-11T09:20:34.603
9047
2015-04-11T09:20:34.603
5519
9037
answer