将 Google Sign In for iOS 与 Swift Package Manager 结合使用

如何解决将 Google Sign In for iOS 与 Swift Package Manager 结合使用

有点像 Build iOS App having Google Sign with support for Mac,我已经嵌入了适用于 iOS 的 Google Sign in 框架并将其捆绑到一个 Xcode 项目中,但我只针对 iOS。我的需求是将 Swift Package Manager 与 Google Sign In for iOS 结合使用。

我创建这个问题是为了添加我当前的解决方案,看看其他人是否有解决方案。并尝试鼓励 Google 通过适用于 iOS 的 Google Sign In 支持 Swift Package Manager :)。

解决方法

为此,我创建了一个 XCFramework 版本的 Google Sign。见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 登录按钮。没什么大不了的,但为了完整起见,我想访问 Google 登录框架提供的 Google 按钮。

  2. 此软件包取决于特定版本的 Google Sign In。更新它需要进入 https://github.com/SyncServerII/GSignIn.git 并根据 Google 登录框架的更新手动更新它。

我尚未将使用此包的应用部署到应用商店,因此目前尚不清楚。

-- 更新 --

12/28/20(已解决 - 请参阅下面的 1/1/21 更新):我还应该注意,我在我的共享扩展中收到了有关此库的警告:

ld: 警告:链接到不安全的 dylib 应用扩展: /Users/chris/Library/Developer/Xcode/DerivedData/Neebla-aybzuiaoyytaypbvqtqeummvcssh/Build/Products/Debug-iphoneos/GSignIn.framework/GSignIn

当我在我的目标应用程序中使用这个框架构建时,它有一个共享扩展。 我还没有尝试将这个应用上传到应用商店,所以不知道会发生什么。

12/29/20(已解决 - 请参阅下面的 1/1/21 更新):我之前在构建时将我的 Google 登录包从本地目录拖到我的应用程序中。我刚刚尝试从没有拖入,而是仅仅依靠它作为我的应用程序中的 swift 包,使用其 Github 存储库引用。这会用各种模糊的链接器错误来破坏构建,如下所示:

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",iOSSignIn.SignInDescription)] in Services+SignIns.o
  "direct field offset for iOSGoogle.GoogleSyncServerSignIn.userType : ServerShared.UserType",iOSSignIn.SignInDescription)] in Services+SignIns.o
  "protocol witness table for iOSGoogle.GoogleSyncServerSignIn : iOSSignIn.GenericSignIn in iOSGoogle",iOSSignIn.SignInDescription)] in Services+SignIns.o
  "type metadata accessor for iOSApple.AppleSignIn",iOSSignIn.SignInDescription)] in Services+SignIns.o
  "iOSApple.AppleSignIn.__allocating_init() -> iOSApple.AppleSignIn",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",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 Sign In 包(在我的主应用程序中有引用),但在我的共享扩展中没有引用此包时,它构建得很干净。我将此作为该包不能用于共享扩展的更多证据。

1/1/21: 我现在已经解决了上述两个链接器问题。第一个只是我需要在 https://github.com/SyncServerII/GSignIn.git Xcode 项目中更改的开关(请参阅 warning message linking against a dylib which is not safe for use in application extensions)。 第二个是我没有将我的框架参考(在我的情况下为 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 操作错误 错误 ITMS-90680:“无效目录。包 Payload/Neebla.app/PlugIns/GSignIn.framework 未包含在正确命名的目录中。它应该在“Frameworks”下。请参阅 https://forums.swift.org/t/swift-package-binary-framework-issue/41922/2https://bugs.swift.org/browse/SR-13840

,

Google Sign-In Framework 的 6.0 版开始,Swift 包管理器就得到了本地支持。

不再需要解决方法。只需使用他们的 Github URL 将框架添加到 SPM:

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-