golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.32k stars 17.58k forks source link

x/mobile: gomobile [suggested fix provided] not working with Xcode 15.3 due to missing `Info.plist` via SPM #67000

Open g3devv opened 5 months ago

g3devv commented 5 months ago

Go version

go version go1.21.4 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/Meme/Library/Caches/go-build'
GOENV='/Users/Meme/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/Meme/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/Meme/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/w0/123_/T/go-build1234_=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I ran my iOS app that has a gomobile compiled framework as an SPM dependency.

Example project to reproduce the issue: github.com/g3devv/gomobile-plist-demo

What did you see happen?

66500 and #66018 is not entirely solved yet, Xcode still complains with the following output:

App installation failed: Unable to Install “pl0”

Please try again later. Failed to load Info.plist from bundle at path /Users/Meme/Library/Developer/CoreSimulator/Devices/123-456/data/Library/Caches/com.apple.mobile.installd.staging/temp.XTabc/extracted/Payload/pl0.app/Frameworks/Plexample.framework; Extra info about "/Users/Meme/Library/Developer/CoreSimulator/Devices/123-456/data/Library/Caches/com.apple.mobile.installd.staging/temp.XTabc/extracted/Payload/pl0.app/Frameworks/Plexample.framework/Info.plist": Couldn't stat /Users/Meme/Library/Developer/CoreSimulator/Devices/123-456/data/Library/Caches/com.apple.mobile.installd.staging/temp.XTabc/extracted/Payload/pl0.app/Frameworks/Plexample.framework/Info.plist: No such file or directory

What did you expect to see?

Because gomobile now adds the Info.plist files I expected everything to work again. Tree from my gomobile output:

gomobile-plist-demo/plexampleSPM/Frameworks
└── plexample.xcframework
    ├── Info.plist
    ├── ios-arm64
    │   └── Plexample.framework
    │       ├── Headers -> Versions/Current/Headers
    │       ├── Modules -> Versions/Current/Modules
    │       ├── Plexample -> Versions/Current/Plexample
    │       ├── Resources -> Versions/Current/Resources
    │       └── Versions
    │           ├── A
    │           │   ├── Headers
    │           │   │   ├── Plexample.h
    │           │   │   ├── Plexample.objc.h
    │           │   │   ├── Universe.objc.h
    │           │   │   └── ref.h
    │           │   ├── Modules
    │           │   │   └── module.modulemap
    │           │   ├── Plexample
    │           │   └── Resources
    │           │       └── Info.plist
    │           └── Current -> A
    └── ios-arm64_x86_64-simulator
        └── Plexample.framework
            ├── Headers -> Versions/Current/Headers
            ├── Modules -> Versions/Current/Modules
            ├── Plexample -> Versions/Current/Plexample
            ├── Resources -> Versions/Current/Resources
            └── Versions
                ├── A
                │   ├── Headers
                │   │   ├── Plexample.h
                │   │   ├── Plexample.objc.h
                │   │   ├── Universe.objc.h
                │   │   └── ref.h
                │   ├── Modules
                │   │   └── module.modulemap
                │   ├── Plexample
                │   └── Resources
                │       └── Info.plist
                └── Current -> A

(It has Info.plist in 3 places for 2 architectures)

Tree for my framework in the Derived Data:

Plexample.framework/
├── Headers -> Versions/Current/Headers
├── Modules -> Versions/Current/Modules
├── Plexample -> Versions/Current/Plexample
├── Resources -> Versions/Current/Resources
└── Versions
    ├── A
    │   ├── Headers
    │   │   ├── Plexample.h
    │   │   ├── Plexample.objc.h
    │   │   ├── Universe.objc.h
    │   │   └── ref.h
    │   ├── Modules
    │   │   └── module.modulemap
    │   ├── Plexample
    │   └── Resources
    │       └── Info.plist
    └── Current -> A

10 directories, 8 files

(It has no Info.plist in the root in case that matters)

g3devv commented 5 months ago

Adding to this, if I manually add the Info.plist to the Plexample.framework folder (where Xcode seems to expect it according to the error message and also where GoogleMobileAds has put it) it actually does show up in the derived data but I then get:

Please try again later. Failed to load Info.plist from bundle at path /Users/Meme/Library/Developer/CoreSimulator/Devices/123-456/data/Library/Caches/com.apple.mobile.installd.staging/temp.abc/extracted/Payload/pl0.app/Frameworks/Plexample.framework; Extra info about "/Users/Meme/Library/Developer/CoreSimulator/Devices/123-456/data/Library/Caches/com.apple.mobile.installd.staging/temp.abc/extracted/Payload/pl0.app/Frameworks/Plexample.framework/Info.plist": dev=16777234 ino=96894730 mode=0100644 nlink=1 uid=501 gid=20 rdev=0 size=212 atime=1713903777.230342 mtime=1713903777.179036 ctime=1713903777.410030 birthtime=1713903777.179036 blksize=4096 blocks=8 flags=0x0 firstBytes={length = 4, bytes = 0x3c3f786d} ACL=<not found> extendedAttributes=<not found> keyCount=0 

The error message doesn't indicate what's wrong with the new Plist tho

g3devv commented 5 months ago

Good news! After 8 hours and an unprecedented physical headache building up I think I have a solution now. I previously tried to use the GoogleMobileAds plist but I only replaced it on either plist which threw this error above. If I put the GoogleMobileAds Info.plist in

Plexample.framework/ + replace the Plist that gomobile generates, and then replace the key/string for:

    <key>CFBundleExecutable</key>
    <string>Plexample</string>

it finally runs the app again. I don't know if I'm allowed to share the file directly here but it's the one at

https://github.com/googleads/swift-package-manager-google-mobile-ads/commit/5ff977255c2ba5844e7e9da779f1f2a5a00e0028

So basically it looks like gomobile's fault is that the plist is empty, if we fill it with actual data it works. 🎉🥳

If I have permission to post the google plist here I can show a fully working example if it helps you

jimwei commented 5 months ago

[celebrate] WeiYaPeng(Jim) reacted to your message:


From: g3devv @.> Sent: Tuesday, April 23, 2024 8:35:24 PM To: golang/go @.> Cc: Subscribed @.***> Subject: Re: [golang/go] x/mobile: gomobile (demo project included) not working with Xcode 15.3 due to missing Info.plist via SPM (Issue #67000)

Good news! After 8 hours and an unprecedented physical headache building up I think I have a solution now. I previously tried to use the GoogleMobileAds plist but I only replaced it on either plist which threw this error above. If I put the GoogleMobileAds Info.plist in

Plexample.framework/ + replace the Plist that gomobile generates, and then replace the key/string for:

    <key>CFBundleExecutable</key>
    <string>Plexample</string>

it finally runs the app again. I don't know if I'm allowed to share the file directly here but it's the one at

@.***https://github.com/googleads/swift-package-manager-google-mobile-ads/commit/5ff977255c2ba5844e7e9da779f1f2a5a00e0028

So basically it looks like gomobile's fault is that the plist is empty, if we fill it with actual data it works. 🎉🥳

If I have permission to post the google plist here I can show a fully working example if it helps you

— Reply to this email directly, view it on GitHubhttps://github.com/golang/go/issues/67000#issuecomment-2073399403, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAKTSGIROVEYN7UECHPPOLTY63AYZAVCNFSM6AAAAABGVQYQ5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZTGM4TSNBQGM. You are receiving this because you are subscribed to this thread.Message ID: @.***>