JamitLabs / Accio

A dependency manager driven by SwiftPM that works for iOS/tvOS/watchOS/macOS projects.
MIT License
664 stars 32 forks source link

accio fails to install dependencies #76

Closed tcurdt closed 5 years ago

tcurdt commented 5 years ago

I thought I give accio a try for a macOS project. I've created a simple Package.swift file:

// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "Demo",
    products: [],
    dependencies: [
        .package(url: "https://github.com/filom/ASN1Decoder.git", .upToNextMajor(from: "1.3.1"))
    ],
    targets: [
        .target(
            name: "Demo",
            dependencies: [
                "ASN1Decoder",
            ],
            path: "Demo"
        ),
    ]
)

When trying to build the dependency

$ accio update
...
✨  Building library ASN1Decoder with Carthage ...
*** xcodebuild output can be found in /var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/carthage-xcodebuild.TzqLBH.log
*** Skipped building ASN1Decoder due to the error:
Dependency "ASN1Decoder" has no shared framework schemes for any of the platforms: Mac
cp: /Users/tcurdt/Desktop/StoreKitExample/.accio/checkouts/ASN1Decoder/Carthage/Build/Mac/ASN1Decoder.framework: No such file or directory
Error: The operation couldn’t be completed. (SwiftShell.CommandError error 0.)

Running xcodebuild myself it builds just fine.

$ xcodebuild
...
CreateUniversalBinary /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework/ASN1Decoder normal armv7\ arm64 (in target: ASN1Decoder)
    cd /Users/tcurdt/Downloads/ASN1Decoder-1.3.1
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo -create /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/ASN1Decoder.build/Release-iphoneos/ASN1Decoder.build/Objects-normal/armv7/ASN1Decoder /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/ASN1Decoder.build/Release-iphoneos/ASN1Decoder.build/Objects-normal/arm64/ASN1Decoder -output /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework/ASN1Decoder

CpHeader /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/ASN1Decoder/ASN1Decoder.h /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework/Headers/ASN1Decoder.h (in target: ASN1Decoder)
    cd /Users/tcurdt/Downloads/ASN1Decoder-1.3.1
    builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/ASN1Decoder/ASN1Decoder.h /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework/Headers

GenerateDSYMFile /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework.dSYM /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework/ASN1Decoder (in target: ASN1Decoder)
    cd /Users/tcurdt/Downloads/ASN1Decoder-1.3.1
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework/ASN1Decoder -o /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework.dSYM

Touch /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework (in target: ASN1Decoder)
    cd /Users/tcurdt/Downloads/ASN1Decoder-1.3.1
    /usr/bin/touch -c /Users/tcurdt/Downloads/ASN1Decoder-1.3.1/build/Release-iphoneos/ASN1Decoder.framework

** BUILD SUCCEEDED **

Now I am wondering how to track this down. Is this a Carthage issue? Any pointers?

I am using:

$ accio version
Version: 0.6.3
$ carthage version
0.33.0
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.6
BuildVersion:   18G87
acecilia commented 5 years ago

Seems like an error from Carthage: it can not find a shared scheme for the Mac platform. Seems like the shared scheme is only for the iOS platform. You can try two things:

tcurdt commented 5 years ago

I tried the specifying the platform like this but that didn't help

let package = Package(
    name: "StoreKitExample",
    platforms: [ .macOS("10.14") ],
    dependencies: [
        .package(url: "https://github.com/filom/ASN1Decoder.git", .upToNextMajor(from: "1.3.1"))
    ],
    targets: [
        .target(
            name: "StoreKitExample",
            dependencies: [
                "ASN1Decoder",
            ],
            path: "StoreKitExample"
        ),
    ]
)
✨  Building library ASN1Decoder with Carthage ...
*** xcodebuild output can be found in /var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/carthage-xcodebuild.MsGnj7.log
*** Skipped building ASN1Decoder due to the error:
Dependency "ASN1Decoder" has no shared framework schemes for any of the platforms: Mac
cp: /Users/tcurdt/Desktop/StoreKitExample/.accio/checkouts/ASN1Decoder/Carthage/Build/Mac/ASN1Decoder.framework: No such file or directory
Error: The operation couldn’t be completed. (SwiftShell.CommandError error 0.)

