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

consider supporting xcframworks #38

Closed
johndpope opened this issue Aug 31, 2022 · 4 comments
Closed

consider supporting xcframworks #38

johndpope opened this issue Aug 31, 2022 · 4 comments

Comments

@johndpope
Copy link

had some success spitting this out

https://github.com/mstfy/spm-to-xcframework

/Users/johndpope/Desktop/spm-to-xcframework/.build/arm64-apple-macosx/release/spm-to-xcframework Sup
abase --path /Users/johndpope/Desktop/supabase-swift --output /Users/johndpope/Desktop/xcframework

Screen Shot 2022-08-31 at 11 23 17 am

it's helpful for bazel builds

@johndpope johndpope reopened this Sep 3, 2022
@johndpope
Copy link
Author

johndpope commented Sep 3, 2022

Sorry - bumping into several issues here

this library
https://github.com/unsignedapps/swift-create-xcframework

brew install mint
mint install unsignedapps/swift-create-xcframework
swift create-xcframework --platform ios

I need a path to get this working -
the realtime has an issue with zlib

spleeter) ➜ supabase-swift git:(master) ✗ swift create-xcframework --platform ios
Error: Xcode project generation is not supported by Swift Package Manager for packages that reference system modules.These system modules were referenced: swift-nio-zlib-support

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
  name: "Supabase",
  platforms: [
    .iOS(.v13),
    .macCatalyst(.v13),
    .macOS(.v10_15),
    .watchOS(.v6),
    .tvOS(.v13),
  ],
  products: [
    .library(
      name: "Supabase",
      targets: ["Supabase"]
    )
  ],
  dependencies: [
    .package(url: "https://github.com/supabase-community/gotrue-swift", from: "0.0.7"),
    .package(url: "https://github.com/supabase-community/storage-swift.git", from: "0.0.2"),
    .package(url: "https://github.com/supabase-community/postgrest-swift", from: "0.0.6"),
  ],
  targets: [
    .target(
      name: "Supabase",
      dependencies: [
        .product(name: "GoTrue", package: "gotrue-swift"),
        .product(name: "SupabaseStorage", package: "storage-swift"),
        .product(name: "PostgREST", package: "postgrest-swift"),
      ]
    )
  ]
)

I still hit this

** ARCHIVE FAILED **

The following build commands failed:
CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler (in target 'SupabaseStorage' from project 'Supabase')
CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler (in target 'KeychainAccess' from project 'Supabase')
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KeychainAccess' from project 'Supabase')
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'AnyCodable' from project 'Supabase')
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'Get' from project 'Supabase')
CompileSwift normal arm64 (in target 'Get' from project 'Supabase')
(6 failures)
Error: xcodebuild exited with a non-zero code: 65

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
  name: "Supabase",
  platforms: [
    .iOS(.v13),
    .macCatalyst(.v13),
    .macOS(.v10_15),
    .watchOS(.v6),
    .tvOS(.v13),
  ],
  products: [
    .library(
      name: "Supabase",
      targets: ["Supabase"]
    )
  ],
  dependencies: [
    .package(url: "https://github.com/supabase-community/gotrue-swift", from: "0.0.7"),
    .package(url: "https://github.com/supabase-community/storage-swift.git", from: "0.0.2"),
    .package(url: "https://github.com/wweevv-johndpope/realtime-swift.git", from: "0.0.2"),
    .package(url: "https://github.com/supabase-community/postgrest-swift", from: "0.0.6"),
  ],
  targets: [
    .target(
      name: "Supabase",
      dependencies: [
        .product(name: "GoTrue", package: "gotrue-swift"),
        .product(name: "SupabaseStorage", package: "storage-swift"),
        .product(name: "Realtime", package: "realtime-swift"),
        .product(name: "PostgREST", package: "postgrest-swift"),
      ]
    )
  ]
)

I hack the package to use my fork which has this fix
daltoniam/Starscream#844

but still not working...

swift create-xcframework --platform ios --stack-evolution

Screen Shot 2022-09-04 at 10 46 46 am

Screen Shot 2022-09-04 at 10 51 22 am

let closeCode = (error as? WSError)?.code ?? RealtimeClient.CloseCode.abnormal.rawValue

probably due to the hot fix above - I'll do some digging.

UPDATE

