yasirkula / UnityNativeGallery

A native Unity plugin to interact with Gallery/Photos on Android & iOS (save and/or load images/videos)
MIT License
1.39k stars 199 forks source link

iOS build fails in Unity 2022.3.8 LTS: undefined method `[]' for nil:NilClass (NoMethodError) #252

Open dmichalke2 opened 2 years ago

dmichalke2 commented 2 years ago

Description of the bug

when adding the nativegalery repo to our manifest.json to load the package from github to our project to use it in code, the build for iOS fails in Xcode with a ruby error. this only seems to happen with the latest Unity 2022.3X lts version (we use Unity 2022.3.8).

Reproduction steps

add nativegalery package to a unity 2022.3.8 project, use it, i.e. NativeGallery.LoadImageAtPath() and build for iOS.

Platform specs

Please provide the following info if this is a Unity 3D repository.

Screenshot_1

Additional info

xcode error log when building

378: [2022-08-22T10:20:00.626Z] - 6.3.4.2.4.2 - INFO: + Building with Xcode 13.2.1 379: /BUILD_PATH/.rvm/gems/ruby-2.4.2/gems/fastlane-2.182.0/fastlane/lib/fastlane/actions/update_project_provisioning.rb:73:inblock (2 levels) in run': [!] undefined method []' for nil:NilClass (NoMethodError) 380: [2022-08-22T10:20:04.720Z] - 6.3.4.2.4.2 - ERROR: xcode build failed 381: RuntimeError (Build Failure): 382: Finished: FAILURE

yasirkula commented 2 years ago

Since the error message doesn't mention NativeGallery, can you try removing NativeGallery from your project and verify that it's the cause of the issue?

dmichalke2 commented 2 years ago

yes, sorry I thought I expressed myself correctly. so as this screenshot in my first post shows, the package was added in the manifest.json.

when we remove it from the project (remove the line from the manifest.json and comment code that uses nativegallery), the iOS build works. so it is definitely the cause of the issue.

here I found a more detailed xcode log also mentioning nativegallery.

`Undefined symbols for architecture arm64: "_OBJCCLASS$_PHPickerViewController", referenced from: objc-class-ref in NativeGallery.o "_OBJCCLASS$_PHPickerFilter", referenced from: objc-class-ref in NativeGallery.o "_OBJCCLASS$_PHPickerConfiguration", referenced from: objc-class-ref in NativeGallery.o

ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) /Users/developer/builds/LEziGM3r/0/spiele-palast/pinochle/Build/IOS/de.spielepalast.pinochlepalace-appstore692/Unity-iPhone.xcodeproj: warning: MobileCoreServices has been renamed. Use CoreServices instead. (in target 'UnityFramework' from project 'Unity-iPhone') /Users/developer/builds/LEziGM3r/0/spiele-palast/pinochle/Build/IOS/de.spielepalast.pinochlepalace-appstore692/Unity-iPhone.xcodeproj: warning: AssetsLibrary is deprecated. Consider migrating to Photos instead. (in target 'UnityFramework' from project 'Unity-iPhone')

ARCHIVE FAILED

The following build commands failed: Ld /Users/developer/Library/Developer/Xcode/DerivedData/Unity-iPhone-ebrzqbbmqfdxmhfawpwagqfzukbr/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/UnityFramework.framework/UnityFramework normal (in target 'UnityFramework' from project 'Unity-iPhone') (1 failure)

$ sed -i '' -e "s/PROV_UUID/${provuuid}/g" -e "s/TEAM_ID/${TEAM_ID}/g" exportOptions.plist $ sed -i '' "s/SIGN_CERT/${SIGNING_IDENTITY}/g" exportOptions.plist $ sed -i '' "s/EXPORT_METHOD/${EXPORT_METHOD}/g" exportOptions.plist $ xcodebuild -exportArchive -archivePath Pinochle-Palace.xcarchive -exportPath Pinochle-Palace.ipa -exportOptionsPlist exportOptions.plist | tee export_archive.log

2022-08-22 14:45:26.609 xcodebuild[63742:7589902] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore 2022-08-22 14:45:26.609 xcodebuild[63742:7589902] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore error: archive not found at path '/Users/developer/builds/LEziGM3r/0/spiele-palast/pinochle/Build/IOS/de.spielepalast.pinochlepalace-appstore692/Pinochle-Palace.xcarchive' EXPORT FAILED Cleaning up project directory and file based variables 00:00 ERROR: Job failed: exit status 1`

yasirkula commented 2 years ago

Something must be overwriting my automated setup. Can you try manual setup: https://github.com/yasirkula/UnityNativeGallery/wiki/Manual-Setup-for-iOS

dmichalke2 commented 2 years ago

I can try doing this for a local build but it doesnt solve the problem long term - we have a CI system that auto builds our app and needs the automated post build setup. also I have to mention that the problem is only in unity 2022.3.6+ in the previous version we used (2022.1.28f1) there was no issue, it is since the update to the latest unity LTS version. so it has to be a problem in the latest unity LTS version and the plugin.

yasirkula commented 2 years ago

Your local test results would be helpful, yeah. You can check if the necessary Other Linker Flags are present in Xcode because if not, then they're being overwritten somehow. I'd suspect that another plugin is now overwriting Other Linker Flags by mistake in a recent update since I haven't had a Unity-update-related native issue in a long while. But perhaps they've made significant changes to Xcode structure which've caused this problem. I can't verify this for the time being because I don't have access to a Mac workstation, unfortunately.

ChrisMasterton commented 1 year ago

@dmichalke2 I've had similar problems with flags and frameworks being overwritten. I've reverted to using a large hammer, also known as a custom Fastlane action that just sets whatever needs setting. It is not an elegant solution, but it gets the job done. Your issue is either the missing frameworks Photos and PhotosUI and/or the search path for those frameworks. I had the same problem - check out the Fastlane action fs_xcode