krzyzanowskim / OpenSSL

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

help in install with Xcode #138

Closed SodaSurfer closed 2 years ago

SodaSurfer commented 2 years ago

Hello and thanks for your work

I am trying to install it for Xcode. I'm using a Mac with m1.

the instructions part under the Xcode Setup says :

  1. Then add a new entry to the User Header Search Paths. This should be the location of the OpenSSL header files that were included in OpenSSLUniversal. - which headers folders does it mean? there are a lot of headers folder included in OpenSSLUniversal.

is it those headers folders: Frameworks/OpenSSL.xcframework/ios-arm64_armv7/OpenSSL.framework/Headers/ Frameworks/OpenSSL.xcframework/ios-arm64_i386_x86_64-simulator/OpenSSL.framework/Headers/ Frameworks/OpenSSL.xcframework/ios-arm64_x86_64-maccatalyst/OpenSSL.framework/Headers/ Frameworks/OpenSSL.xcframework/macos-arm64_x86_64/OpenSSL.framework/Headers/

or is it: iphoneos/include/openssl/ iphonesimulator/include/openssl/ macosx/include/openssl/ macosx_catalyst/include/openssl/

or: Frameworks/iphoneos/OpenSSL.framework/Headers/ Frameworks/iphonesimulator/OpenSSL.framework/Headers/ Frameworks/macosx/OpenSSL.framework/Headers/ Frameworks/macosx_catalyst/OpenSSL.framework/Headers/

thank you

krzyzanowskim commented 2 years ago

for xcframework you don't need to set headers path, just drag and drop framework to the project and that should be all you need to do

SodaSurfer commented 2 years ago

@krzyzanowskim do you mean the Frameworks folder? where should I drop it inside my project? I've been trying for about 4 hours to install the repo but without success. The folder that is created after "pod install" is different then the folder then I get when I clone the repo. the Framework folder that is created from pod install doesn't contains the iphoneos, macosx etc. folders, not the static libs so I'm not so sure how I should handle it and where to copy what. would really appreciate any detailed help. cheers & thanks a lot

krzyzanowskim commented 2 years ago

whenever you want. drag'n'drop OpenSSL.xcframework

https://user-images.githubusercontent.com/758033/152779148-2653cfa4-5090-494a-b448-f0300fcb1229.mov

SodaSurfer commented 2 years ago

do I also need to tell Xcode where the static libs are? I still also need to follow this step: Select Build Phases and Link Binary With Libraries. Select + and navigate to the static OpenSSL libraries that was included in the framework. ? because I haven't done it now (after your reply) and I get an error of: Could not build Objective-C module 'OpenSSL'

krzyzanowskim commented 2 years ago

no.

SodaSurfer commented 2 years ago

thanks for the quick support. I have fixed the objective-c issue by following this issue: https://github.com/krzyzanowskim/OpenSSL/issues/117

but to make sure if I succeeded in installing it, I tried to write a simple code that uses this lib:

import SwiftUI
import OpenSSL

struct ContentView: View {
    let cert : UnsafeMutablePointer<X509>

    var body: some View {
        Text("Hello, world!")
            .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

But I get a compile error: Cannot find type 'X509' in scope

even though the lib should have been imported. am I missing some steps?

krzyzanowskim commented 2 years ago

great.

am I missing some steps?

that's how Swift imports OpenSSL C headers. https://github.com/krzyzanowskim/OpenSSL/issues/108#issuecomment-760473047