after some hotfixes - I got it to compile.

not sure what's going on - but seems like theres some code rot with the realtime.
wweevv-johndpope/realtime-swift@36cdcac

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
  name: "Supabase",
  platforms: [
    .iOS(.v13),
    .macCatalyst(.v13),
    .macOS(.v10_15),
    .watchOS(.v6),
    .tvOS(.v13),
  ],
  products: [
    .library(
      name: "Supabase",
      targets: ["Supabase"]
    )
  ],
  dependencies: [
    .package(url: "https://github.com/supabase-community/gotrue-swift", from: "0.0.7"),
    .package(url: "https://github.com/supabase-community/storage-swift.git", from: "0.0.2"),
    .package(url: "https://github.com/wweevv-johndpope/realtime-swift.git", from: "0.0.5"),
    .package(url: "https://github.com/supabase-community/postgrest-swift", from: "0.0.6"),
  ],
  targets: [
    .target(
      name: "Supabase",
      dependencies: [
        .product(name: "GoTrue", package: "gotrue-swift"),
        .product(name: "SupabaseStorage", package: "storage-swift"),
        .product(name: "Realtime", package: "realtime-swift"),
        .product(name: "PostgREST", package: "postgrest-swift"),
      ]
    )
  ]
)

not sure if this will work - but goal is to get a file like this
https://github.com/wweevv-johndpope/supabase-xcframework

UPDATE
so it's possible to render out all the frameworks as so

swift create-xcframework AnyCodable ComposableKeychain Get GoTrue KeychainAccess PostgREST Realtime Starscream SupabaseStorage URLQueryEncoder XCTestDynamicOverlay --platform ios --stack-evolution

something breaks on import

Screen Shot 2022-09-04 at 12 00 28 pm

@johndpope
Copy link
Author

johndpope commented Sep 4, 2022

https://github.com/apple/swift-package-manager/blob/main/Sources/SPMLLBuild/llbuild.swift

It maybe possible to reduce number of xcframeworks by using this technique
https://developer.apple.com/forums/thread/650995
You’d just need to modify a couple of lines in this library…. (I think)

UPDATE -

at this point using a bunch of hot fixes (renamed modules) + swift-create-xcframework

I can successfully create all the packages -

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
  name: "Supabase",
  platforms: [
    .iOS(.v13),
    .macCatalyst(.v13),
    .macOS(.v10_15),
    .watchOS(.v6),
    .tvOS(.v13),
  ],
  products: [
    .library(
      name: "Supabase",
      targets: ["Supabase"]
    )
  ],
  dependencies: [
    .package(url: "https://github.com/wweevv-johndpope/gotrue-swift", from: "0.0.10"),
    .package(url: "https://github.com/supabase-community/storage-swift.git", from: "0.0.2"),
    .package(url: "https://github.com/wweevv-johndpope/realtime-swift.git", from: "0.0.5"),
    .package(url: "https://github.com/supabase-community/postgrest-swift", from: "0.0.6"),
  ],
  targets: [
    .target(
      name: "Supabase",
      dependencies: [
        .product(name: "GoTrue", package: "gotrue-swift"),
        .product(name: "SupabaseStorage", package: "storage-swift"),
        .product(name: "Realtime", package: "realtime-swift"),
        .product(name: "PostgREST", package: "postgrest-swift"),
      ]
    )
  ]
)

So currently - this is crashing
binaryscraping/swift-composable-keychain#1

UPDATE

this is a slim example of supabase integration + bazel - demonstrating crash.

git clone https://github.com/wweevv-johndpope/DemoBazel/tree/supabase
./xcodegen app

cheatsheet for adding dependencies with bazel
https://docs.google.com/presentation/d/1ZYwyA_zHjDugt4UH-APJt4qBSt_fbY_286WrgFQvdfA/edit#slide=id.p

@grdsdev
Copy link
Collaborator

grdsdev commented Nov 5, 2022

Supporting xcframework is not in the roadmap for now, we can revisit this later if priority changes.

@grdsdev grdsdev closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2022
@johndpope
Copy link
Author

Hi @bok- have you encountered any problems in general with xcframework / where the swift code that would automatically deallocate / BAD_EXEC - but run fine when code is ran locally?
supabase-community/gotrue-swift#32

image

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

2 participants