krzyzanowskim / OpenSSL

OpenSSL package for SwiftPM, CocoaPod, and Carthage, multiplatform
https://swift.best
Other
910 stars 336 forks source link

Project Catalyst Support (aka UIKit on macOS) #60

Closed chrisballinger closed 3 years ago

chrisballinger commented 5 years ago

It looks like perhaps xcframeworks will be required? I am trying to wrap my head around what is necessary to enable cross compilation for that new target platform.

$ xcodebuild archive -workspace Alamofire.xcworkspace -scheme "Alamofire iOS" -sdk iphoneos13.0 OBJROOT=build/iOS
$ xcodebuild archive -workspace Alamofire.xcworkspace -scheme "Alamofire iOS" -sdk iphonesimulator13.0 OBJROOT=build/simulator
$ xcodebuild -create-xcframework -framework build/iOS/UninstalledProducts/iphoneos/Alamofire.framework -framework build/simulator/UninstalledProducts/iphonesimulator/Alamofire.framework -output build/Alamofire.xcframework
chrisballinger commented 5 years ago

I did some more digging, it looks like you use a subfolder in the MacOSX SDK with a x86_64-apple-ios13.0-macabi target. Here are some nuggets I found in the raw build logs for compiling a C file in a static lib:

Compiling

CompileC /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/Objects-normal/x86_64/CrossTest.o /Users/xxxxxx/Desktop/Marzipan/CrossTwo/CrossTest.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (in target: CrossTwo)
    cd /Users/xxxxxx/Desktop/Marzipan
    export LANG=en_US.US-ASCII
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -target x86_64-apple-ios13.0-macabi -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu11 -fmodules -fmodules-cache-path=/Users/xxxxxx/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/xxxxxx/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DDEBUG=1 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -g -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Index/DataStore -iquote /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/CrossTwo-generated-files.hmap -I/Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/CrossTwo-own-target-headers.hmap -I/Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/CrossTwo-all-non-framework-target-headers.hmap -ivfsoverlay /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/all-product-headers.yaml -iquote /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/CrossTwo-project-headers.hmap -I/Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Products/Debug-uikitformac/include -isystem /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/usr/include -I/Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/DerivedSources-normal/x86_64 -I/Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/DerivedSources/x86_64 -I/Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/DerivedSources -F/Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Products/Debug-uikitformac -iframework /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/System/Library/Frameworks -MMD -MT dependencies -MF /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/Objects-normal/x86_64/CrossTest.d --serialize-diagnostics /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/Objects-normal/x86_64/CrossTest.dia -c /Users/xxxxxx/Desktop/Marzipan/CrossTwo/CrossTest.c -o /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/Objects-normal/x86_64/CrossTest.o

Libtool /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Products/Debug-uikitformac/libCrossTwo.a normal x86_64 (in target: CrossTwo)
    cd /Users/xxxxxx/Desktop/Marzipan
    export MACOSX_DEPLOYMENT_TARGET=10.15
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -D -syslibroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -L/Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Products/Debug-uikitformac -L/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/usr/lib -L/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/uikitformac -L/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/usr/lib -L/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/uikitformac -filelist /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Intermediates.noindex/Marzipan.build/Debug-uikitformac/CrossTwo.build/Objects-normal/x86_64/CrossTwo.LinkFileList -o /Users/xxxxxx/Library/Developer/Xcode/DerivedData/Marzipan-gbnckgdrmlikahasegoldvxdkpif/Build/Products/Debug-uikitformac/libCrossTwo.a
krzyzanowskim commented 5 years ago

If you have anything working, I'm happy to see it. Starting with PR would be great to collaborate I think.

chrisvanbuskirk commented 5 years ago

Linking a stackoverflow question I created already. Hopefully it will steer some traffic.

https://stackoverflow.com/questions/56459036/how-does-one-build-a-openssl-library-for-uikitformac

chrisballinger commented 5 years ago

Had some progress. This seems to be the magic trick: -target x86_64-apple-ios-macabi -miphoneos-version-min=13.0. Add it to CFLAGS and LDFLAGS.

hellc commented 5 years ago

Any progress update? Could we provide static libcrypto lib for UIKit on mac?

krzyzanowskim commented 5 years ago

I guess we need a script to build a xcframework structure. I didn't dig it much yet by myself.

hellc commented 5 years ago

@chrisballinger Could you provide a proper sh script to build libcrypto.a from public source? It should be compatible with UIKit for mac. Seems like export CFLAGS="-target x86_64-apple-ios-macabi -miphoneos-version-min=13.0" is not enough and I'm having trouble to use resulted static lib in UIKitForMac env. Then I could help u with Universal xcframework script.

chrisballinger commented 5 years ago

@hellc Here's a hacky WIP where OpenSSL is compiled in another context: https://github.com/ursachec/CPAProxy/compare/marzipan

fishandphil commented 5 years ago

Has anyone succeeded with this? Our catalyst app is like 99% ready appart from OpenSSL lib which we haven't achieved to build yet. Thanks

krzyzanowskim commented 4 years ago

I haven't tried it, but I'm interested in working and confirmed solution to include and release

benrosen78 commented 4 years ago

Any update on using this OpenSSL cocoapod in Catalyst?

krzyzanowskim commented 4 years ago

I didn't do much research, who wants to make it happen?

BubblyNetDev commented 4 years ago

Hello, are there any updates on this?

krzyzanowskim commented 3 years ago

Catalyst build is here as of 1.1.180 🎊