I guess debugging Carthage it is :-(

tcurdt commented 5 years ago

Seems like the Xcode project isn't really setup to support macOS and iOS yet.

I guess Accio inherits the same pain from Carthage - having to bug project authors to fix their Xcode projects. I guess cocoapods conveniently hides that :-/

I guess I can close this here.

acecilia commented 5 years ago

You should be able to add the Mac platform to the supported platforms, in the Xcode project of ‘ASN1Decoder’. You can look at how RxSwift has done the setup, and do it similarly. Good luck! ;P

tcurdt commented 5 years ago

Yes, but I either need to fork it or have the author merge it. Always a hassle. Not the first time ;)

tcurdt commented 5 years ago

This was fixed faster than expected :)

$ accio update
✨  Reverting any changes in the checkouts directory ...
✨  Updating dependencies ...
Updating https://github.com/filom/ASN1Decoder.git
Completed resolution in 3.56s
Resolving https://github.com/filom/ASN1Decoder.git at master
✨  Reading package manifest at /path/Demo/Package.swift ...
✨  Generating dependency graph ...
✨  Resolving dependencies for target 'Demo' on platform 'macOS' ...
✨  Building library ASN1Decoder with Carthage ...
*** xcodebuild output can be found in /var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/carthage-xcodebuild.WTbq6l.log
*** Building scheme "ASN1Decoder macOS" in ASN1Decoder.xcodeproj
✨  Completed building scheme ASN1Decoder with Carthage.
✨  Saved build products for ASN1Decoder in local cache.
✨  Copying build products of target 'Demo' into folder 'Dependencies' ...
Error: The file “Info.plist” couldn’t be opened because there is no such file.

...but what is the error about the Info.plist about, @acecilia ?

tcurdt commented 5 years ago

Maybe that's related to https://github.com/JamitLabs/Accio/issues/73 ?

$ tree Dependencies
Dependencies
└── macOS
    ├── ASN1Decoder.framework
    │   ├── ASN1Decoder -> Versions/Current/ASN1Decoder
    │   ├── Headers -> Versions/Current/Headers
    │   ├── Modules -> Versions/Current/Modules
    │   ├── Resources -> Versions/Current/Resources
    │   └── Versions
    │       ├── A
    │       │   ├── ASN1Decoder
    │       │   ├── Headers
    │       │   │   ├── ASN1Decoder-Swift.h
    │       │   │   └── ASN1Decoder.h
    │       │   ├── Modules
    │       │   │   ├── ASN1Decoder.swiftmodule
    │       │   │   │   ├── x86_64.swiftdoc
    │       │   │   │   └── x86_64.swiftmodule
    │       │   │   └── module.modulemap
    │       │   └── Resources
    │       │       └── Info.plist
    │       └── Current -> A
    └── ASN1Decoder.framework.dSYM
        └── Contents
            ├── Info.plist
            └── Resources
                └── DWARF
                    └── ASN1Decoder
tcurdt commented 5 years ago

Also: Shouldn't accio make changes in the xcode project? I don't see any references yet.

tcurdt commented 5 years ago

Just noticed there is a "Dependency" group - but it's empty.

tcurdt commented 5 years ago

After some digging I found that the following should come next - but isn't. So accio is apparently aborting the integration just before.

