google / promises

Promises is a modern framework that provides a synchronization construct for Swift and Objective-C.
Apache License 2.0
3.8k stars 293 forks source link

Application not compiling on XCode 10 and on iOS 12 device #49

Closed rajesht1989 closed 6 years ago

rajesht1989 commented 6 years ago

There seems to be an issue while converting Promise to FBLPromise. Completly blocked.

  1. While generating Objective-C header
  2. While printing 'Connection' at /Volumes/Official/WorkingCopy/native/Classes/Swift/Connection/Connection.swift:11:1
  3. While printing type 'Promise.ObjCPromise'
  4. While printing type 'Value' error: Segmentation fault: 11
shoumikhin commented 6 years ago

Hi Rajesh, thank you for the heads up!

Could you provide some code snippets or a small test project that fails for you on Xcode 10, please? Can you also open Promises.xcworkspace on your side and confirm all tests pass?

Thanks.

rajesht1989 commented 6 years ago

Objc code

    [Test callMeObjc].then(^id(NSNumber *number) {
         NSLog(@"%@",number);
         return nil;
     });

Swift class

 class Test : NSObject {

     static func callMeObjc() - Promise<Bool.ObjCPromise<NSNumber {
         return callMe().then({ (value) in
             return NSNumber(value: value)
         }).asObjCPromise()
     }

     static func callMe() - Promise<Bool {
         return Promise<Bool.init(true)
     }
 }

This is the simple use case. The application fails to compile.

I m unable test because it throws an error. Tests in the target “PromisesTests” can’t be run because “PromisesTests” isn’t a member of the active scheme.

DazChong commented 6 years ago

Tested Pod with XCode 10 beta with new blank Cocoa app, result in Swift Compiler Error > Include of non-modular header inside framework module 'FBLPromises'...

And then open project back in XCode 9 will remain to have this error. Clean project, pod remove and add didnt help.

If creating a blank new project with in XCode 9, it works. But broken once opened it with XCode 10 beta.

shoumikhin commented 6 years ago

@rajesht1989 I just ran the following code successfully in a new 1-view template project set up with Cococapods in Xcode 10 beta:

# Podfile
target 'TestPromisesCocoapods' do
  use_frameworks!
  pod 'PromisesSwift', '~> 1.2.2'
end
// TestObject.h
#import <FBLPromises/FBLPromises.h>

@interface TestObject : NSObject
- (void)test;
@end

// TestObject.m
#import "TestPromisesCocoapods-Swift.h"

@implementation TestObject

- (void)test {
  [Test callMeObjc].then(^id(NSNumber *number) {
    NSLog(@"%@",number);
    return nil;
  });
}

@end

// TestPromisesCocoapods-Bridging-Header.h
#import "TestObject.h"
// ViewController.swift
import Promises
import UIKit

class ViewController: UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()

    TestObject().test()
  }
}

// Test.swift
import Promises

class Test : NSObject {

  @objc
  static func callMeObjc() -> Promise<Bool>.ObjCPromise<NSNumber> {
    return callMe().then { value in
      NSNumber(value: value)
    }.asObjCPromise()
  }

  static func callMe() -> Promise<Bool> {
    return Promise(true)
  }
}

Let me know if it works on your side.

rajesht1989 commented 6 years ago

@shoumikhin We had the same sort of code but It was not working. Now we are able to fix the issue by making return type FBLPromise like this.

new working code

static func callMeObjc() -> FBLPromise<NSNumber> {
    return callMe().asObjCPromise()
  }

Instead of

static func callMeObjc() -> Promise<Bool>.ObjCPromise<NSNumber> {
    return callMe().asObjCPromise()
  }

Can you let me know if this is fine and let me know the causes and consequences of this ?

shoumikhin commented 6 years ago

Do you also have an @objc specifier for the function returning ObjCPromise and used from Objective-C? I'd highly appreciate if you packed a simple test project in zip and attached here, so that we could reproduce your error. Thanks!

rajesht1989 commented 6 years ago

