Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build for iOS on XCode 9.2 - entry point (_main) undefined. for architecture i386 #17802

Closed
jahd2602 opened this issue Mar 27, 2018 · 27 comments

Comments

@jahd2602
Copy link
Contributor

jahd2602 commented Mar 27, 2018

I am having the same problem as the user pip in QA.

Godot version:
3.0.2 stable

OS/device including version:
MacBook Air (13-inch, Early 2014) (1,4 GHz Intel Core i5)
MacOS High Sierra 10.13.3

Issue description:
I should be able to build and run the generated XCode project. It does not build successfully.

Steps to reproduce:

I have installed the export templates and tried to export an empty Godot project.

  • Project > Export > iOS(Runnable)
  • Fill the required icons and launch screens.
  • Enter App Store Team ID (This should be obsolete since Xcode automatically handles the signing now. The team ID can no longer be found on the apple dev website)
  • Export project *.ipa (even tough Godot only exports the Xcode files and not an ipa file)
  • Opened the generated .xcodeproj in XCode 9.2
  • Changed to my personal team in iOSExport target > General > Signing > Team

When I hit build in Xcode I get these same error:

ld: warning: ignoring file /Users/alejandro/Godot3Projects/iOSExport.a, missing required architecture i386 in file /Users/alejandro/Godot3Projects/iOSExport.a (2 slices)
ld: entry point (_main) undefined. for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: warning: ignoring file /Users/alejandro/Godot3Projects/iOSExport.a, missing required architecture x86_64 in file /Users/alejandro/Godot3Projects/iOSExport.a (2 slices)
ld: entry point (_main) undefined. for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Note that one says architecture i386 and the other architecture x86_64.

Minimal reproduction project:
Empty new project.

@ghost ghost added this to the 3.1 milestone Mar 28, 2018
@endragor
Copy link
Contributor

Team ID is still required - you must specify a team for each of your Xcode projects and Xcode won't do any signing without it. Command line tools, which Godot makes use of, also require team ID to be present in project settings. Team ID can be found on "Membership" page at https://developer.apple.com/account/

Godot does build .ipa as long as export is performed correctly. It seems something was broken since 3.0.0, because export worked fine there (although I never tried building with the official templates).

@jahd2602
Copy link
Contributor Author

Thanks for the answer @endragor
I am trying to do some performance test for iOS, and I don't have a paid Apple account, and therefore no Team ID (or even Membership page).
Will I be able to do it without the paid membership?

@Shin-NiL
Copy link

You don't need a paid Apple account, I don't have one and I'm able to build and run iOS apps. You'll need to pay to publish on Apple Store though.

@jahd2602
Copy link
Contributor Author

@Shin-NiL and how did you get your Team ID? my developer page looks like this:
Developer page screenshot
So there is no Team ID I can use.
Can I find the Team ID in XCode or in keychain?

@hyponymous
Copy link

I'm getting the same error as @jahd2602, and I've entered my team id. I'm also not seeing a .ipa file generated on export.

@Shin-NiL
Copy link

@jahd2602 it's weird, as I never paid anything... Anyways, maybe this article can help you.

@jahd2602
Copy link
Contributor Author

@Shin-NiL I already have an account. The difference with that article is that https://developer.apple.com/membercenter/index.action redirects now to https://developer.apple.com/account and there, there is no Team ID to copy to Godot.
Godot export settings screenshot

@jahd2602
Copy link
Contributor Author

I found the team ID by following this post instructions:

If I select my personal team in xcode and then open MyProject.xcodeproj > project.pbxproj, I can find said ID by looking for DEVELOPMENT_TEAM.

I exported with that Team ID, and XCode didn't complain about it. However:

  1. The .ipa was not generated.
  2. When trying to build, the same error appeared:
ld: warning: ignoring file /Users/alejandro/Godot3Projects/iOSExport2.a, missing required architecture i386 in file /Users/alejandro/Godot3Projects/iOSExport2.a (2 slices)
ld: entry point (_main) undefined. for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@Shin-NiL
Copy link

Are you trying to run on simulator (i386)? If so, the template won't work.

@hyponymous
Copy link

Ah, it wasn't clear that the project wouldn't work for the simulator. I got it working on a device.

@jahd2602
Copy link
Contributor Author

I could bypass the error by trying to build to a device. But then, I got this errors:

Code Signing Error: Cannot create a iOS App Development provisioning profile for "org.godotengine.iosgame". Your development team, "Jairo Honorio", does not support the Push Notifications capability.
Code Signing Error: No profiles for 'org.godotengine.iosgame' were found:  Xcode couldn't find any iOS App Development provisioning profiles matching 'org.godotengine.iosgame'.
Code Signing Error: Code signing is required for product type 'Application' in SDK 'iOS 11.2'

Thanks for your help.

@jahd2602
Copy link
Contributor Author

jahd2602 commented Mar 31, 2018

I solved those problems by:

  1. Changing the General > Identity > Bundle Identifier
  2. Turning off General > Signing > Automatically Manage Signing, and then turn it on again
  3. Changing Team to None, and then choosing my Personal Team
  4. Going to appName/appName.entitlements and removing APS Environment

After that, I could get it to run on a physical device.

@reduz
Copy link
Member

reduz commented Sep 7, 2018

Any feedback on how can this be improved? or is it just usability enhancement?

@alasdairbarton
Copy link

alasdairbarton commented Oct 29, 2018

The reason you must turn automatically manage signing off and on is because by default it tries to use the Push Notifications and Game Center capabilities which non-paying devs don't have permission to use.
The easiest way to solve this is to:

  1. Make the General > Identity > Bundle Identifier Something unique. It doesn't matter what, it just has to be unique.
  2. Turn off General > Signing > Automatically Manage Signing
  3. Go to the Capabilities tab, and turn off the Game Center and Push Notifications Capabilities
  4. Turn back on General > Signing > Automatically Manage Signing , and Select your team.

In Response to the original question:
A quick web search shows that you generally get linker errors such as clang: error: linker command failed with exit code 1 (use -v to see invocation) due to missing libraries. For me it was the StoreKit.framework. This is solved by going to Build Phases > Link Binary With Libraries And pressing the plus button to add a library. In my case I just searched for StoreKit and added the library.

@gvdb
Copy link

gvdb commented Dec 2, 2018

Edit: Sorry, never mind. I found the settings under the Project navigator and edited the project settings.

The reason you must turn automatically manage signing off and on is because by default it tries to use the Push Notifications and Game Center capabilities which non-paying devs don't have permission to use.
The easiest way to solve this is to:

1. Make the _General > Identity > Bundle Identifier_ Something unique. It doesn't matter what, it just has to be **unique**.

2. Turn **off** _General > Signing > Automatically Manage Signing_

3. Go to the _Capabilities_ tab, and turn off the `Game Center` and `Push Notifications` Capabilities

4. Turn back **on** _General > Signing > Automatically Manage Signing_ , and Select your team.

Where are these options? Are they meant to be under Preferences for Xcode? The General tab doesn't have Identity or Signing options as far as I can see. Are they somewhere else?

@akien-mga
Copy link
Member

What's the status on this issue? The export dialog now does some validation of the identifier at least IINM.

@gvdb
Copy link

gvdb commented Jan 22, 2019

What's the status on this issue? The export dialog now does some validation of the identifier at least IINM.

For me the steps from @thebartyparty resolved the issue.

Perhaps they would be useful on the Exporting for iOS page? https://docs.godotengine.org/en/3.0/getting_started/workflow/export/exporting_for_ios.html

@akien-mga
Copy link
Member

Thanks. Moving the discussion to godotengine/godot-docs#2152 to focus on the documentation needs. Feedback there or PRs welcome :)

@wombatwingdings
Copy link

Is this really fixed? It seems that export to emulator (rather than physical device) is still broken with the error reported in the title.

@akien-mga
Copy link
Member

Did you try with 3.1 beta 2? It ships both x86 and x86_64 binaries and should therefore run fine on the simulator.

@wombatwingdings
Copy link

I think so. I am doing build from master branch pulled 12 Jan. Maybe I have built the export templates wrong (can't find 3.1 beta templates online. https://hugo.pro/projects/godot-builds/ missing xcode template stuff). I can't find any info online on how to build them for iOS. Manual doesn't mention the extra files needed for the xcode project template. I have got my own script to build them, but maybe it's wrong. I do something like this:

DoBuilds()
{
	cd GODOT_BLD_DIR
	scons p=osx

	scons p=iphone tools=no bits=32 target=release arch=x86
	scons p=iphone tools=no bits=64 target=release arch=x86_64

	scons p=iphone tools=no bits=32 target=debug arch=x86
	scons p=iphone tools=no bits=64 target=debug arch=x86_64

	scons p=iphone tools=no bits=32 target=release arch=arm7
	scons p=iphone tools=no bits=64 target=release arch=arm64

	scons p=iphone tools=no bits=32 target=debug arch=arm7
	scons p=iphone tools=no bits=64 target=debug arch=arm64
}

PackageUp()
{
	cd GODOT_BLD_DIR/bin

	lipo -create libgodot.iphone.opt.arm.a libgodot.iphone.opt.arm64.a -output libgodot.iphone.release.fat.a
	lipo -create libgodot.iphone.debug.arm.a libgodot.iphone.debug.arm64.a -output libgodot.iphone.debug.fat.a
}

PackageUpFinal()
{
	PACK_TMP=/tmp/tmppack
	PACK_TMP_2=/tmp/templates

	mkdir $PACK_TMP
	cd $PACK_TMP

	echo "Copying..."
	cp $GODOT_BLD_DIR/bin/libgodot.iphone.release.fat.a .
	cp $GODOT_BLD_DIR/bin/libgodot.iphone.debug.fat.a .

	cp -R $GODOT_BLD_DIR/misc/dist/ios_xcode/* .

	cp $GODOT_BLD_DIR/bin/libgodot.iphone.debug.x86.a .
	cp $GODOT_BLD_DIR/bin/libgodot.iphone.opt.x86.a .
	cp $GODOT_BLD_DIR/bin/libgodot.iphone.debug.x86_64.a .
	cp $GODOT_BLD_DIR/bin/libgodot.iphone.opt.x86_64.a .

	echo "Zipping..."
	zip -9 -r iphone.zip .

	mkdir $PACK_TMP_2
	cd $PACK_TMP_2/..

	echo "3.1.beta" > $PACK_TMP_2/version.txt
	cp $PACK_TMP/iphone.zip $PACK_TMP_2
	rm $GODOT_BLD_DIR/bin/custom_bld_export_templates.tpz 2>/dev/null
	zip -9 -r $GODOT_BLD_DIR/bin/custom_bld_export_templates.tpz templates

	rm -rf $PACK_TMP
	rm -rf $PACK_TMP_2
}

GODOT_BLD_DIR=~/godot

DoBuilds
PackageUp
PackageUpFinal

@akien-mga
Copy link
Member

You could use the 3.1 beta 2 templates with the 3.1 beta 2 editor binary: https://godotengine.org/article/dev-snapshot-godot-3-1-beta-2

scons p=iphone tools=no bits=32 target=release arch=arm7

It's actually armv7. Doesn't matter in the end as if the arch argument is invalid, it builds armv7.

lipo -create libgodot.iphone.opt.arm.a libgodot.iphone.opt.arm64.a -output libgodot.iphone.release.fat.a
lipo -create libgodot.iphone.debug.arm.a libgodot.iphone.debug.arm64.a -output libgodot.iphone.debug.fat.a

You need to collate the x86 and x86_64 libraries here too.

See the build scripts for 3.0.6 (missing x86_64, this has been added later on):
https://notabug.org/hp/godot-scripts/src/master/build-godot-macosx.sh#L45-L53
https://notabug.org/hp/godot-scripts/src/master/build-godot.sh#L310-L317

@alcroito
Copy link
Contributor

I just checked both the linked 3.1 beta2 template snapshot, and 3.1 beta4.
Both of them are missing the x86_64 architecture.

$ file libgodot.iphone.debug.fat.a
libgodot.iphone.debug.fat.a: Mach-O universal binary with 3 architectures: [arm_v7:current ar archive] [arm64]
libgodot.iphone.debug.fat.a (for architecture armv7):	current ar archive
libgodot.iphone.debug.fat.a (for architecture i386):	current ar archive
libgodot.iphone.debug.fat.a (for architecture arm64):	current ar archive

So I guess either the issue should be reopened, or a new one created.

@wombatwingdings
Copy link

Yes, I think you're right. I had same result when I tried official beta template as well as custom build. I never got emulator to work, but real device is ok.

@hpvb
Copy link
Member

hpvb commented Feb 13, 2019

I'll add x86_64 for beta 5/rc1

@raavan199
Copy link

i got a same Error when i try to build my Objective C Project in Xcode 10, and i solved it my change my development target to 7.0. I think Xcode did not support older iOS version so they get this error.
correct me if i say something wrong.
Thanks.

@wombatwingdings
Copy link

@raavan199 I have my Deployment Target to 9.0. It doesn't go below 8.0. I still get the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests