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

Swift compiler error #202

Closed
mtso opened this issue Jun 27, 2016 · 27 comments
Closed

Swift compiler error #202

mtso opened this issue Jun 27, 2016 · 27 comments

Comments

@mtso
Copy link

mtso commented Jun 27, 2016

Hello Perfect team,
I tried following the README Quick Start instructions.

After I enter the following in Terminal:
git clone https://github.com/PerfectlySoft/PerfectTemplate.git
cd PerfectTemplate
swift build

I get:
/Users/matthewtso/git/PerfectTemplate/Packages/PerfectThread-0.10.0/Sources/ThreadQueue.swift:210:97: error: cannot convert value of type 'UnsafeMutablePointer<Void>' (aka 'UnsafeMutablePointer<()>') to expected argument type 'UnsafeMutablePointer<_>'

/Users/matthewtso/git/PerfectTemplate/Packages/PerfectThread-0.10.0/Sources/ThreadQueue.swift:233:37: error: value of type 'Unmanaged<IsThisRequired>' has no member 'toOpaque'

error: exit(1): /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/matthewtso/git/PerfectTemplate/.build/debug.yaml

Checking my Swift version returns the following:
Apple Swift version 3.0 (swiftlang-800.0.30 clang-800.0.24)
Target: x86_64-apple-macosx10.9

I'm pretty new and not sure how to diagnose this, is there something I can try to fix this?
Thanks!

@CharlesHarroch
Copy link

For fix this error, you can use swiftenv
swiftenv local 3.0

Or you can create .swift-version file with 3.0

@mtso
Copy link
Author

mtso commented Jun 27, 2016

Hi, thanks for responding. I am getting these errors with Swift version 3.0. Is there a particular snapshot I should be using?

@kjessup
Copy link
Member

kjessup commented Jun 27, 2016

We will always note the proper snapshot to use on the main README:

https://github.com/PerfectlySoft/Perfect/blob/master/README.md

As of right this moment, we are on DEVELOPMENT-SNAPSHOT-2016-06-20-a

Once the full 3.0 is released we will tag all of our components as 2.0.0.

@mtso
Copy link
Author

mtso commented Jun 27, 2016

With a fresh clone of PerfectTemplate.git and my local swiftenv rehashed and set to DEVELOPMENT-SNAPSHOT-2016-06-20-a, I am still running into the compiler errors I posted above when running swift build.

@kjessup
Copy link
Member

kjessup commented Jun 28, 2016

Did you:

swift build --clean=dist
swift build

The dist flag will have it delete all the downloaded packages and re-download the latest versions. This is often necessary when things are changing frequently as they are now.

@mtso
Copy link
Author

mtso commented Jun 28, 2016

Thanks for the suggestion! Just tried it, but it didn't fix the compiler error.

@CharlesHarroch
Copy link

After update my Perfect package, I've the same error.

@iamjono
Copy link
Member

iamjono commented Jun 28, 2016

@mtso and @CharlesHarroch can you clarify what OS you're using please?

@iamjono
Copy link
Member

iamjono commented Jun 28, 2016

Can you also paste in the output of swift --version please.
You should get something like this
$ swift --version
Apple Swift version 3.0-dev (LLVM cb08d1dbbd, Clang 383859a9c4, Swift 9e8266aaeb) Target: x86_64-apple-macosx10.9

@iamjono
Copy link
Member

iamjono commented Jun 28, 2016

I just verified on mine and it builds ok, the choosing of the command line tools version is the only thing that might be different.

@CharlesHarroch
Copy link

I use OS X 10.11.5

swift --version
Apple Swift version 3.0-dev (LLVM c191431197, Clang c6195325c5, Swift add621a959) Target: x86_64-apple-macosx10.9

My error :

Compile Swift Module 'PerfectThread' (2 sources)
****/Packages/PerfectThread-0.10.0/Sources/ThreadQueue.swift:210:97: error: cannot convert value of type 'UnsafeMutablePointer<Void>' (aka 'UnsafeMutablePointer<()>') to expected argument type 'UnsafeMutablePointer<_>'
            let unleakyObject = Unmanaged<IsThisRequired>.fromOpaque(UnsafeMutablePointer<Void>(p)).takeRetainedValue()
                                                                                                ^
****/Packages/PerfectThread-0.10.0/Sources/ThreadQueue.swift:233:37: error: value of type 'Unmanaged<IsThisRequired>' has no member 'toOpaque'
        let leakyObject = Unmanaged.passRetained(holderObject).toOpaque()
                          ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
<unknown>:0: error: build had 1 command failures

@mtso
Copy link
Author

mtso commented Jun 28, 2016

I am also using macOS 10.11.5.
Xcode Version 8.0 beta (8S128d)

@kjessup yes, I made sure to set Xcode 8 in Locations > Command Line Tools.

It doesn't show the LLVM part, though?
$ swift --version
Apple Swift version 3.0 (swiftlang-800.0.30 clang-800.0.24)
Target: x86_64-apple-macosx10.9

If I package generate an Xcode project, those errors are caught by the checker.

screen shot 2016-06-28 at 10 58 03 am

screen shot 2016-06-28 at 11 00 33 am

@iamjono
Copy link
Member

iamjono commented Jun 28, 2016

Good news... I've managed to reproduce the error. We'll be back to you soon :)
Thanks!

@iamjono
Copy link
Member

iamjono commented Jun 28, 2016

