Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using use_modular_headers!, NSUInteger is cast in Swift as Int instead of UInt #7589

Closed
1 task done
MaximeLM opened this issue Apr 5, 2018 · 13 comments · Fixed by #7638
Closed
1 task done
Milestone

Comments

@MaximeLM
Copy link
Contributor

MaximeLM commented Apr 5, 2018

🌈

Report

What did you do?

In the Podfile of a Swift project, replace use_frameworks! with:

use_frameworks!(false)
use_modular_headers!

The project uses an Objective-C pod. The Objective-C pod use NSUInteger in its public interface.

What did you expect to happen?

NSUInteger should be cast in Swift as UInt. This is the previous behavior.

What happened instead?

NSUInteger is cast is Swift as Int. The swift project fails to compile.

CocoaPods Environment

Stack

   CocoaPods : 1.5.0
        Ruby : ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
    RubyGems : 2.4.6
        Host : Mac OS X 10.13.4 (17E199)
       Xcode : 9.3 (9E145)
         Git : git version 2.15.1 (Apple Git-101)
Ruby lib dir : /Users/maximelemoine/.rvm/rubies/ruby-2.2.1/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 4ddb0bcf3b52ed9ff3e40a475fb06d9dc264bcfe

Installation Source

Executable Path: /Users/maximelemoine/.rvm/gems/ruby-2.2.1/bin/pod

Plugins

cocoapods-amimono     : 0.0.10
cocoapods-deintegrate : 1.0.2
cocoapods-packager    : 1.5.0
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.0
cocoapods-try         : 1.1.0

Podfile

# Uncomment the next line to define a global platform for your project
platform :osx, '10.10'

# The project will compile with these settings
#use_frameworks!

# The project will fail to compile with these settings
use_frameworks!(false)
use_modular_headers!

target 'TestNSUInteger' do
  
  pod 'TestLib', :path => '.'

end

Project that demonstrates the issue

https://github.com/MaximeLM/TestNSUInteger.git

This is a simple project that demonstrates the issue. Reverting to use_frameworks!in the Podfile makes the project build again.

This issue is preventing apps that use RealmSwift to build with the new setting: realm/realm-swift#5663

@MaximeLM
Copy link
Contributor Author

MaximeLM commented Apr 5, 2018

This seems to be caused by cd554f4

In the test project, the content of Pods/Headers/Public/TestLib/TestLib.modulemap is:

module TestLib [system] {
  umbrella header "TestLib-umbrella.h"

  export *
  module * { export * }
}

If I remove the [system] tag, the error is gone.

This thread indicates that NSUInteger is bridged as Int for system frameworks like Foundation/AppKit/UIKit, and as UInt for user frameworks.
https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160111/000848.html

@segiddins
Copy link
Member

Well that’s unfortunate, and undocumented in the clang modules page :(. All it says the system modifier does is suppress warnings from headers

@dnkoutso
Copy link
Contributor

dnkoutso commented Apr 5, 2018

We might have to remove this.

@dnkoutso dnkoutso added this to the 1.5.1 milestone Apr 5, 2018
@gereons
Copy link
Contributor

gereons commented Apr 14, 2018

This issue also prevents apps using SwiftyDropbox from switching to use_frameworks!(false).

@dnkoutso
Copy link
Contributor

PR #7638

@MaximeLM
Copy link
Contributor Author

I still can't build RealmSwift with CocoaPods on the master branch. The Realm subpod defines a module map with framework module Realm, which is replaced by module Realm [system] by CocoaPods.
https://github.com/realm/realm-cocoa/blob/master/Realm/Realm.modulemap

contents.gsub!(/^(\s*)framework\s+(module[^{}]+){/, '\1\2[system] {')

@dnkoutso
Copy link
Contributor

1.5.1 hasn't shipped yet. did you try with latest master branch?

@dnkoutso
Copy link
Contributor

Oops @MaximeLM you are right this should also be removed.

@dnkoutso
Copy link
Contributor

Let me open a PR

@MaximeLM
Copy link
Contributor Author

@dnkoutso yes I used the latest master

@dnkoutso
Copy link
Contributor

@MaximeLM PR up

@MaximeLM
Copy link
Contributor Author

@dnkoutso the app compiles with your fix, thank you!

Two warnings have appeared in our app:

Umbrella header for module 'Realm' does not include header 'RLMMigration_Private.h'
Umbrella header for module 'Realm' does not include header 'RLMSyncManager_Private.h'

I guess that is an issue with Realm?

@segiddins
Copy link
Member

No, it’s a CocoaPods issue that we don’t know how to fix for static libraries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants