giginet / Scipio

A new build tool to generate XCFramework
https://giginet.github.io/Scipio/documentation/scipio
MIT License
440 stars 26 forks source link

Not possible to use Scipio to build some of the popular frameworks #26

Open mikeger opened 1 year ago

mikeger commented 1 year ago

Hey 👋

I've tried to use Scipio for my project, but I've found a couple of issues. The following frameworks cannot be compiled:

SDWebImage

Compilation error

The following build commands failed:
    CompileC /Users/m.gerasymenko/Library/Developer/Xcode/DerivedData/RiderAppDependencies-hemauyjxyusqbydjtqogvbdpzofn/Build/Intermediates.noindex/ArchiveIntermediates/SDWebImageMapKit/IntermediateBuildFilesPath/RiderAppDependencies.build/Release-iphoneos/SDWebImage.build/Objects-normal/arm64/UIColor+SDHexString.o /Users/m.gerasymenko/Projects/logistics-rider-app-ios/.build/checkouts/SDWebImage/SDWebImage/Private/UIColor+SDHexString.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'SDWebImage' from project 'RiderAppDependencies')

GoogleTagManager

Compilation error

The following build commands failed:
    CompileC /Users/m.gerasymenko/Library/Developer/Xcode/DerivedData/RiderAppDependencies-hemauyjxyusqbydjtqogvbdpzofn/Build/Intermediates.noindex/ArchiveIntermediates/GoogleTagManagerTarget/IntermediateBuildFilesPath/RiderAppDependencies.build/Release-iphoneos/GoogleUtilities-NSData.build/Objects-normal/arm64/GULNSData+zlib.o /Users/m.gerasymenko/Projects/logistics-rider-app-ios/.build/checkouts/GoogleUtilities/GoogleUtilities/NSData+zlib/GULNSData+zlib.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'GoogleUtilities_NSData' from project 'RiderAppDependencies')
(1 failure)

Firebase

Seems that one of the sub-dependencies are not automatically linked.

xcodebuild: error: The project named "RiderAppDependencies" does not contain a scheme named "FirebaseStorageSwift". The "-list" option can be used to find the names of the schemes in the project.

Example Package.swift


// swift-tools-version:5.6

import PackageDescription

let package = Package(
    name: "RiderAppDependencies",
    platforms: [
        .iOS(.v11),
    ],
    products: [],
    dependencies: [
        .package(url: "https://github.com/firebase/firebase-ios-sdk.git", exact: "8.15.0"),
        .package(url: "https://github.com/googleanalytics/google-tag-manager-ios-sdk.git", exact: "7.4.1"),
        .package(url: "https://github.com/vadymmarkov/Fakery", exact: "5.1.0"),
        .package(url: "https://github.com/SDWebImage/SDWebImage.git", exact: "5.8.2")
    ],
    targets: [
        .target(
            name: "RiderAppDependencies",
            dependencies: [
                .productItem(name: "FirebaseRemoteConfig", package: "firebase-ios-sdk"),
                .productItem(name: "FirebasePerformance", package: "firebase-ios-sdk"),
                .productItem(name: "FirebaseAnalytics", package: "firebase-ios-sdk"),
                .productItem(name: "FirebaseCrashlytics", package: "firebase-ios-sdk"),

                .productItem(name: "GoogleTagManager", package: "google-tag-manager-ios-sdk"),
                .productItem(name: "Fakery", package: "Fakery"),
                .productItem(name: "SDWebImage", package: "SDWebImage"),
                .productItem(name: "SDWebImageMapKit", package: "SDWebImage")
            ])
    ]
)
giginet commented 1 year ago

SDWebImage uses cSettings on Package.swift. Scipio can't treat this declaration correctly. I'm going to fix this.

https://github.com/SDWebImage/SDWebImage/blob/master/Package.swift#L36-L37

squarefrog commented 1 year ago

I'm unable to build Firebase either. There is a third-party Package manifest that includes pre-built xcframework files though: https://github.com/akaffenberger/firebase-ios-sdk-xcframeworks

There is an in-depth discussion about this repo here: https://github.com/firebase/firebase-ios-sdk/issues/6564

I've found another package that wouldn't build called SVGKit. This is an objective-c framework, which I suspect some parts of Firebase are too. Perhaps this could be a problem?

squarefrog commented 1 year ago

I had a look into this with another Objective-C library we use, that is a little simpler than Firebase. It's called SnowplowTracker.

Trying to build this with scipio produces build errors:

Verbose build output ``` $ mint run scipio prepare . --verbose 🔁 Resolving Dependencies... loading manifest for 'dependencies' v. unknown from cache loading manifest for 'snowplow-objc-tracker' v. 5.0.0 from cache loading manifest for 'fmdb' v. 2.7.7 from cache loading manifest for 'dependencies' v. unknown from cache /usr/bin/xcrun clang --version /usr/bin/xcrun clang --version ⚠️ Existing FMDB.xcframework is outdated. 🗑️ Delete FMDB.xcframework 📦 Building FMDB for iOS /usr/bin/xcrun xcode-select -p /usr/bin/xcrun --sdk iphoneos --show-sdk-path /usr/bin/xcrun xcode-select -p /Applications/Xcode-14.3.0.app/Contents/SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild build /path/to/Dependencies/.build/scipio/manifest-Dependencies-iphoneos.pif --configuration Release --derivedDataPath /path/to/Dependencies/.build/scipio/DerivedData --buildParametersFile /path/to/Dependencies/.build/scipio/build-parameters-iphoneos.json --target FMDB 🚀 Combining into XCFramework... /usr/bin/xcrun xcode-select -p /Applications/Xcode-14.3.0.app/Contents/SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild createXCFramework -framework /path/to/Dependencies/.build/scipio/DerivedData/Products/Release-iphoneos/PackageFrameworks/FMDB.framework -output /path/to/Dependencies/XCFrameworks/FMDB.xcframework 📦 Building SnowplowTracker for iOS /usr/bin/xcrun xcode-select -p /usr/bin/xcrun --sdk iphoneos --show-sdk-path /usr/bin/xcrun xcode-select -p /Applications/Xcode-14.3.0.app/Contents/SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild build /path/to/Dependencies/.build/scipio/manifest-Dependencies-iphoneos.pif --configuration Release --derivedDataPath /path/to/Dependencies/.build/scipio/DerivedData --buildParametersFile /path/to/Dependencies/.build/scipio/build-parameters-iphoneos.json --target SnowplowTracker Unable to build for iOS ⚠️ Execution was terminated: Build description signature: e810aa82ab806c81ffd2b0d4c4752809 Build description path: /path/to/Dependencies/.build/scipio/DerivedData/Intermediates.noindex/XCBuildData/e810aa82ab806c81ffd2b0d4c4752809.xcbuilddata Building targets in dependency order Undefined symbols for architecture arm64: "_OBJC_CLASS_$_FMDatabaseQueue", referenced from: objc-class-ref in SQLiteEventStore.o ld: symbol(s) not found for architecture arm64 Undefined symbol: _OBJC_CLASS_$_FMDatabaseQueue clang: error: linker command failed with exit code 1 (use -v to see invocation) Linker command failed with exit code 1 (use -v to see invocation) 🚀 Combining into XCFramework... /usr/bin/xcrun xcode-select -p /Applications/Xcode-14.3.0.app/Contents/SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild createXCFramework -framework /path/to/Dependencies/.build/scipio/DerivedData/Products/Release-iphoneos/PackageFrameworks/SnowplowTracker.framework -output /path/to/Dependencies/XCFrameworks/SnowplowTracker.xcframework Something went wrong during building Execution was terminated: error: unable to read the file at '/path/to/Dependencies/.build/scipio/DerivedData/Products/Release-iphoneos/PackageFrameworks/SnowplowTracker.framework/SnowplowTracker' Error: Execution was terminated: error: unable to read the file at '/path/to/Dependencies/.build/scipio/DerivedData/Products/Release-iphoneos/PackageFrameworks/SnowplowTracker.framework/SnowplowTracker' ```
Package.swift ``` // swift-tools-version: 5.6 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "Dependencies", platforms: [ .iOS(.v14), ], products: [], dependencies: [ .package(url: "https://github.com/snowplow/snowplow-objc-tracker", exact: "5.0.0"), ], targets: [ .target( name: "Dependencies", dependencies: [ .product(name: "SnowplowTracker", package: "snowplow-objc-tracker"), ]), ] ) ```

However I was able to build with swift-create-xcframework:

$ swift create-xcframework --platform ios SnowplowTracker
...
xcframework successfully written out to: /path/to/snowplow-objc-tracker/SnowplowTracker.xcframework

Perhaps it might be worth comparing the differences between the generated xcodebuild commands of scipio and swift-create-xcframework?