Solved:

  1. Make sure you have the latest (as of current time) snapshot installed. If you have swiftenv installed you can install it using this:
    swiftenv install DEVELOPMENT-SNAPSHOT-2016-06-20-a
    Then select as current using:
    swiftenv local DEVELOPMENT-SNAPSHOT-2016-06-20-a
  2. In Xcode > Preferences > Locations, make sure the Xcode 8 is definitely set for command line tools.
  3. Xcode -> Toolchains -> Select the dev snapshot that you just installed.

Then try build.
These steps worked for me, lets hope it solves for you. Please let me know?

@mtso
Copy link
Author

mtso commented Jun 28, 2016

Thank you so much for the help, I really appreciate it. Following the above steps, I'm able to properly compile with git clone https://github.com/PerfectlySoft/Perfect.git.

However, I get the same error when I try using the starter project git clone https://github.com/PerfectlySoft/PerfectTemplate.git.

In case the bit in the parens might help, my System Version: OS X 10.11.5 (15F34)
And my full terminal output:
mtso_terminaloutput_062816.txt

@CharlesHarroch
Copy link

Same for me

@colourful987
Copy link

@mtso whether you change Xcode -> Toolchains -> Swift Development Snapshot 2016-06-20-a?
@iamjono Thank you for your help. It works for me!

@tomisacat
Copy link

Do as same as comment said:

1. install DEVELOPMENT-SNAPSHOT-2016-06-20-a;
2. swiftenv local DEVELOPMENT-SNAPSHOT-2016-06-20-a;
3. Xcode -> Preference -> Locations and select Xcode 8;
4. Xcode -> Toolchains -> DEVELOPMENT-SNAPSHOT-2016-06-20-a;
5. clean and build;

and my system is macOS 10.11.5, but sadly it still got the same error.

@colourful987
Copy link

@tomisacat try Xcode -> Preference -> DEVELOPMENT-SNAPSHOT-2016-06-20-a

@colourful987
Copy link

colourful987 commented Jun 30, 2016

most of people follow the tutorial :

  1. clone PerfectTemplate and swift build , It works!
  2. Enter swift package generate-xcodeproj in terminal and Open the generated file "PerfectTemplate.xcodeproj" by Xcode IDE ,Ensure that you have selected the executable target and selected it to run on "My Mac" ,It failed!

Solved:

  1. install DEVELOPMENT-SNAPSHOT-2016-06-20-a(the lastest),You could download in swift.org,or install swiftenv firstly,then enter swiftenv install DEVELOPMENT-SNAPSHOT-2016-06-20-a
  2. if you use swiftenv ,then enter swiftenv local DEVELOPMENT-SNAPSHOT-2016-06-20-a in terminal. otherwise just skip;
  3. Xcode -> Preference -> Components->DEVELOPMENT-SNAPSHOT-2016-06-20-a(Not Xcode 8.0);
    Or Xcode -> Toolchains -> DEVELOPMENT-SNAPSHOT-2016-06-20-a;
  4. Xcode -> Location -> Command Line Tools -> Xode8
  5. clean and build;

Note:
Apple official document point out:
Selecting a Swift toolchain affects the Xcode IDE only. To use the Swift toolchain with command-line tools, use xcrun --toolchain swift and xcodebuild -toolchain swift, or add the Swift toolchain to your path as follows:

$ export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"

Hope this could help you

@tomisacat
Copy link

@colourful987 Thanks for helping. But What do you mean about 3. Xcode -> Preference -> DEVELOPMENT-SNAPSHOT-2016-06-20-a(Not Xcode 8)? I could only find Command Line Tools(and select Xcode 8) in Location tab and Toolchains(Swift Development Snapshot selected) in Component tab.

btw, only these Swift versions installed in my system:

$> swiftenv version
* DEVELOPMENT-SNAPSHOT-2016-06-20-a (set by /Users/my_user_name/WorkSpace/PerfectTemplate/.swift-version)
  3.0
  2.1.1

and as you see, the development snapshot is the current version for the project.

@tomisacat
Copy link

It just worked strangely that I re-clean-and-build and I checked the last commit, it's early than the time I tried last time. Strange but amazing : )

@carlsondev
Copy link

@colourful987 I have been attempting to get my project working. I tried cloning the PerfectTemplate and running swift build.....And I got the same error as with my own project. I have the newest snapshot downloaded and have it selected however I still get the error.

@iamjono
Copy link
Member

iamjono commented Jun 30, 2016

@FibonacciRedstone i presume you have followed the steps @colourful987 laid out?

Solved:

  1. install DEVELOPMENT-SNAPSHOT-2016-06-20-a(the lastest),You could download in swift.org,or install swiftenv firstly,then enter swiftenv install DEVELOPMENT-SNAPSHOT-2016-06-20-a
  2. swiftenv local DEVELOPMENT-SNAPSHOT-2016-06-20-a;
  3. Xcode -> Preference -> Components->DEVELOPMENT-SNAPSHOT-2016-06-20-a(Not Xcode 8.0);
    Or Xcode -> Toolchains -> DEVELOPMENT-SNAPSHOT-2016-06-20-a;
  4. Xcode -> Location -> Command Line Tools -> Xode8
  5. clean and build;

@carlsondev
Copy link

@iamjono I don't have "swiftenv" installed however I have installed the 6-20 snapshot and my swift --version shows this. I also have steps 3-6 completed and I am still getting those errors

@mtso
Copy link
Author

mtso commented Jun 30, 2016

I figured out what went wrong on my end.
Didn't realize I had to make the tools available for use in my Terminal by running the following in my Terminal:
$ export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"
Now PerfectTemplate also builds without error.
Thanks, all!

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

No branches or pull requests

7 participants