@shoumikhin I have tried giving @objcspecifier but still helpless. When I try the same in the sample project, It compiled without any issues. So, I feel the problem is in the configuration of my project which I could not identify. :(

shoumikhin commented 6 years ago

Sorry to hear that. Hoped we could help to resolve your issue. Anyhow, feel free to close this issue and follow up with any other related findings in future.

Kishimotovn commented 6 years ago

@shoumikhin I'm having the same problem with promises and Xcode 10 beta. Couldn't build FBLPromises: Include non-modular header inside framework module 'FBLPromises'

The project builds fine with Xcode 9.3 :( and I'm using PromisesSwift

Kishimotovn commented 6 years ago

This problem is resolved by removing Promises from pod file and reinstall...

shoumikhin commented 6 years ago

@Kishimotovn just to clarify, do you say the issue has gone when you re-run pod update? Were you able to successfully build Promises with Xcode 10 eventually? Would appreciate any reproduction steps that lead to the issue.

Kishimotovn commented 6 years ago

Hi @shoumikhin,

Here is what I did:

It seems that this problem only happens when you open an existing project with xcode 10. Projects that are created with xcode 10 won’t have this problem :-?

malaratn commented 6 years ago

Just turn on Xcode Server. It's good for me.

martindufort commented 6 years ago

Got that same error under XCode 9.4.1 with version 1.2.3. Include of non-modular header inside framework module 'FBLPromises' ..../Sources/Promises/Promise+Await.swift:15:8: Could not build Objective-C module 'FBLPromises'

And I tried the remove / reinstall trick but still same problem.

And this is being added to an existing XCode 9 project.

shoumikhin commented 6 years ago

Hi Martin, thank you for reporting that!

Are you using CocoaPods? Wonder if the following would work for you:

pod cache clean PromisesObjC
pod cache clean PromisesSwift
cd <your_project_dir>
rm -rf Pods/
rm Podfile.lock
pod update
martindufort commented 6 years ago

Followed instructions... Same issue. screen shot 2018-08-27 at 4 48 51 pm

Deployment target : MacOS 10.12 Swift Version : 4.1

shoumikhin commented 6 years ago

Do you mind to make a small test project and check if it reproduces on it, and if so, share the project here with some instructions on how to break it? Many thanks!

martindufort commented 6 years ago

screen shot 2018-08-27 at 4 52 59 pm

martindufort commented 6 years ago

Will do and report here.

martindufort commented 6 years ago

Weird. I created a new project; installed and compiled the Promises pod without any issues. Will investigate my current project structure.

martindufort commented 6 years ago

Here's my latest finding:

Not sure where to go from here.

shoumikhin commented 6 years ago

Thank you for experimenting, Martin! How do you normally clean the project?

There're basically two standard options via Xcode:

screen shot 2018-08-29 at 8 56 16 am

Wonder if both of them fail to clean DerivedData properly?

martindufort commented 6 years ago

OK, after some tests, even the Clean Build Folder.... does not prevent the compilation failure. I have to moved the "DerivedData" folder to the trash to allow my project to build cleanly.

Weird !!!

Will have to try with XCode 10 to see if this is a bug that is now resolved...

nitishmaropost commented 5 years ago

Getting the same issue. I read somewhere that might be because of low memory. But that doesn't help as well.

martindufort commented 5 years ago

I think it's an issue if you have started your project with an earlier version of XCode and then upgraded all the way to XCode 10.

The only way I was able to make this work (even in XCode 10) was to physically delete the DerivedData folder.

On Fri, Oct 12, 2018 at 03:29 nitishmaropost notifications@github.com wrote:

Getting the same issue. I read somewhere that might be because of low memory. But that doesn't help as well.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/promises/issues/49#issuecomment-429232116, or mute the thread https://github.com/notifications/unsubscribe-auth/AbmB8d91iW0XTLgAZAn2zlV6NzrXN8tyks5ukETkgaJpZM4UaVnq .

ItsEcholot commented 5 years ago

This randomly happened while adding another library as a pod. Like @martindufort said deleting DerivedData folder fixed it!