簡體   English   中英

使用 Google 登錄 iOS 和 Swift Package 管理器

[英]Using Google Sign In for iOS with Swift Package Manager

Somewhat like Build iOS App having Google Sign with support for Mac , I have embedded the Google Sign in for iOS framework and bundle into an Xcode project, but I'm targeting only iOS. 我的需要是使用 Swift Package 管理器和 Google 登錄 iOS。

我正在創建這個問題以添加我當前的解決方案並查看其他人是否有解決方案。 並嘗試鼓勵 Google 支持 Swift Package Manager with Google Sign In for iOS :)。

為此,我創建了 Google Sign 的 XCFramework 版本。 請參閱https://github.com/SyncServerII/GSignIn.git 到目前為止,可以使用 Xcode iOS 模擬器和實際 iOS 設備進行測試和開發。

構建后,將在 Package.swift 清單中使用,例如:

        .binaryTarget(
            // This was generated using https://github.com/SyncServerII/GSignIn.git
            name: "GSignIn",
            path: "Frameworks/GSignIn.xcframework"
        ),

(有關完整示例,另請參見https://github.com/SyncServerII/iOSGoogle/blob/main/Package.swift )。

到目前為止的問題:

  1. 我顯然無法訪問捆綁資產。 我不得不創建一個新的 Google 登錄按鈕。 沒什么大不了的,但為了完整起見,我想訪問谷歌登錄框架提供的谷歌按鈕。

  2. 此 package 取決於特定版本的 Google 登錄。 更新它需要進入https://github.com/SyncServerII/GSignIn.git並根據 Google 登錄框架的更新手動更新它。

我尚未將使用此 package 的應用程序部署到應用程序商店,因此目前尚不清楚。

- 更新 -

20 年 12 月 28 日(已解決——請參閱下面的 1/1/21 更新):我還應該注意,我在共享擴展中收到了此庫的警告:

ld:警告:鏈接到在應用程序擴展中使用不安全的 dylib:/Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Products/Debug-iphoneos/GSignIn.framework/GSignIn

當我在我的目標應用程序中使用這個框架構建時,它有一個共享擴展。 我還沒有嘗試將這個應用程序上傳到應用程序商店,所以不知道會發生什么。

20 年 12 月 29 日(已解決 - 請參閱下面的 1/1/21 更新):我之前使用 Google 登錄 package 從本地目錄拖到我的應用程序中進行構建。 我剛剛嘗試在我的應用程序中從不拖入,而只是依賴它作為 swift package,使用它的 Github repo 引用。 這打破了各種模糊的 linker 錯誤的構建,如下所示:

Showing All Messages
Ld /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Products/Debug-iphoneos/Share\ Extension.appex/Share\ Extension normal (in target 'Share Extension' from project 'Neebla')
    cd /Users/chris/Developer/Neebla
    /Applications/Xcode-12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios14.0 -isysroot /Applications/Xcode-12.3.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.3.sdk -L/Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Products/Debug-iphoneos -F/Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Products/Debug-iphoneos -filelist /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/Neebla.build/Debug-iphoneos/Share\ Extension.build/Objects-normal/arm64/Share\ Extension.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/../../Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/Neebla.build/Debug-iphoneos/Share\ Extension.build/Objects-normal/arm64/Share\ Extension_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fembed-bitcode-marker -fapplication-extension -fobjc-link-runtime -L/Applications/Xcode-12.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/Neebla.build/Debug-iphoneos/Share\ Extension.build/Objects-normal/arm64/Share_Extension.swiftmodule -lc++ -framework Accelerate -e _NSExtensionMain -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/Neebla.build/Debug-iphoneos/Share\ Extension.build/Objects-normal/arm64/Share\ Extension_dependency_info.dat -o /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Products/Debug-iphoneos/Share\ Extension.appex/Share\ Extension -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/iOSFacebook.build/Debug-iphoneos/iOSFacebook.build/Objects-normal/arm64/iOSFacebook.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/iOSSignIn.build/Debug-iphoneos/iOSSignIn.build/Objects-normal/arm64/iOSSignIn.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/ServerShared.build/Debug-iphoneos/ServerShared.build/Objects-normal/arm64/ServerShared.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/PersistentValue.build/Debug-iphoneos/PersistentValue.build/Objects-normal/arm64/PersistentValue.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/SwiftyUserDefaults.build/Debug-iphoneos/SwiftyUserDefaults.build/Objects-normal/arm64/SwiftyUserDefaults.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/KeychainAccess.build/Debug-iphoneos/KeychainAccess.build/Objects-normal/arm64/KeychainAccess.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/iOSShared.build/Debug-iphoneos/iOSShared.build/Objects-normal/arm64/iOSShared.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/swift-log.build/Debug-iphoneos/Logging.build/Objects-normal/arm64/Logging.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/SQLite.swift.build/Debug-iphoneos/SQLite.build/Objects-normal/arm64/SQLite.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/Facebook.build/Debug-iphoneos/FacebookLogin.build/Objects-normal/arm64/FacebookLogin.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/Facebook.build/Debug-iphoneos/FacebookCore.build/Objects-normal/arm64/FacebookCore.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/Facebook.build/Debug-iphoneos/FacebookShare.build/Objects-normal/arm64/FacebookShare.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/iOSDropbox.build/Debug-iphoneos/iOSDropbox.build/Objects-normal/arm64/iOSDropbox.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/SwiftyDropbox.build/Debug-iphoneos/SwiftyDropbox.build/Objects-normal/arm64/SwiftyDropbox.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/Alamofire.build/Debug-iphoneos/Alamofire.build/Objects-normal/arm64/Alamofire.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/ImageIOSwift.build/Debug-iphoneos/ImageIOUIKit.build/Objects-normal/arm64/ImageIOUIKit.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/ImageIOSwift.build/Debug-iphoneos/ImageIOSwift.build/Objects-normal/arm64/ImageIOSwift.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/SMLinkPreview.build/Debug-iphoneos/SMLinkPreview.build/Objects-normal/arm64/SMLinkPreview.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/swift-log-file.build/Debug-iphoneos/FileLogging.build/Objects-normal/arm64/FileLogging.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/iOSBasics.build/Debug-iphoneos/iOSBasics.build/Objects-normal/arm64/iOSBasics.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/Version.build/Debug-iphoneos/Version.build/Objects-normal/arm64/Version.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/ChangeResolvers.build/Debug-iphoneos/ChangeResolvers.build/Objects-normal/arm64/ChangeResolvers.swiftmodule -Xlinker -add_ast_path -Xlinker /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Intermediates.noindex/ServerAccount.build/Debug-iphoneos/ServerAccount.build/Objects-normal/arm64/ServerAccount.swiftmodule

ld: warning: linking against a dylib which is not safe for use in application extensions: /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Products/Debug-iphoneos/GSignIn.framework/GSignIn
Undefined symbols for architecture arm64:
  "iOSGoogle.GoogleHashing.init() -> iOSGoogle.GoogleHashing", referenced from:
      Share_Extension.ServerInterface.addHashingForCloudStorageSignIns(hashingManager: iOSShared.HashingManager) throws -> () in ServerInterface+CloudHashing.o
  "type metadata for iOSGoogle.GoogleHashing", referenced from:
      Share_Extension.ServerInterface.addHashingForCloudStorageSignIns(hashingManager: iOSShared.HashingManager) throws -> () in ServerInterface+CloudHashing.o
  "protocol witness table for iOSGoogle.GoogleHashing : iOSShared.CloudStorageHashing in iOSGoogle", referenced from:
      Share_Extension.ServerInterface.addHashingForCloudStorageSignIns(hashingManager: iOSShared.HashingManager) throws -> () in ServerInterface+CloudHashing.o
  "type metadata accessor for iOSGoogle.GoogleSyncServerSignIn", referenced from:
      Share_Extension.Services.getSignIns(configPlist: Share_Extension.ConfigPlist) -> [(iOSSignIn.GenericSignIn, iOSSignIn.SignInDescription)] in Services+SignIns.o
  "iOSGoogle.GoogleSyncServerSignIn.__allocating_init(serverClientId: Swift.String, appClientId: Swift.String, signInDelegate: iOSGoogle.GoogleSignInDelegate) -> iOSGoogle.GoogleSyncServerSignIn", referenced from:
      Share_Extension.Services.getSignIns(configPlist: Share_Extension.ConfigPlist) -> [(iOSSignIn.GenericSignIn, iOSSignIn.SignInDescription)] in Services+SignIns.o
  "direct field offset for iOSGoogle.GoogleSyncServerSignIn.userType : ServerShared.UserType", referenced from:
      Share_Extension.Services.getSignIns(configPlist: Share_Extension.ConfigPlist) -> [(iOSSignIn.GenericSignIn, iOSSignIn.SignInDescription)] in Services+SignIns.o
  "protocol witness table for iOSGoogle.GoogleSyncServerSignIn : iOSSignIn.GenericSignIn in iOSGoogle", referenced from:
      Share_Extension.Services.getSignIns(configPlist: Share_Extension.ConfigPlist) -> [(iOSSignIn.GenericSignIn, iOSSignIn.SignInDescription)] in Services+SignIns.o
  "type metadata accessor for iOSApple.AppleSignIn", referenced from:
      Share_Extension.Services.getSignIns(configPlist: Share_Extension.ConfigPlist) -> [(iOSSignIn.GenericSignIn, iOSSignIn.SignInDescription)] in Services+SignIns.o
  "iOSApple.AppleSignIn.__allocating_init() -> iOSApple.AppleSignIn", referenced from:
      Share_Extension.Services.getSignIns(configPlist: Share_Extension.ConfigPlist) -> [(iOSSignIn.GenericSignIn, iOSSignIn.SignInDescription)] in Services+SignIns.o
  "protocol descriptor for iOSGoogle.GoogleSignInDelegate", referenced from:
      l_got.$s9iOSGoogle20GoogleSignInDelegateMp in Services+SignIns.o
  "protocol witness table for iOSApple.AppleSignIn : iOSSignIn.GenericSignIn in iOSApple", referenced from:
      Share_Extension.Services.getSignIns(configPlist: Share_Extension.ConfigPlist) -> [(iOSSignIn.GenericSignIn, iOSSignIn.SignInDescription)] in Services+SignIns.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

請注意,這並不特定於為真實設備(例如arm64 )構建。 如果我為模擬器構建,我會收到相同類型的消息,但標題是Undefined symbols for architecture x86_64:

當我構建並仍然包含我的 Google 登錄 package(在我的主應用程序中引用),但在我的共享擴展中沒有引用這個 package 時,它構建得很干凈。 我將此作為更多證據證明此 package 不能用於共享擴展。

21 年 1 月 1 日:我現在解決了上述 linker 問題。 第一個只是我需要在https://github.com/SyncServerII/GSignIn.git Xcode 項目中更改的開關(請參閱針對 adylib 的擴展應用程序中的安全使用警告消息鏈接)。 第二個是我沒有將我的框架參考(在我的情況下是針對 iOSGoogle)添加到我的共享擴展中。 例如,參見https://stackoverflow.com/a/61848359/1675875

2/3/21:當我將我的應用程序上傳到 iTunes Connect 時,我遇到了一些其他問題,在共享擴展中使用 XCFrameworks:

  1. https://developer.apple.com/forums/thread/662247

  2. App Store Connect 操作錯誤 ERROR ITMS-90680:“無效目錄。捆綁 Payload/Neebla.app/PlugIns/GSignIn.framework 未包含在正確命名的目錄中。它應該位於“Frameworks”下。” See https://forums.swift.org/t/swift-package-binary-framework-issue/41922/2 and https://bugs.swift.org/browse/SR-13840

Google 登錄框架6.0 版以來,本機支持 Swift Package 管理器。

不再需要解決方法。 只需使用他們的 Github URL 將框架添加到 SPM:

git clone https://github.com/google/GoogleSignIn-iOS

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM