Skip to content

Swift compile for iOS #48

@mhewett-ks

Description

@mhewett-ks

I need to compile AMCL for use on IOS but I'm getting an error while trying to do that.

Choose a Scheme to support - 0 to finish: 21
<unknown>:0: warning: using sysroot for 'MacOSX' but targeting 'iPhone'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "DispatchOverlayShims.h"
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/shims/DispatchOverlayShims.h:219:20: error: implicit conversion of C pointer type 'dispatch_data_t _Nonnull' (aka 'struct dispatch_data_s *') to Objective-C pointer type '__swift_shims_dispatch_data_t _Nonnull' (aka 'id') requires a bridged cast
    return applier(data, off, loc, size);
                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/shims/DispatchOverlayShims.h:219:20: note: use __bridge to convert directly (no change in ownership)
    return applier(data, off, loc, size);
                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/shims/DispatchOverlayShims.h:219:20: note: use __bridge_transfer to transfer ownership of a +1 'dispatch_data_t _Nonnull' (aka 'struct dispatch_data_s *') into ARC
    return applier(data, off, loc, size);
                   ^
<unknown>:0: error: could not build Objective-C module '_SwiftDispatchOverlayShims'
Traceback (most recent call last):
  File "config64.py", line 302, in <module>
    curveset("bls381","48","58","381","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","NEGATIVEX","65","128")
  File "config64.py", line 148, in curveset
    run_in_shell("swiftc amcl"+slashtext+"*.swift " + target + sysroot + "-O -Ounchecked -whole-module-optimization -emit-library -emit-module -module-name amcl")
  File "config64.py", line 21, in run_in_shell
    subprocess.check_call(cmd, shell=True)
  File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'swiftc amcl/*.swift -target x86_64-apple-ios12.2-simulator -Fsystem /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -O -Ounchecked -whole-module-optimization -emit-library -emit-module -module-name amcl' returned non-zero exit status 1.

Since the error is in a Swift library I'm not sure how to proceed. I have XCode 10.3 installed which is the latest version. As an alternative I added the source files to my Swift project and used them without building the .dylib but it would be nice to know that the library build process works if we need it.

In the next-to-last line of output you can see that I added -Fsystem /Applications/.../iPhoneOS.sdk but I'm still getting the sysroot warning in the first line.

I added the amcl files to an existing XCode project designed to build a .dylib and it worked after adding "public" on all methods and adding header files such as BIG.h. Although it would be nice to get the current compilation method working another alternative would be to use a .xcodeproj file for configuration and call xcodebuild in the config script.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions