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

Created on 27 Mar 2018  路  27Comments  路  Source: godotengine/godot

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.

archived documentation enhancement ios porting

Most helpful comment

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.

All 27 comments

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).

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?

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.

@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?

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.

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

@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

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)

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

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

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.

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.

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

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.

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?

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

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

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

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

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

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

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

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.

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.

I'll add x86_64 for beta 5/rc1

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.

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

Was this page helpful?
0 / 5 - 0 ratings