xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.48k stars 514 forks source link

Build Error - PHImageManager.h: Error GEA45E82A: expected identifier or '{' #6716

Closed rbanker closed 5 years ago

rbanker commented 5 years ago

Steps to Reproduce

  1. Compile any of our applications using Xcode 11 Beta 5 and VS2019 8.3 Preview

Expected Behavior

Applications complete compilation as they do under released versions of Xcode and VS2019

Actual Behavior

Receive the following errors: /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.0.sdk/System/Library/Frameworks/Photos.framework/Headers/PHImageManager.h(47,47): Error GEA45E82A: expected identifier or '{' (GEA45E82A) (VTrack.iOS.Framework)

/Users/jenk.svc/macos-build-beta-vm/workspace/iOS Betas/vTrackNG iOS Beta/VTrack/VTrack.iOS/MTOUCH: Error MT4109: Failed to compile the generated registrar code. Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new (MT4109) (VTrack.iOS.Framework)

Environment

=== Visual Studio Community 2019 for Mac (Preview) ===

Version 8.3 Preview (8.3 build 867)
Installation UUID: 639fa640-d54f-4746-94b2-88d36cab6e6d
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 5.16.0.5 (d16-3 / 26f04c54)

    Package version: 604000081

=== Mono Framework MDK ===

Runtime:
    Mono 6.4.0.81 (2019-06/f55e0a671c0) (64-bit)
    Package version: 604000081

=== NuGet ===

Version: 5.2.0.6067

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.1.12
SDK: /usr/local/share/dotnet/sdk/2.1.701/Sdks
SDK Version: 2.1.701
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.10
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.0 (14908.4)
Build 11M382q

=== Xamarin.Mac ===

Version: 5.16.0.5 (Visual Studio Community)
Hash: 26f04c54
Branch: d16-3
Build date: 2019-06-28 01:31:14-0400

=== Xamarin.iOS ===

Version: 12.16.0.5 (Visual Studio Community)
Hash: 26f04c54
Branch: d16-3
Build date: 2019-06-28 01:31:14-0400

=== Xamarin Designer ===

Version: 16.3.0.17
Hash: 73f0a446c
Branch: remotes/origin/d16-3-release-8.3-p1
Build date: 2019-07-22 17:05:22 UTC

=== Xamarin.Android ===

Version: 9.5.0.27 (Visual Studio Community)
Commit: xamarin-android/d16-3/16c4494
Android SDK: /Users/jenk.svc/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.2
SDK Build Tools Version: 28.0.3

Build Information: 
Mono: mono/mono/2019-02@e6f5369c2d2
Java.Interop: xamarin/java.interop/d16-3@5836f58
LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94
LibZip: nih-at/libzip/rel-1-5-1@b95cf3f
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.27.1@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/jenk.svc/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 1.4.0.8
Hash: 28342d0
Branch: remotes/origin/backport-pr-235-to-d16-3~2
Build date: 2019-07-18 16:54:46 UTC

=== Android Device Manager ===

Version: 1.2.0.75
Hash: bf6d603
Branch: remotes/origin/backport-pr-369-to-d16-3~1
Build date: 2019-07-18 16:55:08 UTC

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 803000867
Git revision: ab4af85ea561e474b545e0eada75c5bfe8a92297
Build date: 2019-07-24 14:13:44+00
Build branch: release-8.3-preview1
Xamarin extensions: 45290013e165bcd2db7acbb310e0c16bfe04f0c3

=== Operating System ===

Mac OS X 10.14.5
Darwin 18.6.0 Darwin Kernel Version 18.6.0
    Thu Apr 25 23:16:27 PDT 2019
    root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

Build Logs

Build Log

Example Project (If Possible)

chamons commented 5 years ago

This is a known issue with the current Xcode 11 betas: the ObjC headers for PhotoUI are broken.

This has been filed with Apple (but it never hurts to file duplicate feedback).

softsan commented 5 years ago

@chamons I just upgraded to xCode Version 11.0 (11A420a) - stable and it still happening. I've VS for mac 8.2.6 What could be the work around?

dfandler commented 5 years ago

i updated my visual studio for mac & installed xcode new command line tools (xcode 11.0 (11A420a)) and now im getting the same error

mzhukovs commented 5 years ago

Seeing same thing, using VS (for Windows) Enterprise latest version, just updated XCode to version 11A420a on my connected mac and am getting error on build saying expected identifier or '{' - same project was building fine yesterday without any changes.

@chamons are we able to downgrade the version of XCode to get it working again? Is this even possible on a Mac (forgive the ignorance I am not a Mac user)?

tipa commented 5 years ago

Hitting the same issue after updating XCode

RGPDev commented 5 years ago

Same exact issue after updating. Supposed to go to the app store tomorrow. Now I have to walk into a meeting and tell a boardroom we can't go to the store and marketing will have to be put on hold. What a nightmare choice I advocated for.

abrahamventura commented 5 years ago

I am not using Xamarin but I was having this issue also. I was able solve the issue by instead of importing the whole framework I individually import the framework files like this

import <Photos/PHAsset.h>

import <Photos/PHImageManager.h>

Aashreetha commented 5 years ago

Found the same error after updating XCode to version 11 on windows with following Environment:

Microsoft Visual Studio Enterprise 2017 Version 15.9.13

Microsoft .NET Framework Version 4.7.03056

Mono Debugging for Visual Studio 4.13.12-pre (9bc9548) Support for debugging Mono processes with Visual Studio.

Xamarin 4.12.3.83 (d15-9@23fa80172) Xamarin Designer 4.16.30 (e0af99a34) Xamarin Templates 1.1.128 (6f5ebb2) Xamarin.Android SDK 9.1.7.0 (HEAD/ba9da7a76) Xamarin.iOS and Xamarin.Mac SDK 12.4.0.64 (9c8d8e0)

Is there any work around for this ? After updating the Xcode couldn't compile the iOS project

this is error I see in the logs:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.0.sdk/System/Library/Frameworks/Photos.framework/Headers/PHImageManager.h:17:47: error: expected identifier or '{' typedef NS_ENUM(NSInteger, UIImageOrientation);

/Users/devteam/Library/Caches/Xamarin/mtbs/builds/StarRezHousing.iOS/48a6c01cf675903a515a245655ee573f/obj/iPhone/Debug/mtouch-cache/registrar.h:43:9: fatal error: 'WatchKit/WatchKit.h' file not found

import <WatchKit/WatchKit.h>

rolfbjarne commented 5 years ago

Our current stable version of Xamarin.iOS is not compatible with Xcode 11.

We'll release a version of Xamarin.iOS that is compatible with Xcode 11 later today. A more immediate solution is to install our preview version of Xamarin.iOS with support for Xcode 11.

jtorvald commented 5 years ago

@rolfbjarne I tried installing the preview version but it still gives the same error. Just thought I let you know: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.0.sdk/System/Library/Frameworks/Photos.framework/Headers/PHImageManager.h(47,47): Error GEA45E82A: expected identifier or '{' (GEA45E82A)

Visual Studio Community 2019 for Mac (Preview) Version 8.3 Preview (8.3 build 1760) Installation UUID: 8a28987a-1e72-4b4e-ae4d-21612ffbdc71 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)

Package version: 604000194

Mono Framework MDK Runtime: Mono 6.4.0.194 (2019-06/7da9a041b3b) (64-bit) Package version: 604000194

NuGet Version: 5.3.0.6192

.NET Core SDK SDK: /usr/local/share/dotnet/sdk/3.0.100-rc1-014190/Sdks SDK Versions: 3.0.100-rc1-014190 2.2.402 2.1.701 2.1.700 2.1.505 2.1.504 2.1.302 2.1.4 2.0.0 1.0.4 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Sdks