✨  Adding frameworks ["ASN1Decoder...] to project navigator group 'Dependencies/ASN1Decoder' & linking with target 'Demo' ...
✨  Creating new copy build script phase 'Accio' for 'Demo'...
✨  Updating paths in build script 'Accio' for target 'Demo' ...
✨  Successfully updated dependencies.
tcurdt commented 5 years ago

Checking https://github.com/JamitLabs/Accio/blob/a308c68c842f9c2bf21ee23f430b8494e6e2919c/Tests/AccioKitTests/Services/XcodeProjectIntegrationServiceTests.swift it seems like there is the expectation of a plist at \(frameworkName).framework/Info.plist. I don't understand why yet.

tcurdt commented 5 years ago

I've tried to manually work around this by copying

cp Dependencies/macOS/ASN1Decoder.framework/Resources/Info.plist Dependencies/macOS/ASN1Decoder.framework

but the file disappears when calling accio install/update

tcurdt commented 5 years ago

Just tried with only Alamofire as dependency (as that seems to be one of the references in the tests). Fails with the same error. So it's not related to the ASN1Decoder.

$ accio install -v
✨  Reverting any changes in the checkouts directory ...
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire' reset HEAD --hard --quiet 2> /dev/null'
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire' clean -fd --quiet 2> /dev/null'
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire' clean -fdX --quiet 2> /dev/null'
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/ASN1Decoder' reset HEAD --hard --quiet 2> /dev/null'
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/ASN1Decoder' clean -fd --quiet 2> /dev/null'
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/ASN1Decoder' clean -fdX --quiet 2> /dev/null'
✨  Resolving dependencies ...
⏳ Executing 'swift package --package-path '/Users/tcurdt/Desktop/Demo' --build-path '/Users/tcurdt/Desktop/Demo/.accio' resolve'
✨  Reading package manifest at /Users/tcurdt/Desktop/Demo/Package.swift ...
✨  Generating dependency graph ...
✨  Dependency graph JSON output is:
{
  "name": "Demo",
  "url": "/Users/tcurdt/Desktop/Demo",
  "version": "unspecified",
  "path": "/Users/tcurdt/Desktop/Demo",
  "dependencies": [
    {
      "name": "Alamofire",
      "url": "https://github.com/Alamofire/Alamofire.git",
      "version": "5.0.0-beta.7",
      "path": "/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire",
      "dependencies": [

      ]
    }
  ]
}

⏳ Executing 'rm -rf '/var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/Accio/BuildProducts''
⏳ Executing 'rm -rf '/var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/Accio/Uncaching''
⏳ Executing 'mkdir -p '/var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/Accio/BuildProducts''
⏳ Executing 'mkdir -p '/var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/Accio/Uncaching''
✨  Resolving dependencies for target 'Demo' on platform 'macOS' ...
✨  Reading package manifest at /Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire/Package.swift ...
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire' reset HEAD --hard --quiet 2> /dev/null'
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire' clean -fd --quiet 2> /dev/null'
✨  Building library Alamofire with Carthage ...
⏳ Executing 'rm -rf '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire/Cartfile''
⏳ Executing 'rm -rf '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire/Cartfile.resolved''
✨  Found shared scheme(s) ["Alamofire macOS"] matching specified library – removing others: ["Alamofire iOS", "Alamofire tvOS", "Cleanup Whitespace", "Alamofire watchOS", "iOS Example"]
⏳ Executing '/usr/local/bin/carthage build --project-directory '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire' --platform macOS --no-skip-current --no-use-binaries'
*** xcodebuild output can be found in /var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/carthage-xcodebuild.c7iXNU.log
*** Building scheme "Alamofire macOS" in Alamofire.xcworkspace
⏳ Executing 'mkdir -p '/var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/Accio/BuildProducts/macOS''
⏳ Executing 'cp -R '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire/Carthage/Build/Mac/Alamofire.framework' '/var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/Accio/BuildProducts/macOS/Alamofire.framework''
⏳ Executing 'cp -R '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire/Carthage/Build/Mac/Alamofire.framework.dSYM' '/var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/Accio/BuildProducts/macOS/Alamofire.framework.dSYM''
⏳ Executing 'rm -rf '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire/Carthage/Build''
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire' reset HEAD --hard --quiet 2> /dev/null'
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire' clean -fd --quiet 2> /dev/null'
⏳ Executing 'git -C '/Users/tcurdt/Desktop/Demo/.accio/checkouts/Alamofire' clean -fdX --quiet 2> /dev/null'
✨  Completed building scheme Alamofire with Carthage.
⏳ Executing 'mkdir -p '/Users/tcurdt/Library/Caches/Accio/Cache/Swift-5.0.1/Alamofire/a6241748b5c5f38ca53fa8286788d2f90fa9c666''
✨  Saved build products for Alamofire in local cache.
⏳ Executing 'rm -rf /Users/tcurdt/Desktop/Demo/Dependencies/*'
✨  Copying build products of target 'Demo' into folder 'Dependencies' ...
⏳ Executing 'mkdir -p '/Users/tcurdt/Desktop/Demo/Dependencies/macOS''
⏳ Executing 'cp -R '/var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/Accio/BuildProducts/macOS/Alamofire.framework' '/Users/tcurdt/Desktop/Demo/Dependencies/macOS/Alamofire.framework''
⏳ Executing 'cp -R '/var/folders/pf/7vhqx5bn41qddypw08w9jc4w0000gn/T/Accio/BuildProducts/macOS/Alamofire.framework.dSYM' '/Users/tcurdt/Desktop/Demo/Dependencies/macOS/Alamofire.framework.dSYM''
Error: The file “Info.plist” couldn’t be opened because there is no such file.

Is there a special requirement for the project layout? I've used the default Xcode layout.

tcurdt commented 5 years ago

Any suggestions, @acecilia? I am a little stuck for the moment.

Jeehut commented 5 years ago

@tcurdt What version of Xcode and Swift (swift -version) are you using? Also, which macOS version are you running?

Regarding Info.plist issues, I think @mrylmz could know more to help you out.

tcurdt commented 5 years ago
$ swift -version
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.7.0

$ xcodebuild -version
Xcode 10.3
Build version 10G8

$ sw_vers 
ProductName:  Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G87
tcurdt commented 5 years ago

@mrylmz if you have an idea that would be great. Let me know if you need any more details.

tcurdt commented 5 years ago

Guys, any pointers? Right now this is a bit of a blocker for using accio - which is a shame. What are the requirements for the Info.plist? Looking at the code I don't understand the error yet.

Jeehut commented 5 years ago

As far as I can remember, the issue was the other way around: There were issues with existing Info.plist files and we just tried to fix them somehow. But @mrylmz implemented it if i remember correctly, so he knows the details. But feel free to make a PR which simply drops the requirement of the existence of the Info.plist and post a PR. If it fixes your issue without opening up new ones, I'd happily merge it.

tcurdt commented 5 years ago

Thanks for reply @Dschee. I'd be happy to help out and make a PR but at the moment I don't feel like I have the full picture yet.

It seems like this issue and #73 suggest that the added verifyBundleVersion in #70 is at fault. Of course we could just remove that check. That might fix it for us. But I am sure there was a reason it was added and I don't fully grasp that one yet.

One path of action would be to search for the Index.plist inside the framework or just ignore the error when it's not found at the expected location. We could also just check multiple locations. I just need to know the desire behaviour in order to fix it.

mrylmz commented 5 years ago

The introduction of the bundle version verification was to include a bundle version into it when it was missing, because the app store deployment get rejected without a version.

We could fallback to a solution where we print a warning if there is no Info.plist found inside the framework and suggest to submit an issue with the framework which was causing that problem.

@tcurdt if you bypass the verification step and your upload to app store is successful, then there wouldn’t be any problems, this could be a way of testing it.

tcurdt commented 5 years ago

Thanks for the input @mrylmz

Right now I have the feeling that accio just looks in the wrong place.

In the code I found

\(frameworkName).framework/Info.plist

but to me it looks like it rather should be

\(frameworkName).framework/Resources/Info.plist

I am not aware of Info.plist files at the root of framework bundles.

https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html

fredpi commented 5 years ago

As #77 is merged, I guess this can be closed now.