iOS Question Compile Error: init methods must return a type related to the receiver type

Jack Cole

Well-Known Member
Licensed User
I receive this error when attempting to compile a project. B4i takes me to the end of a sub. If I comment out all the code in the sub it does the same thing. If I comment out the calls to that sub, it goes to the end of the next sub in the project. If I comment out all the subs but the default subs, it compiles and installs. Then if I uncomment everything after a successful install, it compiles and installs correctly.

B4X:
Parsing code.                           0.06
Compiling code.                         0.11
Compiling layouts code.                 0.05
Compiling debugger engine code.         3.03
Building Xcode project                  0.05
Sending data to remote compiler.        Error
B4i line: 769
End Sub
init methods must return a type related to the receiver type

Out: Build settings from command line:
    ARCHS = armv7
    CODE_SIGN_IDENTITY = iPhone
    CONFIGURATION_BUILD_DIR = /Users/administrator/Documents/UploadedProjects/xxxxx/Payload
    OTHER_CODE_SIGN_FLAGS = --keychain xxxxxxx
    PRODUCT_NAME = Minesweeper
    PROVISIONING_PROFILE = xxxxx

Any ideas?
 

Jack Cole

Well-Known Member
Licensed User
Ok, this is fairly easy for me to reproduce. You can do it in a brand new project. It only requires the sub declarations (not even the code contained within them). Paste the following code at the bottom of a new project. It gives me the error at End Sub of clear_spaces.

B4X:
Sub SetGameLevel_click(ButtonText As String)

End Sub
Sub Load_Themes
  
End Sub

Sub Initialize_Tabber()

End Sub

Sub settings_tab_setup

End Sub


Sub Load_top_scores

End Sub

Sub Top_Score_Header(l As String)

End Sub

Sub Add_Counts()

End Sub

Sub Add_Minefield(nummines As Int,x1 As Int, y1 As Int)
End Sub

Sub Reveal_Field
End Sub

Sub Init_Minefield(minepanel As Panel)
  
End Sub



Sub setup_field
  
End Sub

Sub Set_Grid_Size(c As Int)
End Sub

Sub set_theme
End Sub

Sub Set_Colors(c As Int,d As Int)
End Sub

Sub update_marked
End Sub

Sub Spaces(x2 As Int, y2 As Int)

End Sub

Sub win

End Sub

Sub clear_square(b As ImageView)

End Sub
Sub loseTmr_tick

End Sub
Sub playagain_click(ButtonText As String)
End Sub
Sub timer_start(x3 As Int,y3 As Int)
End Sub
Sub mark_mine(b As ImageView)
End Sub
Sub longpressTmr_tick
End Sub

Sub button_Click
End Sub

Sub Button1_Click
End Sub


Sub Re_Create
End Sub

Sub load_chrome_nums
End Sub
 
Upvote 0

Jack Cole

Well-Known Member
Licensed User
Systematically commenting out the above subs, I found the one that is a problem: Init_Minefield. If I change it to Initialize_Minefield, it works. Is this a problem with the compiler?

Here is the simplest way to reproduce:

B4X:
Sub Init_test
End Sub

Change the name to Initialize_test and it works fine.
 
Upvote 0
Top