.NET Core Runtime Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 3.0.0-rc1-19456-20 2.2.7 2.1.12 2.1.11 2.1.9 2.1.8 2.1.2 2.0.5 2.0.0 1.1.2 1.0.5

Xamarin.Profiler Version: 1.6.12.26 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater Version: 11

Apple Developer Tools Xcode 11.0 (14936) Build 11A420a

Xamarin.Mac Version: 5.16.1.24 (Visual Studio Community) Hash: 08809f5b Branch: d16-3 Build date: 2019-09-06 08:42:41-0400

Xamarin.iOS Version: 12.16.1.24 (Visual Studio Community) Hash: 08809f5b Branch: d16-3 Build date: 2019-09-06 08:42:42-0400

Xamarin Designer Version: 16.3.0.180 Hash: 54a02e2c9 Branch: remotes/origin/d16-3 Build date: 2019-09-12 15:35:22 UTC

Xamarin.Android Version: 10.0.0.43 (Visual Studio Community) Commit: xamarin-android/d16-3/8af1ca8 Android SDK: /Users/developer/Library/Developer/Xamarin/android-sdk-mac_x86 Supported Android versions: 7.1 (API level 25) 8.0 (API level 26) 8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 29.0.1 SDK Build Tools Version: 27.0.2

Build Information: Mono: mono/mono/2019-06@7af64d1ebe9 Java.Interop: xamarin/java.interop/d16-3@5836f58 LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94 LibZip: nih-at/libzip/rel-1-5-1@b95cf3f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333

Microsoft Mobile OpenJDK Java SDK: /Users/developer/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager Version: 1.4.0.65 Hash: c33b107 Branch: remotes/origin/d16-3 Build date: 2019-09-13 13:06:32 UTC

Android Device Manager Version: 1.2.0.113 Hash: 2f86c05 Branch: remotes/origin/d16-3~1 Build date: 2019-09-13 13:06:52 UTC

Xamarin Inspector Version: 1.4.3 Hash: db27525 Branch: 1.4-release Build date: Mon, 09 Jul 2018 21:20:18 GMT Client compatibility: 1

Build Information Release ID: 803001760 Git revision: 02f4f2e58b5aebe14e078aeff0fbad1abc9c7ae7 Build date: 2019-09-17 11:52:55+00 Build branch: release-8.3 Xamarin extensions: 8f75f12867e7d20d8ca78ea5e136a6ed7dde5dd2

Operating System Mac OS X 10.14.6 Darwin 18.7.0 Darwin Kernel Version 18.7.0 Tue Aug 20 16:57:14 PDT 2019 root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

Enabled user installed extensions DeepClean 1.2.5 LiveXAML 1.3.51 FileNesting 0.1.2 XAML Styler 1.1.5

diegostamigni commented 5 years ago

The preview from the Xcode11 Preview channel.... @jtorvald

https://devblogs.microsoft.com/xamarin/ios-13-xcode-11/

TLDR:

To get started:
* Download and install the Xcode 11 beta from the Apple Developer Portal.
* In Visual Studio for Mac, select Visual Studio > Check for Updates, select the Xcode 11 Previews channel, and install the available updates.
* In Visual Studio for Mac, select Visual Studio > Preferences > Projects > SDK Locations > Apple and select Xcode-beta.app.
* (Optional – Visual Studio 2019 only) Download and install the Xcode 11 preview support VSIX.

You obv don't neet the Xcode beta part of the instructions anymore.

jtorvald commented 5 years ago

The preview from the Xcode11 Preview channel.... @jtorvald

@diegostamigni Yeah I tried that but there is no XCode available at the Apple Developer Portal under 'beta'. Only under release: 11A420a (20 sept) which I've installed.

diegostamigni commented 5 years ago

@jtorvald That's why I said:

You obv don't neet the Xcode beta part of the instructions anymore.

Just switch to Xcode 11 Preview channel on VS for Mac on the update window and you are all set for now, as @rolfbjarne already mentioned.

jtorvald commented 5 years ago

@diegostamigni with that you mean to use the Preview channel in Visual Studio Update right? That is what I did after reading this thread and that's why I comment that it is still failing... See my device info above. Or am I missing something here? image

diegostamigni commented 5 years ago

@diegostamigni with that you mean to use the Preview channel in Visual Studio Update right? That is what I did after reading this thread and that's why I comment that it is still failing... See my device info above. Or am I missing something here? image

@jtorvald from the Preview dropdown menu in the top left corner you should see Xcode 11 Preview...

jtorvald commented 5 years ago

@jtorvald from the Preview dropdown menu in the top left corner you should see Xcode 11 Preview...

@diegostamigni Where exactly do you mean? Can you make a screenshot? Here in Visual Studio Update behind "Update Channel"? I only have two options there: Stable and Preview

diegostamigni commented 5 years ago
Screenshot 2019-09-23 at 9 43 56 am

This is what I have there @jtorvald

jtorvald commented 5 years ago

@diegostamigni that is why I'm so confused. I don't have it :-) Any idea on how to get the iOS Preview channel? (including @rolfbjarne here) Seems like there are more people not having that one in the dropdown.

UKDeveloper99 commented 5 years ago

When is the Xcode fix expected to happen?

lassana commented 5 years ago

VS 8.2..6.73: https://download.visualstudio.microsoft.com/download/pr/efc93fa3-2343-47e6-b3df-94fd5765e3c0/65a2af5d44914d492d1abd561bff47d8/visualstudioformac-8.2.6.73.dmg Xamarin.iOS 13.0.0.19: https://download.visualstudio.microsoft.com/download/pr/2efa7250-657f-4200-b057-bc0b24ef6fe2/81f38419ac0259235b8d0be65358168e/xamarin.ios-13.0.0.19.pkg

rbanker commented 5 years ago

I'm the dude that originally reported the issue... To get around it at the time, I patched the SDK. Admittedly, it didn't leave me with a good feeling, but at least I had a compiling and running build...

Get yourself down into the SDK:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Photos.framework/Headers

PHImageManager.h Line 17 is the offender:

typedef NS_ENUM(NSInteger, UIImageOrientation);

I just changed it to:

typedef NS_ENUM(NSInteger, UIImageOrientation){};

Yeah, so it's an empty enum, but not much other choice when we don't know what the values are supposed to be.

joellegh commented 5 years ago

Hello @rbanker can you post where you fixed the class and compiled it?

UKDeveloper99 commented 5 years ago

@joellegh he did post where the class was. You don't need to compile anything. Just need file change permissions.

rbanker commented 5 years ago

@joellegh @UKDeveloper99 is right -- you don't need to recompile anything but your application and PHImageManager.h is the header file for the PHImageManager class. I didn't need to change any permissions, but that just might be my setup.

joellegh commented 5 years ago

Thank you @rbanker and @UKDeveloper99 It worked!

rohit-hike commented 5 years ago

@rbanker - hi, I am not able to edit file, it says You don’t have permission to write to the folder that the file “PHImageManager.h” is in. How to move forward?

jtorvald commented 5 years ago

@rohit-hike sudo vi /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Photos.framework/HeadersPHImageManager.h

rbanker commented 5 years ago

You might try editing as super user at the command-line with sudo vi /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Photos.framework/Headers/PHImageManager.h

jtorvald commented 5 years ago

@rbanker thanks. That solution was 100x faster than finding the XCode preview channel ;-)

rbanker commented 5 years ago

@jtorvald I’m a lazy, impatient man 😂

chrilith commented 5 years ago

Switching to "Xcode 11 previews" channel did the trick for me. Thanks!

rohitvipin commented 5 years ago

Getting "Error installing application" error when updating with "Xcode 11 previews" Got around the issue by manually installing XCode Command line https://download.developer.apple.com/Developer_Tools/Command_Line_Tools_for_Xcode_11/Command_Line_Tools_for_Xcode_11.dmg

rbanker commented 5 years ago

By all means, if there's an official route from Microsoft, go that route. My approach (https://github.com/xamarin/xamarin-macios/issues/6716#issuecomment-534034433) was a hack to get something to the QA folks. @rolfbjarne mentions on another thread (https://github.com/xamarin/xamarin-macios/issues/6471#issuecomment-533968244) that they're releasing a Xcode 11-compliant Xamarin.iOS later today. Go that route if you can.

JKennedy24 commented 5 years ago

Reported on 5th August, How did this slip through the net!

rohit-hike commented 5 years ago

thanks @rbanker

bo3po commented 5 years ago

This is bad. I also have to release apps now. I can not build it?! I have tried @rbanker genius trick which seemed to work. But there are other errors like the original. What to do? I have tried all channels. None of then are working for me. I guess I have to be patient....?

irohitkelkar commented 5 years ago

Downgrading to xcode 10.3 through app store fixed problem for now.

softsan commented 5 years ago

Downgrading xCode10.3 solved the problem as of now.

bo3po commented 5 years ago

Hi. Ok. Downgrading is the the right thing to do for now. So by downgrade you mean uninstall it and log into app developer and get the version 10.3 ? right...?

chamons commented 5 years ago

You can have multiple Xcode's side by side, it just matters what one is selected in Visual Studio and xcode-select.

So you could rename Xcode.app to Xcode11.app and install 10.3 in Xcode.app for example.

bo3po commented 5 years ago

The fix came out very fast I would say. Updating the VS and switching back to XCode11 also reverting the fix from @rbanker made it work. The XCode10.3 xcode-select did also work. Great work ! 👍

KShaibani commented 5 years ago

last night I was having the same issue but after updating visual studio to the latest version (8.3 visual studio for mac). finally, I can build. thanks

Aashreetha commented 5 years ago

Updating VS 2019 (windows) does fix the issue with Xcode. Thanks

An1shNa1r commented 5 years ago

First Update the VS 2019 (windows) installer if you are updating with the old one that you have in your local then Update the VS by that only the issue with Xcode will be fixed. if the updater is not updated you won't be able to see this update.

pmarpaung commented 5 years ago

Ok this pretty much killed me. But best way on Xcode is to just delete the whole line.

typedef NS_ENUM(NSInteger, UIImageOrientation);

Use terminal to edit:

sudo nano /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Photos.framework/Headers/PHImageManager.h

elorusso commented 5 years ago

UIImageOrientation is originally defined in UIKit/UIImage.h. Not sure how it ended up in PHImageManager.h....

Best way to fix this: 1) import UIKit/UIImage.h 2) comment out this line: typedef NS_ENUM(NSInteger, UIImageOrientation);

The edit needs to be done in the terminal with: sudo nano /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Photos.framework/Headers/PHImageManager.h

mateuswolkmer commented 5 years ago

I had the same problem and the solution proposed by @rbanker worked. But I'm also receiving another error when trying to build my Xamarin app in Visual Studio 2019:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(804,3): error GB12A9FDE: "Photos requires C++11 or later".

Could these problems be related? Is anyone receiving the same problem?

HappyTreesDev commented 5 years ago

I am on Visual Studio 2017 and it seems that the issue is not fixed here. VS2017 still points to an older version of mono and xamarin annoyingly. Does this mean VS2017 is no longer supported?

chamons commented 5 years ago

Yes - if you want to use the newest Xcode versions you need to upgrade to VS 2019.

Sorry for any confusion.

gvuksa commented 5 years ago

@mateuswolkmer Did you manage to solve the issue "Photos requires C++11 or later"?